From 53f6bf54b1f308a1daca7871b0e72c9745c14164 Mon Sep 17 00:00:00 2001 From: chenlinghy Date: Tue, 7 Jul 2020 16:41:23 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E5=A2=9E=E5=8A=A0=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=B9=BF=E6=92=AD=E6=96=B9=E5=BC=8F=E5=AF=B9=E6=89=80?= =?UTF-8?q?=E6=9C=89=E5=A4=84=E7=BD=AE=E8=AE=BE=E5=A4=87=E4=B8=8B=E5=8F=91?= =?UTF-8?q?=E5=A4=84=E7=BD=AE=E4=BB=BB=E5=8A=A1=E7=9A=84=E5=86=92=E7=83=9F?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TaskControllerSmokeTest.java | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/dispose/test/controller/TaskControllerSmokeTest.java b/src/test/java/com/dispose/test/controller/TaskControllerSmokeTest.java index c4b11955..55af2116 100644 --- a/src/test/java/com/dispose/test/controller/TaskControllerSmokeTest.java +++ b/src/test/java/com/dispose/test/controller/TaskControllerSmokeTest.java @@ -51,7 +51,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment { private ObjectMapper objectMapper; @Test - public void t1_NormalTaskTest() throws Exception { + public void t1_BroadcastNormalTaskTest() throws Exception { String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + "\"msgContent\":\"{\\\"id\\\":-1," + "\\\"type\\\":0, " + @@ -87,9 +87,52 @@ public class TaskControllerSmokeTest extends InitTestEnvironment { } } + @Test + public void t2_DesignatedDeviceNormalTaskTest() throws Exception { + + String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + + "\"msgContent\":\"{\\\"id\\\":1," + + "\\\"type\\\":0, " + + "\\\"disposeIp\\\":\\\"192.168.4.2\\\", " + + "\\\"disposeTime\\\":120}\"}"; + + String taskStart = mockMvc.perform(MockMvcRequestBuilders + .post("/task/start") + .contentType(MediaType.APPLICATION_JSON) + .header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken()) + .content(reqData)) + .andDo(print()).andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode())) + .andReturn() + .getResponse() + .getContentAsString(); + + StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class); + + Assert.assertNotNull(startTaskRsp); + Assert.assertNotNull(startTaskRsp.getStatus()); + Assert.assertNotNull(startTaskRsp.getMessage()); + + System.out.println(startTaskRsp.getStatus()); + + if (startTaskRsp.getStatus() == 0) { + Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime())); + Assert.assertNotNull(startTaskRsp.getId()); + Assert.assertNotNull(startTaskRsp.getTaskId()); + Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); + Assert.assertEquals(startTaskRsp.getMessage(), ErrorCode.ERR_OK.getMsg()); + } else if (startTaskRsp.getStatus() == 26) { + Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_TASKRUNNING.getCode())); + Assert.assertEquals(startTaskRsp.getMessage(), ErrorCode.ERR_TASKRUNNING.getMsg()); + }else if(startTaskRsp.getStatus() == 19){ + Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); + Assert.assertEquals(startTaskRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg()); + } + } + @Test - public void t2_NormalStopTaskTest() throws Exception { + public void t3_NormalStopTaskTest() throws Exception { String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + "\"msgContent\":\"{\\\"taskId\\\":[\\\"60\\\", \\\"2\\\" ]}\"}"; @@ -125,7 +168,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment { @Test - public void t3_NormalStopTaskByDisposeIpTest() throws Exception { + public void t4_NormalStopTaskByDisposeIpTest() throws Exception { String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" + "[{\\\"id\\\":\\\"1\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"192.168.3.3\\\"}]}\"}"; @@ -160,7 +203,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment { } @Test - public void t4_NormalGetNodeDetailedInfoTest() throws Exception { + public void t5_NormalGetNodeDetailedInfoTest() throws Exception { String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + "\"msgContent\":\"{\\\"taskId\\\":[\\\"60\\\", \\\"2\\\"]}\"}";