REM:
1. 修改askController QA测试用例
This commit is contained in:
chenlinghy 2020-05-09 12:29:19 +08:00
parent 315f15386e
commit d66e2d6f66
1 changed files with 71 additions and 74 deletions

View File

@ -2,6 +2,7 @@ package com.dispose.controller;
import com.dispose.Global.InitTestEnvironment; import com.dispose.Global.InitTestEnvironment;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.pojo.po.ReturnStatus;
import com.dispose.pojo.vo.common.TaskInfoData; import com.dispose.pojo.vo.common.TaskInfoData;
import com.dispose.pojo.vo.task.StartTaskRsp; import com.dispose.pojo.vo.task.StartTaskRsp;
import com.dispose.pojo.vo.task.TaskInfoRsp; import com.dispose.pojo.vo.task.TaskInfoRsp;
@ -95,12 +96,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class); ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
Assert.assertNotNull(startTaskRsp); Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(startTaskRsp.getStatus()); Assert.assertNotNull(returnStatus.getMessage());
Assert.assertNotNull(startTaskRsp.getMessage()); Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
} }
@ -121,12 +121,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class); ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
Assert.assertNotNull(startTaskRsp); Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(startTaskRsp.getStatus()); Assert.assertNotNull(returnStatus.getMessage());
Assert.assertNotNull(startTaskRsp.getMessage()); Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
} }
@ -157,7 +156,8 @@ public class TaskControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(startTaskRsp.getStatus()); Assert.assertNotNull(startTaskRsp.getStatus());
Assert.assertNotNull(startTaskRsp.getMessage()); Assert.assertNotNull(startTaskRsp.getMessage());
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
} }
@Test @Test
public void t5_startTaskNullIdExceptionTest() throws Exception { public void t5_startTaskNullIdExceptionTest() throws Exception {
@ -176,12 +176,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class); ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
Assert.assertNotNull(startTaskRsp); Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(startTaskRsp.getStatus()); Assert.assertNotNull(returnStatus.getMessage());
Assert.assertNotNull(startTaskRsp.getMessage()); Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
} }
@Test @Test
@ -201,12 +200,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class); ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
Assert.assertNotNull(startTaskRsp); Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(startTaskRsp.getStatus()); Assert.assertNotNull(returnStatus.getMessage());
Assert.assertNotNull(startTaskRsp.getMessage()); Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
} }
@ -226,12 +224,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class); ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
Assert.assertNotNull(startTaskRsp); Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(startTaskRsp.getStatus()); Assert.assertNotNull(returnStatus.getMessage());
Assert.assertNotNull(startTaskRsp.getMessage()); Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
} }
@Test @Test
@ -251,12 +248,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class); ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
Assert.assertNotNull(startTaskRsp); Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(startTaskRsp.getStatus()); Assert.assertNotNull(returnStatus.getMessage());
Assert.assertNotNull(startTaskRsp.getMessage()); Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
} }
@ -277,12 +273,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class); ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
Assert.assertNotNull(startTaskRsp); Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(startTaskRsp.getStatus()); Assert.assertNotNull(returnStatus.getMessage());
Assert.assertNotNull(startTaskRsp.getMessage()); Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
} }
@Test @Test
@ -302,12 +297,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class); ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStart), ReturnStatus.class);
Assert.assertNotNull(startTaskRsp); Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(startTaskRsp.getStatus()); Assert.assertNotNull(returnStatus.getMessage());
Assert.assertNotNull(startTaskRsp.getMessage()); Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
} }
@ -327,16 +321,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStop), TaskInfoRsp.class); ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStop), ReturnStatus.class);
List<TaskInfoData> taskInfoList = startTaskRsp.getItems();
for (TaskInfoData task : taskInfoList Assert.assertNotNull(returnStatus.getStatus());
) { Assert.assertNotNull(returnStatus.getMessage());
Assert.assertNotNull(task.getId()); Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
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 @Test
@ -357,40 +346,48 @@ public class TaskControllerQATest extends InitTestEnvironment {
TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStop), TaskInfoRsp.class); TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStop), TaskInfoRsp.class);
List<TaskInfoData> taskInfoList = startTaskRsp.getItems(); List<TaskInfoData> taskInfoList = startTaskRsp.getItems();
for (TaskInfoData task : taskInfoList
) { if (taskInfoList.size() == 0) {
Assert.assertNotNull(task.getId()); ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStop), ReturnStatus.class);
Assert.assertNotNull(task.getTaskId()); Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(task.getStatus()); Assert.assertNotNull(returnStatus.getMessage());
Assert.assertNotNull(task.getMessage()); Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(Long.valueOf(task.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 @Test
.post("/task/stop") 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) .contentType(MediaType.APPLICATION_JSON)
.header("Authorization", "Bearer " + getLogToken()) .header("Authorization", "Bearer " + getLogToken())
.content(reqData)) .content(reqData))
.andDo(print()).andExpect(status().isOk()) .andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200)) .andExpect(jsonPath("$.code").value(521))
.andReturn() .andReturn()
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStop), TaskInfoRsp.class); ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpNullId), ReturnStatus.class);
List<TaskInfoData> taskInfoList = startTaskRsp.getItems();
for (TaskInfoData task : taskInfoList Assert.assertNotNull(returnStatus.getStatus());
) { Assert.assertNotNull(returnStatus.getMessage());
Assert.assertNotNull(task.getId()); Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertNotNull(task.getTaskId());
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
}
} }
} }