OCT
REM: 1. 添加askController QA测试用例注释 2. 添加askController QA测试用例中停止某处置IP的处置任务的异常用例测试代码 3. 修改askController冒烟测试用例中状态码的判断 4. 添加停止某IP处置IP的处置任务接口中入参判断 5. 修改StopTask类中type字段的类型
This commit is contained in:
parent
391a062e69
commit
f2a1788eae
|
@ -221,6 +221,7 @@ public class DisposeTaskController {
|
|||
public ProtocolRespDTO taskStopByIp(@RequestBody ProtocolReqDTO mr,
|
||||
@RequestHeader HttpHeaders headers)
|
||||
throws JsonProcessingException {
|
||||
String regex = "\\A(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z";
|
||||
ErrorCode err = mr.verifyRequest(headers);
|
||||
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
|
@ -228,6 +229,24 @@ public class DisposeTaskController {
|
|||
}
|
||||
|
||||
StopTaskReq reqInfo = mr.getRequestObject(StopTaskReq.class);
|
||||
List<StopTaskData> item = reqInfo.getItems();
|
||||
for (StopTaskData stopTaskData : item
|
||||
) {
|
||||
if (stopTaskData.getId() == null || stopTaskData.getId().length() == 0) {
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMEXCEPTION);
|
||||
}
|
||||
|
||||
if (stopTaskData.getDisposeIp() == null || stopTaskData.getDisposeIp().length() == 0) {
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMEXCEPTION);
|
||||
} else if (!stopTaskData.getDisposeIp().matches(regex)) {
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMEXCEPTION);
|
||||
}
|
||||
|
||||
if (String.valueOf(stopTaskData.getType()).length() == 0 || stopTaskData.getType() == null) {
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMEXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
TaskInfoRsp rspInfo = new TaskInfoRsp();
|
||||
|
||||
reqInfo.getItems().forEach(v -> {
|
||||
|
@ -512,7 +531,10 @@ public class DisposeTaskController {
|
|||
unExists.forEach(v -> {
|
||||
TaskInfoData taskData = new TaskInfoData();
|
||||
rspInfo.getItems().add(taskData);
|
||||
taskData.setTaskId("-1");
|
||||
taskData.setId(v);
|
||||
taskData.setStartTime(0);
|
||||
taskData.setDisposeTime(0);
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ public class StopTaskData {
|
|||
/**
|
||||
* The Type.
|
||||
*/
|
||||
private int type;
|
||||
private Integer type;
|
||||
/**
|
||||
* The Dispose ip.
|
||||
*/
|
||||
|
|
|
@ -80,10 +80,15 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* t2 disposeIp empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t2_startTaskNoDisPoseIpExceptionTest() throws Exception {
|
||||
String reqDataNoIp = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
"\\\"type\\\":0, \\\"disposeIp\\\":, \\\"disposeTime\\\":120}\"}";
|
||||
"\\\"type\\\":0, \\\"disposeIp\\\":\\\"\\\", \\\"disposeTime\\\":120}\"}";
|
||||
|
||||
String taskStart = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/start")
|
||||
|
@ -103,7 +108,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* t3 disposeIp null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t3_startTaskNullDisposeIpExceptionTest() throws Exception {
|
||||
//disposeIp null
|
||||
|
@ -128,7 +137,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* t4 disposeIp Integer empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t4_startTaskIntegerDisposeIpExceptionTest() throws Exception {
|
||||
String reqDataIntegerIp = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
|
@ -158,10 +171,13 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* t5 id null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t5_startTaskNullIdExceptionTest() throws Exception {
|
||||
//Id null
|
||||
String reqDataNullId = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":null," +
|
||||
"\\\"type\\\":0, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":120}\"}";
|
||||
|
||||
|
@ -183,9 +199,13 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* t6 type empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t6_startTaskNoTypeExceptionTest() throws Exception {
|
||||
//no type
|
||||
String reqDataNoType = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
"\\\"type\\\":, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":120}\"}";
|
||||
|
||||
|
@ -207,7 +227,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* t7 type null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t7_startTaskNullTypeExceptionTest() throws Exception { //null type
|
||||
String reqDataNullType = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
|
@ -231,6 +255,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* t8 disposeTime empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t8_startTaskNoDisposeTimeExceptionTest() throws Exception {
|
||||
//no disposeTime
|
||||
|
@ -255,7 +284,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* t9 disposeTime null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t9_startTaskNullDisposeTimeExceptionTest() throws Exception {
|
||||
//null disposeTime
|
||||
|
@ -280,6 +313,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* t10 disposeTime String exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t10_startTaskStringDisposeTimeExceptionTest() throws Exception {
|
||||
//string disposeTime
|
||||
|
@ -304,11 +342,15 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* t11 taskId empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t11_stopTaskNoTaskIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||
"\"msgContent\":\"{\\\"taskId\\\":}\"}";
|
||||
"\"msgContent\":\"{\\\"taskId\\\":\\\"\\\"}\"}";
|
||||
|
||||
String taskStop = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop")
|
||||
|
@ -328,6 +370,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* t12 taskId null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t12_stopTaskNullTaskIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||
|
@ -362,10 +409,13 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* t13 id null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t13_stopTaskByIpNullIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
|
@ -389,5 +439,199 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* t14 id empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t14_stopTaskByIpNoIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"192.168.3.4\\\"}]}\"}";
|
||||
|
||||
String taskStopByIpNollId = 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(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpNollId), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* t15 disposeIp empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t15_stopTaskByIpNoDisposeIpExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"\\\"}]}\"}";
|
||||
|
||||
String taskStopByIpNoDisposeIp = 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(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpNoDisposeIp), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* t16 disposeIp null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t16_stopTaskByIpNullDisposeIpExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":0,\\\"disposeIp\\\":null}]}\"}";
|
||||
|
||||
String taskStopByIpNullDisposeIp = 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(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpNullDisposeIp), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* t17 disposeIp "abc" exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t17_stopTaskByIpErrorDisposeIpExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"abc\\\"}]}\"}";
|
||||
|
||||
String taskStopByIpErrorDisposeIp = 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(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpErrorDisposeIp), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* t18 disposeIp Integer exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t18_stopTaskByIpIntegerDisposeIpExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":0,\\\"disposeIp\\\":123}]}\"}";
|
||||
|
||||
String taskStopByIpIntegerDisposeIp = 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(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpIntegerDisposeIp), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* t19 type empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t19_stopTaskByIpNoTypeExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":,\\\"disposeIp\\\":\\\"192.168.5.4\\\"}]}\"}";
|
||||
|
||||
String taskStopByIpNoType = 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(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpNoType), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* t20 type null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t20_stopTaskByIpNullTypeExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":null,\\\"disposeIp\\\":\\\"192.168.5.4\\\"}]}\"}";
|
||||
|
||||
String taskStopByIpNullType = 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(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStopByIpNullType), 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