REM:
1. 修改处置任务接口异常业务返回信息,异常结果只保留状态码和描述信息
2. 修处置任务接口冒烟测试断言
3. 修改处置任务接口 QA测试断言
This commit is contained in:
chenlinghy 2020-05-19 17:25:43 +08:00
parent 3590774bd8
commit 63ef3e0435
4 changed files with 126 additions and 198 deletions

View File

@ -120,8 +120,6 @@ public class DisposeTaskController {
rspInfo.setTaskId(String.valueOf(ret.getSecondParam()));
} else {
log.error("Failed to create task, error:{}", ret.getFirstParam().getMsg());
rspInfo.setId("-1");
rspInfo.setTaskId("-1");
}
rspInfo.setStatus(ret.getFirstParam().getCode());
@ -161,8 +159,6 @@ public class DisposeTaskController {
if (ret.size() == 0) {
log.error("No such dispose task, taskId:{}", v);
taskData.setId("-1");
taskData.setTaskId(v);
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
rspInfo.getItems().add(taskData);
@ -184,12 +180,9 @@ public class DisposeTaskController {
rspInfo.getItems().add(taskData);
}else{
log.error("Stop task: taskId:{}, error:{}", v, k.getFirstParam().getMsg());
taskData.setId("-1");
taskData.setTaskId("-1");
taskData.setStatus(k.getFirstParam().getCode());
taskData.setMessage(k.getFirstParam().getMsg());
}
});
}
});
@ -229,8 +222,6 @@ public class DisposeTaskController {
if (ret.size() == 0) {
log.error("No such dispose task, taskId:{}", v);
taskData.setId(v.getId());
taskData.setTaskId("-1");
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
rspInfo.getItems().add(taskData);
@ -251,8 +242,6 @@ public class DisposeTaskController {
} else {
log.error("Stop task: taskId:{}, type:{}, disposeIp:{}, error:{}", v.getId(), v.getType(), v.getDisposeIp(),
k.getFirstParam().getMsg());
taskData.setId("-1");
taskData.setTaskId("-1");
taskData.setStatus(k.getFirstParam().getCode());
taskData.setMessage(k.getFirstParam().getMsg());
}
@ -295,8 +284,6 @@ public class DisposeTaskController {
if (ret.size() == 0) {
log.error("No such dispose task, taskId:{}", v);
TaskInfoData taskData = TaskInfoData.builder().type(v.getType()).build();
taskData.setId("-1");
taskData.setTaskId("-1");
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
rspInfo.getItems().add(taskData);
@ -321,8 +308,6 @@ public class DisposeTaskController {
log.error("Stop task: deviceId:{}, type:{}, error:{}", v.getId(),
v.getType(), k.getFirstParam().getMsg());
TaskInfoData taskData = TaskInfoData.builder().type(v.getType()).build();
taskData.setId("-1");
taskData.setTaskId("-1");
taskData.setStatus(k.getFirstParam().getCode());
taskData.setMessage(k.getFirstParam().getMsg());
}
@ -363,8 +348,6 @@ public class DisposeTaskController {
if (ret.size() == 0) {
log.error("No such dispose task");
TaskInfoData taskData = TaskInfoData.builder().type(reqInfo.getType()).build();
taskData.setId("-1");
taskData.setTaskId("-1");
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
rspInfo.getItems().add(taskData);
@ -388,8 +371,6 @@ public class DisposeTaskController {
}else{
log.error("No task to stop: error:{}", k.getFirstParam().getMsg());
TaskInfoData taskData = TaskInfoData.builder().type(reqInfo.getType()).build();
taskData.setId("-1");
taskData.setTaskId("-1");
taskData.setStatus(k.getFirstParam().getCode());
taskData.setMessage(k.getFirstParam().getMsg());
}
@ -473,10 +454,8 @@ public class DisposeTaskController {
log.error("No such task, deviceId:{}", v);
NodeTaskData taskData = new NodeTaskData();
rspInfo.getItems().add(taskData);
taskData.setId(v);
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
taskData.setTaskArray(null);
});
}
@ -544,10 +523,6 @@ public class DisposeTaskController {
log.error("No such task, taskId:{}", v);
TaskInfoData taskData = new TaskInfoData();
rspInfo.getItems().add(taskData);
taskData.setTaskId(v);
taskData.setId("-1");
taskData.setStartTime(0);
taskData.setDisposeTime(0);
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
});

View File

@ -73,13 +73,13 @@ public class TaskControllerQATest extends InitTestEnvironment {
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
Assert.assertNotNull(startTaskRsp);
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertNotNull(startTaskRsp.getStatus());
Assert.assertNotNull(startTaskRsp.getMessage());
if (startTaskRsp.getStatus() == 0) {
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else if (startTaskRsp.getStatus() == 26) {
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_TASKRUNNING.getCode()));
@ -111,10 +111,6 @@ public class TaskControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(startTaskRsp);
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertEquals(startTaskRsp.getId(), "-1");
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertEquals(startTaskRsp.getTaskId(), "-1");
Assert.assertNotNull(startTaskRsp.getStatus());
Assert.assertNotNull(startTaskRsp.getMessage());
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
@ -146,10 +142,6 @@ public class TaskControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(startTaskRsp);
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertEquals(startTaskRsp.getId(), "-1");
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertEquals(startTaskRsp.getTaskId(), "-1");
Assert.assertNotNull(startTaskRsp.getStatus());
Assert.assertNotNull(startTaskRsp.getMessage());
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
@ -180,10 +172,6 @@ public class TaskControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(startTaskRsp);
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertEquals(startTaskRsp.getId(), "-1");
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertEquals(startTaskRsp.getTaskId(), "-1");
Assert.assertNotNull(startTaskRsp.getStatus());
Assert.assertNotNull(startTaskRsp.getMessage());
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
@ -270,10 +258,6 @@ public class TaskControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(startTaskRsp);
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertEquals(startTaskRsp.getId(), "-1");
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertEquals(startTaskRsp.getTaskId(), "-1");
Assert.assertNotNull(startTaskRsp.getStatus());
Assert.assertNotNull(startTaskRsp.getMessage());
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
@ -334,10 +318,6 @@ public class TaskControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(startTaskRsp);
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertEquals(startTaskRsp.getId(), "-1");
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertEquals(startTaskRsp.getTaskId(), "-1");
Assert.assertNotNull(startTaskRsp.getStatus());
Assert.assertNotNull(startTaskRsp.getMessage());
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
@ -369,10 +349,6 @@ public class TaskControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(startTaskRsp);
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertEquals(startTaskRsp.getId(), "-1");
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertEquals(startTaskRsp.getTaskId(), "-1");
Assert.assertNotNull(startTaskRsp.getStatus());
Assert.assertNotNull(startTaskRsp.getMessage());
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
@ -427,24 +403,11 @@ public class TaskControllerQATest extends InitTestEnvironment {
.getResponse()
.getContentAsString();
TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStop), TaskInfoRsp.class);
List<TaskInfoData> taskInfoList = startTaskRsp.getItems();
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(taskStop), ReturnStatus.class);
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()));
}
}
Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
}
/**
@ -527,8 +490,6 @@ public class TaskControllerQATest extends InitTestEnvironment {
TaskInfoRsp rspStatus = objectMapper.readValue(verifyResp(taskStopByIpNoDisposeIp), TaskInfoRsp.class);
rspStatus.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getTaskId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
@ -559,8 +520,6 @@ public class TaskControllerQATest extends InitTestEnvironment {
TaskInfoRsp rspStatus = objectMapper.readValue(verifyResp(taskStopByIpNullDisposeIp), TaskInfoRsp.class);
rspStatus.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getTaskId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
@ -591,8 +550,6 @@ public class TaskControllerQATest extends InitTestEnvironment {
TaskInfoRsp rspStatus = objectMapper.readValue(verifyResp(taskStopByIpErrorDisposeIp), TaskInfoRsp.class);
rspStatus.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getTaskId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
@ -623,8 +580,6 @@ public class TaskControllerQATest extends InitTestEnvironment {
TaskInfoRsp rspStatus = objectMapper.readValue(verifyResp(taskStopByIpIntegerDisposeIp), TaskInfoRsp.class);
rspStatus.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getTaskId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
@ -711,12 +666,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
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.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
@ -748,12 +703,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
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.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
@ -896,12 +851,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
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.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
@ -932,12 +887,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
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.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
@ -969,12 +924,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
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.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
@ -1061,12 +1016,12 @@ public class TaskControllerQATest extends InitTestEnvironment {
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.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
@ -1099,27 +1054,28 @@ public class TaskControllerQATest extends InitTestEnvironment {
List<NodeTaskData> taskInfoList = nodeTaskRsp.getItems();
for (NodeTaskData task : taskInfoList
) {
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
if (task.getStatus() == 0) {
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskArray());
for (TaskInfoData taskInfoData : task.getTaskArray()
) {
Assert.assertNotNull(taskInfoData.getTaskId());
Assert.assertNotNull(taskInfoData.getType());
Assert.assertNotNull(taskInfoData.getStartTime());
Assert.assertNotNull(taskInfoData.getDisposeTime());
Assert.assertNotNull(taskInfoData.getDisposeIp());
Assert.assertTrue(taskInfoData.getDisposeIp().matches(regex));
}
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else if (task.getStatus() == 19) {
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
} else if (task.getStatus() == 30) {
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode()));
}
Assert.assertNotNull(task.getTaskArray());
for (TaskInfoData taskInfoData : task.getTaskArray()
) {
Assert.assertNotNull(taskInfoData.getTaskId());
Assert.assertNotNull(taskInfoData.getType());
Assert.assertNotNull(taskInfoData.getStartTime());
Assert.assertNotNull(taskInfoData.getDisposeTime());
Assert.assertNotNull(taskInfoData.getDisposeIp());
Assert.assertTrue(taskInfoData.getDisposeIp().matches(regex));
}
}
}
@ -1142,33 +1098,32 @@ public class TaskControllerQATest extends InitTestEnvironment {
.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";
NodeTaskRsp nodeTaskRsp = objectMapper.readValue(verifyResp(getNodeTaskInfo), NodeTaskRsp.class);
List<NodeTaskData> taskInfoList = nodeTaskRsp.getItems();
for (NodeTaskData task : taskInfoList
) {
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
if (task.getStatus() == 0) {
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskArray());
for (TaskInfoData taskInfoData : task.getTaskArray()
) {
Assert.assertNotNull(taskInfoData.getTaskId());
Assert.assertNotNull(taskInfoData.getType());
Assert.assertNotNull(taskInfoData.getStartTime());
Assert.assertNotNull(taskInfoData.getDisposeTime());
Assert.assertNotNull(taskInfoData.getDisposeIp());
}
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else if (task.getStatus() == 19) {
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
} else if (task.getStatus() == 30) {
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode()));
}
Assert.assertNotNull(task.getTaskArray());
for (TaskInfoData taskInfoData : task.getTaskArray()
) {
Assert.assertNotNull(taskInfoData.getTaskId());
Assert.assertNotNull(taskInfoData.getType());
Assert.assertNotNull(taskInfoData.getStartTime());
Assert.assertNotNull(taskInfoData.getDisposeTime());
Assert.assertNotNull(taskInfoData.getDisposeIp());
Assert.assertTrue(taskInfoData.getDisposeIp().matches(regex));
}
}
}
@ -1180,7 +1135,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\": [\\\"1\\\"]," +
"\\\"type\\\":null}\"}";
String NodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
String getNodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
.post("/task/get_node")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", "Bearer " + getLogToken())
@ -1191,15 +1146,32 @@ public class TaskControllerQATest extends InitTestEnvironment {
.getResponse()
.getContentAsString();
NodeTaskRsp nodeTaskRsp = objectMapper.readValue(verifyResp(NodeTaskInfo), NodeTaskRsp.class);
NodeTaskRsp nodeTaskRsp = objectMapper.readValue(verifyResp(getNodeTaskInfo), NodeTaskRsp.class);
List<NodeTaskData> taskInfoList = nodeTaskRsp.getItems();
for (NodeTaskData task : taskInfoList
) {
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode()));
if (task.getStatus() == 0) {
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskArray());
for (TaskInfoData taskInfoData : task.getTaskArray()
) {
Assert.assertNotNull(taskInfoData.getTaskId());
Assert.assertNotNull(taskInfoData.getType());
Assert.assertNotNull(taskInfoData.getStartTime());
Assert.assertNotNull(taskInfoData.getDisposeTime());
Assert.assertNotNull(taskInfoData.getDisposeIp());
}
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else if (task.getStatus() == 19) {
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
} else if (task.getStatus() == 30) {
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode()));
}
}
}

View File

@ -54,7 +54,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
"\"msgContent\":\"{\\\"id\\\":-1," +
"\\\"type\\\":0, " +
"\\\"disposeIp\\\":\\\"192.168.3.2\\\", " +
"\\\"disposeIp\\\":\\\"192.168.5.8\\\", " +
"\\\"disposeTime\\\":120}\"}";
String taskStart = mockMvc.perform(MockMvcRequestBuilders
@ -71,13 +71,13 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class);
Assert.assertNotNull(startTaskRsp);
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertNotNull(startTaskRsp.getStatus());
Assert.assertNotNull(startTaskRsp.getMessage());
if (startTaskRsp.getStatus() == 0) {
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else if (startTaskRsp.getStatus() == 26) {
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_TASKRUNNING.getCode()));
@ -88,7 +88,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
@Test
public void t2_NormalStopTaskTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
"\"msgContent\":\"{\\\"taskId\\\":[\\\"1\\\", \\\"2\\\" ]}\"}";
"\"msgContent\":\"{\\\"taskId\\\":[\\\"60\\\", \\\"2\\\" ]}\"}";
String taskStop = mockMvc.perform(MockMvcRequestBuilders
.post("/task/stop")
@ -105,12 +105,12 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
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());
if (task.getStatus() == 0) {
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else if (task.getStatus() == 30) {
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode()));
@ -122,7 +122,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
@Test
public void t3_NormalStopTaskByDisposeIpTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" +
"[{\\\"id\\\":\\\"1\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"192.168.3.2\\\"}]}\"}";
"[{\\\"id\\\":\\\"1\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"192.168.3.3\\\"}]}\"}";
String taskStopByIp = mockMvc.perform(MockMvcRequestBuilders
.post("/task/stop_ip")
@ -139,12 +139,12 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
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());
if (task.getStatus() == 0) {
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else if (task.getStatus() == 30) {
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode()));
@ -155,7 +155,7 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
@Test
public void t4_NormalGetNodeDetailedInfoTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
"\"msgContent\":\"{\\\"taskId\\\":[\\\"1\\\", \\\"2\\\"]}\"}";
"\"msgContent\":\"{\\\"taskId\\\":[\\\"60\\\", \\\"2\\\"]}\"}";
String getNodeDetailedInfo = mockMvc.perform(MockMvcRequestBuilders
.post("/task/get")
@ -173,14 +173,14 @@ public class TaskControllerSmokeTest extends InitTestEnvironment {
List<TaskInfoData> taskInfoList = startTaskRsp.getItems();
for (TaskInfoData task : taskInfoList
) {
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertNotNull(task.getStartTime());
Assert.assertNotNull(task.getDisposeTime());
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
if (task.getStatus() == 0) {
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertNotNull(task.getStartTime());
Assert.assertNotNull(task.getDisposeTime());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else if (task.getStatus() == 30) {
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode()));

View File

@ -149,14 +149,14 @@ public class TaskControllerTest extends InitTestEnvironment {
//将json字符串转为StartTaskRsp类
StartTaskRsp startTaskRsp = objectMapper.readValue(msgContent, StartTaskRsp.class);
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotEquals(String.valueOf(startTaskRsp.getExpireTime()), -1);
Assert.assertNotNull(startTaskRsp.getStatus());
Assert.assertNotNull(startTaskRsp.getMessage());
if (startTaskRsp.getStatus() == 0) {
Assert.assertNotNull(startTaskRsp.getId());
Assert.assertNotNull(startTaskRsp.getTaskId());
Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime()));
Assert.assertNotEquals(String.valueOf(startTaskRsp.getExpireTime()), -1);
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
@ -201,12 +201,12 @@ public class TaskControllerTest extends InitTestEnvironment {
List<TaskInfoData> taskInfoList = taskStopRsp.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.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
@ -259,12 +259,12 @@ public class TaskControllerTest extends InitTestEnvironment {
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.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
@ -313,14 +313,14 @@ public class TaskControllerTest extends InitTestEnvironment {
List<TaskInfoData> taskInfoList = taskStopByIpRsp.getItems();
for (TaskInfoData task : taskInfoList
) {
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
if (task.getStatus() == ErrorCode.ERR_OK.getCode()) {
Assert.assertEquals((int) task.getStatus(), ErrorCode.ERR_OK.getCode());
Assert.assertEquals(task.getMessage(), ErrorCode.ERR_OK.getMsg());
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
} else {
Assert.assertNotEquals((int) task.getStatus(), ErrorCode.ERR_OK.getCode());
}
@ -372,14 +372,14 @@ public class TaskControllerTest extends InitTestEnvironment {
List<TaskInfoData> taskInfoList = taskStopByIpRsp.getItems();
for (TaskInfoData task : taskInfoList
) {
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
if (task.getStatus() == ErrorCode.ERR_OK.getCode()) {
Assert.assertEquals((int) task.getStatus(), ErrorCode.ERR_OK.getCode());
Assert.assertEquals(task.getMessage(), ErrorCode.ERR_OK.getMsg());
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
} else {
Assert.assertNotEquals((int) task.getStatus(), ErrorCode.ERR_OK.getCode());
}
@ -424,14 +424,14 @@ public class TaskControllerTest extends InitTestEnvironment {
List<TaskInfoData> taskInfoList = taskStopByIpRsp.getItems();
for (TaskInfoData task : taskInfoList
) {
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
if (task.getStatus() == ErrorCode.ERR_OK.getCode()) {
Assert.assertEquals((int) task.getStatus(), ErrorCode.ERR_OK.getCode());
Assert.assertEquals(task.getMessage(), ErrorCode.ERR_OK.getMsg());
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskId());
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
} else {
Assert.assertNotEquals((int) task.getStatus(), ErrorCode.ERR_OK.getCode());
}
@ -478,37 +478,27 @@ public class TaskControllerTest extends InitTestEnvironment {
List<NodeTaskData> taskInfoList = nodeTaskRsp.getItems();
for (NodeTaskData taskNode : taskInfoList
) {
Assert.assertNotNull(taskNode.getId());
Assert.assertNotNull(taskNode.getStatus());
Assert.assertNotNull(taskNode.getMessage());
if (taskNode.getStatus() == 0) {
Assert.assertNotNull(taskNode.getId());
Assert.assertNotNull(taskNode.getTaskArray());
if (taskNode.getTaskArray().size() != 0) {
for (TaskInfoData task : taskNode.getTaskArray()
) {
Assert.assertNotNull(task.getTaskId());
Assert.assertNotNull(task.getType());
Assert.assertNotNull(task.getStartTime());
Assert.assertNotNull(task.getStartTime());
Assert.assertNotNull(task.getDisposeIp());
Assert.assertTrue(task.getDisposeIp().matches(regex));
}
}
Assert.assertEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
Assert.assertNotNull(taskNode.getTaskArray());
if (taskNode.getTaskArray().size() != 0) {
for (TaskInfoData task : taskNode.getTaskArray()
) {
Assert.assertNotNull(task.getTaskId());
Assert.assertNotNull(task.getType());
Assert.assertNotNull(task.getStartTime());
Assert.assertNotEquals(task.getStartTime(), "-1");
Assert.assertNotNull(task.getStartTime());
Assert.assertNotEquals(task.getStartTime(), "-1");
Assert.assertNotNull(task.getDisposeIp());
Assert.assertTrue(task.getDisposeIp().matches(regex));
if (task.getFlowAttack() != null) {
Assert.assertNotEquals(task.getFlowAttack(), "-1");
}
if (task.getFlowClean() != null) {
Assert.assertNotEquals(task.getFlowClean(), "-1");
}
}
}
}
}
@ -552,37 +542,28 @@ public class TaskControllerTest extends InitTestEnvironment {
List<NodeTaskData> taskInfoList = nodeTaskRsp.getItems();
for (NodeTaskData taskNode : taskInfoList
) {
Assert.assertNotNull(taskNode.getId());
Assert.assertNotNull(taskNode.getStatus());
Assert.assertNotNull(taskNode.getMessage());
if (taskNode.getStatus() == 0) {
Assert.assertNotNull(taskNode.getId());
Assert.assertNotNull(taskNode.getTaskArray());
if (taskNode.getTaskArray().size() != 0) {
for (TaskInfoData task : taskNode.getTaskArray()
) {
Assert.assertNotNull(task.getTaskId());
Assert.assertNotNull(task.getType());
Assert.assertNotNull(task.getStartTime());
Assert.assertNotNull(task.getStartTime());
Assert.assertNotNull(task.getDisposeIp());
Assert.assertTrue(task.getDisposeIp().matches(regex));
}
}
Assert.assertEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
Assert.assertNotNull(taskNode.getTaskArray());
if (taskNode.getTaskArray().size() != 0) {
for (TaskInfoData task : taskNode.getTaskArray()
) {
Assert.assertNotNull(task.getTaskId());
Assert.assertNotNull(task.getType());
Assert.assertNotNull(task.getStartTime());
Assert.assertNotEquals(task.getStartTime(), "-1");
Assert.assertNotNull(task.getStartTime());
Assert.assertNotEquals(task.getStartTime(), "-1");
Assert.assertNotNull(task.getDisposeIp());
Assert.assertTrue(task.getDisposeIp().matches(regex));
if (task.getFlowAttack() != null) {
Assert.assertNotEquals(task.getFlowAttack(), "-1");
}
if (task.getFlowClean() != null) {
Assert.assertNotEquals(task.getFlowClean(), "-1");
}
}
}
}
}