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.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()));
}
@ -159,6 +158,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
}
@Test
public void t5_startTaskNullIdExceptionTest() throws Exception {
//Id null
@ -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,6 +346,13 @@ public class TaskControllerQATest extends InitTestEnvironment {
TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStop), TaskInfoRsp.class);
List<TaskInfoData> taskInfoList = startTaskRsp.getItems();
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());
@ -367,30 +363,31 @@ public class TaskControllerQATest extends InitTestEnvironment {
}
}
@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()));
}
}