parent
315f15386e
commit
d66e2d6f66
|
@ -2,6 +2,7 @@ package com.dispose.controller;
|
|||
|
||||
import com.dispose.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.po.ReturnStatus;
|
||||
import com.dispose.pojo.vo.common.TaskInfoData;
|
||||
import com.dispose.pojo.vo.task.StartTaskRsp;
|
||||
import com.dispose.pojo.vo.task.TaskInfoRsp;
|
||||
|
@ -95,12 +96,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,12 +121,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,7 +156,8 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void t5_startTaskNullIdExceptionTest() throws Exception {
|
||||
|
@ -176,12 +176,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -201,12 +200,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,12 +224,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -251,12 +248,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -277,12 +273,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -302,12 +297,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(startTaskRsp);
|
||||
Assert.assertNotNull(startTaskRsp.getStatus());
|
||||
Assert.assertNotNull(startTaskRsp.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -327,16 +321,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStop), TaskInfoRsp.class);
|
||||
List<TaskInfoData> taskInfoList = startTaskRsp.getItems();
|
||||
for (TaskInfoData task : taskInfoList
|
||||
) {
|
||||
Assert.assertNotNull(task.getId());
|
||||
Assert.assertNotNull(task.getTaskId());
|
||||
Assert.assertNotNull(task.getStatus());
|
||||
Assert.assertNotNull(task.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStop), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -357,40 +346,48 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
|
||||
TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStop), TaskInfoRsp.class);
|
||||
List<TaskInfoData> taskInfoList = startTaskRsp.getItems();
|
||||
for (TaskInfoData task : taskInfoList
|
||||
) {
|
||||
Assert.assertNotNull(task.getId());
|
||||
Assert.assertNotNull(task.getTaskId());
|
||||
Assert.assertNotNull(task.getStatus());
|
||||
Assert.assertNotNull(task.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
|
||||
if (taskInfoList.size() == 0) {
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStop), ReturnStatus.class);
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
} else {
|
||||
for (TaskInfoData task : taskInfoList
|
||||
) {
|
||||
Assert.assertNotNull(task.getId());
|
||||
Assert.assertNotNull(task.getTaskId());
|
||||
Assert.assertNotNull(task.getStatus());
|
||||
Assert.assertNotNull(task.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void t13_stopTaskIntegerTaskIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||
"\"msgContent\":\"{\\\"taskId\\\":[445, 235]}\"}";
|
||||
|
||||
String taskStop = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop")
|
||||
@Test
|
||||
public void t13_stopTaskByIpNullIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":null,\\\"type\\\":0,\\\"disposeIp\\\":\\\"192.168.3.4\\\"}]}\"}";
|
||||
|
||||
String taskStopByIpNullId = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStop), TaskInfoRsp.class);
|
||||
List<TaskInfoData> taskInfoList = startTaskRsp.getItems();
|
||||
for (TaskInfoData task : taskInfoList
|
||||
) {
|
||||
Assert.assertNotNull(task.getId());
|
||||
Assert.assertNotNull(task.getTaskId());
|
||||
Assert.assertNotNull(task.getStatus());
|
||||
Assert.assertNotNull(task.getMessage());
|
||||
}
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpNullId), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue