OCT
REM: 1. 添加停止指定能力节点全部处置任务接口的入参判断 1. 添加askController QA测试用例中止指定能力节点全部处置任务的正常用例和异常用例测试代码
This commit is contained in:
parent
e98d71bd2c
commit
2d646afbe4
|
@ -303,6 +303,20 @@ 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 (String.valueOf(stopTaskData.getType()).length() == 0 || stopTaskData.getType() == null) {
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMEXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TaskInfoRsp rspInfo = new TaskInfoRsp();
|
||||
|
||||
reqInfo.getItems().forEach(v -> {
|
||||
|
|
|
@ -47,7 +47,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
private ObjectMapper objectMapper;
|
||||
|
||||
@Test
|
||||
public void t1_NormalContainsNonEmptyTaskTest() throws Exception {
|
||||
public void a1_NormalContainsNonEmptyTaskTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
"\\\"type\\\":0, \\\"disposeIp\\\":\\\"192.168.5.4\\\", " +
|
||||
"\\\"disposeTime\\\":120, \\\"flowDirection\\\":2, \\\"attackType\\\":[0], " +
|
||||
|
@ -81,12 +81,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t2 disposeIp empty exception test.
|
||||
* a2 disposeIp empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t2_startTaskNoDisPoseIpExceptionTest() throws Exception {
|
||||
public void a2_startTaskNoDisPoseIpExceptionTest() throws Exception {
|
||||
String reqDataNoIp = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
"\\\"type\\\":0, \\\"disposeIp\\\":\\\"\\\", \\\"disposeTime\\\":120}\"}";
|
||||
|
||||
|
@ -109,12 +109,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t3 disposeIp null exception test.
|
||||
* a3 disposeIp null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t3_startTaskNullDisposeIpExceptionTest() throws Exception {
|
||||
public void a3_startTaskNullDisposeIpExceptionTest() throws Exception {
|
||||
//disposeIp null
|
||||
String reqDataNullIp = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
"\\\"type\\\":0, \\\"disposeIp\\\":null, \\\"disposeTime\\\":120}\"}";
|
||||
|
@ -138,12 +138,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t4 disposeIp Integer empty exception test.
|
||||
* a4 disposeIp Integer empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t4_startTaskIntegerDisposeIpExceptionTest() throws Exception {
|
||||
public void a4_startTaskIntegerDisposeIpExceptionTest() throws Exception {
|
||||
String reqDataIntegerIp = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
"\\\"type\\\":0, \\\"disposeIp\\\":192345, \\\"disposeTime\\\":120}\"}";
|
||||
|
||||
|
@ -172,12 +172,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t5 id null exception test.
|
||||
* a5 id null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t5_startTaskNullIdExceptionTest() throws Exception {
|
||||
public void a5_startTaskNullIdExceptionTest() throws Exception {
|
||||
String reqDataNullId = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":null," +
|
||||
"\\\"type\\\":0, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":120}\"}";
|
||||
|
||||
|
@ -200,12 +200,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t6 type empty exception test.
|
||||
* a6 type empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t6_startTaskNoTypeExceptionTest() throws Exception {
|
||||
public void a6_startTaskNoTypeExceptionTest() throws Exception {
|
||||
String reqDataNoType = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
"\\\"type\\\":, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":120}\"}";
|
||||
|
||||
|
@ -228,12 +228,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t7 type null exception test.
|
||||
* a7 type null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t7_startTaskNullTypeExceptionTest() throws Exception { //null type
|
||||
public void a7_startTaskNullTypeExceptionTest() throws Exception { //null type
|
||||
String reqDataNullType = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
"\\\"type\\\":null, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":120}\"}";
|
||||
|
||||
|
@ -256,12 +256,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t8 disposeTime empty exception test.
|
||||
* a8 disposeTime empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t8_startTaskNoDisposeTimeExceptionTest() throws Exception {
|
||||
public void a8_startTaskNoDisposeTimeExceptionTest() throws Exception {
|
||||
//no disposeTime
|
||||
String reqDataNoDisposeTime = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
"\\\"type\\\":null, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":}\"}";
|
||||
|
@ -285,12 +285,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t9 disposeTime null exception test.
|
||||
* a9 disposeTime null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t9_startTaskNullDisposeTimeExceptionTest() throws Exception {
|
||||
public void a9_startTaskNullDisposeTimeExceptionTest() throws Exception {
|
||||
//null disposeTime
|
||||
String reqDataNullDisposeTime = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
"\\\"type\\\":0, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":null}\"}";
|
||||
|
@ -314,12 +314,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t10 disposeTime String exception test.
|
||||
* a10 disposeTime String exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t10_startTaskStringDisposeTimeExceptionTest() throws Exception {
|
||||
public void a10_startTaskStringDisposeTimeExceptionTest() throws Exception {
|
||||
//string disposeTime
|
||||
String reqDataStringDisposeTime = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," +
|
||||
"\\\"type\\\":null, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":\\\"120\\\"}\"}";
|
||||
|
@ -343,12 +343,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t11 taskId empty exception test.
|
||||
* b1 taskId empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t11_stopTaskNoTaskIdExceptionTest() throws Exception {
|
||||
public void b1_stopTaskNoTaskIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||
"\"msgContent\":\"{\\\"taskId\\\":\\\"\\\"}\"}";
|
||||
|
||||
|
@ -371,12 +371,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t12 taskId null exception test.
|
||||
* b2 taskId null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t12_stopTaskNullTaskIdExceptionTest() throws Exception {
|
||||
public void b2_stopTaskNullTaskIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||
"\"msgContent\":\"{\\\"taskId\\\":null}\"}";
|
||||
|
||||
|
@ -412,12 +412,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t13 id null exception test.
|
||||
* c1 id null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t13_stopTaskByIpNullIdExceptionTest() throws Exception {
|
||||
public void c1_stopTaskByIpNullIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":null,\\\"type\\\":0,\\\"disposeIp\\\":\\\"192.168.3.4\\\"}]}\"}";
|
||||
|
||||
|
@ -440,12 +440,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t14 id empty exception test.
|
||||
* c2 id empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t14_stopTaskByIpNoIdExceptionTest() throws Exception {
|
||||
public void c2_stopTaskByIpNoIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"192.168.3.4\\\"}]}\"}";
|
||||
|
||||
|
@ -468,12 +468,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t15 disposeIp empty exception test.
|
||||
* c3 disposeIp empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t15_stopTaskByIpNoDisposeIpExceptionTest() throws Exception {
|
||||
public void c3_stopTaskByIpNoDisposeIpExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"\\\"}]}\"}";
|
||||
|
||||
|
@ -496,12 +496,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t16 disposeIp null exception test.
|
||||
* c4 disposeIp null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t16_stopTaskByIpNullDisposeIpExceptionTest() throws Exception {
|
||||
public void c4_stopTaskByIpNullDisposeIpExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":0,\\\"disposeIp\\\":null}]}\"}";
|
||||
|
||||
|
@ -524,12 +524,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t17 disposeIp "abc" exception test.
|
||||
* c5 disposeIp "abc" exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t17_stopTaskByIpErrorDisposeIpExceptionTest() throws Exception {
|
||||
public void c5_stopTaskByIpErrorDisposeIpExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"abc\\\"}]}\"}";
|
||||
|
||||
|
@ -552,12 +552,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t18 disposeIp Integer exception test.
|
||||
* c6 disposeIp Integer exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t18_stopTaskByIpIntegerDisposeIpExceptionTest() throws Exception {
|
||||
public void c6_stopTaskByIpIntegerDisposeIpExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":0,\\\"disposeIp\\\":123}]}\"}";
|
||||
|
||||
|
@ -580,12 +580,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t19 type empty exception test.
|
||||
* c7 type empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t19_stopTaskByIpNoTypeExceptionTest() throws Exception {
|
||||
public void c7_stopTaskByIpNoTypeExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":,\\\"disposeIp\\\":\\\"192.168.5.4\\\"}]}\"}";
|
||||
|
||||
|
@ -608,12 +608,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* t20 type null exception test.
|
||||
* c8 type null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void t20_stopTaskByIpNullTypeExceptionTest() throws Exception {
|
||||
public void c8_stopTaskByIpNullTypeExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"314\\\",\\\"type\\\":null,\\\"disposeIp\\\":\\\"192.168.5.4\\\"}]}\"}";
|
||||
|
||||
|
@ -634,4 +634,225 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* d1 stop task by single node test.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void d1_NormalStopTaskByNodeTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"472\\\",\\\"type\\\":0}]}\"}";
|
||||
|
||||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
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";
|
||||
TaskInfoRsp taskStopByIpRsp = objectMapper.readValue(verifyResp(taskStopByNode), TaskInfoRsp.class);
|
||||
|
||||
List<TaskInfoData> taskInfoList = taskStopByIpRsp.getItems();
|
||||
for (TaskInfoData task : taskInfoList
|
||||
) {
|
||||
Assert.assertNotNull(task.getId());
|
||||
Assert.assertNotNull(task.getTaskId());
|
||||
Assert.assertNotNull(task.getStatus());
|
||||
Assert.assertNotNull(task.getMessage());
|
||||
|
||||
if (task.getStatus() == 0) {
|
||||
Assert.assertEquals(String.valueOf(task.getStatus()), "0");
|
||||
Assert.assertEquals(task.getMessage(), "成功");
|
||||
} else {
|
||||
Assert.assertNotEquals(String.valueOf(task.getStatus()), "0");
|
||||
Assert.assertNotEquals(task.getMessage(), "成功");
|
||||
}
|
||||
|
||||
if (task.getType() != null) {
|
||||
Assert.assertNotEquals(String.valueOf(task.getType()), -1);
|
||||
}
|
||||
|
||||
if (task.getDisposeIp() != null) {
|
||||
Assert.assertTrue(task.getDisposeIp().matches(regex));
|
||||
}
|
||||
|
||||
if (task.getDisposeTime() != null) {
|
||||
Assert.assertNotEquals(String.valueOf(task.getDisposeTime()), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* d2 stop task by two nodes test.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void d2_NormalStopTaskByNodesTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"472\\\",\\\"type\\\":0}, {\\\"id\\\":\\\"471\\\",\\\"type\\\":0}]}\"}";
|
||||
|
||||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
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";
|
||||
TaskInfoRsp taskStopByIpRsp = objectMapper.readValue(verifyResp(taskStopByNode), TaskInfoRsp.class);
|
||||
|
||||
List<TaskInfoData> taskInfoList = taskStopByIpRsp.getItems();
|
||||
for (TaskInfoData task : taskInfoList
|
||||
) {
|
||||
Assert.assertNotNull(task.getId());
|
||||
Assert.assertNotNull(task.getTaskId());
|
||||
Assert.assertNotNull(task.getStatus());
|
||||
Assert.assertNotNull(task.getMessage());
|
||||
|
||||
if (task.getStatus() == 0) {
|
||||
Assert.assertEquals(String.valueOf(task.getStatus()), "0");
|
||||
Assert.assertEquals(task.getMessage(), "成功");
|
||||
} else {
|
||||
Assert.assertNotEquals(String.valueOf(task.getStatus()), "0");
|
||||
Assert.assertNotEquals(task.getMessage(), "成功");
|
||||
}
|
||||
|
||||
if (task.getType() != null) {
|
||||
Assert.assertNotEquals(String.valueOf(task.getType()), -1);
|
||||
}
|
||||
|
||||
if (task.getDisposeIp() != null) {
|
||||
Assert.assertTrue(task.getDisposeIp().matches(regex));
|
||||
}
|
||||
|
||||
if (task.getDisposeTime() != null) {
|
||||
Assert.assertNotEquals(String.valueOf(task.getDisposeTime()), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* d3 id empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d3_stopTaskByNodeNoIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"\\\",\\\"type\\\":0}}\"}";
|
||||
|
||||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.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(taskStopByNode), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* d4 id null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d4_stopTaskByNodeNullIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":null,\\\"type\\\":0}}\"}";
|
||||
|
||||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.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(taskStopByNode), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* d5 type empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d5_stopTaskByNodeNoTypeExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"472\\\",\\\"type\\\":}}\"}";
|
||||
|
||||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.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(taskStopByNode), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* d6 type null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d6_stopTaskByNodeNullTypeExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
|
||||
"[{\\\"id\\\":\\\"472\\\",\\\"type\\\":null}}\"}";
|
||||
|
||||
String taskStopByNode = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/stop_node")
|
||||
.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(taskStopByNode), 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