parent
499ea8f733
commit
53f6bf54b1
|
@ -51,7 +51,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
|
||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void t1_NormalTaskTest() throws Exception {
|
public void t1_BroadcastNormalTaskTest() throws Exception {
|
||||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||||
"\"msgContent\":\"{\\\"id\\\":-1," +
|
"\"msgContent\":\"{\\\"id\\\":-1," +
|
||||||
"\\\"type\\\":0, " +
|
"\\\"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
|
@Test
|
||||||
public void t2_NormalStopTaskTest() throws Exception {
|
public void t3_NormalStopTaskTest() throws Exception {
|
||||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||||
"\"msgContent\":\"{\\\"taskId\\\":[\\\"60\\\", \\\"2\\\" ]}\"}";
|
"\"msgContent\":\"{\\\"taskId\\\":[\\\"60\\\", \\\"2\\\" ]}\"}";
|
||||||
|
|
||||||
|
@ -125,7 +168,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void t3_NormalStopTaskByDisposeIpTest() throws Exception {
|
public void t4_NormalStopTaskByDisposeIpTest() throws Exception {
|
||||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||||
"[{\\\"id\\\":\\\"1\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"192.168.3.3\\\"}]}\"}";
|
"[{\\\"id\\\":\\\"1\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"192.168.3.3\\\"}]}\"}";
|
||||||
|
|
||||||
|
@ -160,7 +203,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void t4_NormalGetNodeDetailedInfoTest() throws Exception {
|
public void t5_NormalGetNodeDetailedInfoTest() throws Exception {
|
||||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||||
"\"msgContent\":\"{\\\"taskId\\\":[\\\"60\\\", \\\"2\\\"]}\"}";
|
"\"msgContent\":\"{\\\"taskId\\\":[\\\"60\\\", \\\"2\\\"]}\"}";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue