OCT
REM: 1. 添加TaskController QA测试用例中获取节点防护IP接口正常用例和异常用例测试代码 2. 增加获取节点处置任务响应内容中id字段
This commit is contained in:
parent
5ab1ae2a39
commit
9fbb194566
|
@ -420,6 +420,7 @@ public class DisposeTaskController {
|
|||
taskData.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
} else {
|
||||
taskData.setId(v.getId().toString());
|
||||
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||
taskData.setTaskArray(null);
|
||||
|
@ -441,7 +442,7 @@ public class DisposeTaskController {
|
|||
});
|
||||
}
|
||||
|
||||
return ProtocolRespDTO.result(err, rspInfo);
|
||||
return ProtocolRespDTO.result(err, rspInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,6 +4,8 @@ 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.information.NodeTaskData;
|
||||
import com.dispose.pojo.vo.information.NodeTaskRsp;
|
||||
import com.dispose.pojo.vo.task.StartTaskRsp;
|
||||
import com.dispose.pojo.vo.task.TaskInfoRsp;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
@ -1094,4 +1096,223 @@ public class TaskControllerQATest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* f1 get task information of node test.
|
||||
*/
|
||||
@Test
|
||||
public void f1_NormalGetNodeTaskInfoTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\": [\\\"1\\\",\\\"123\\\"]," +
|
||||
"\\\"type\\\":0}\"}";
|
||||
|
||||
String getNodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get_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";
|
||||
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.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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* id empty test.空字符串表示所有能力节点
|
||||
*/
|
||||
@Test
|
||||
public void f2_NormalGetNodeTaskInfoIdTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\": []," +
|
||||
"\\\"type\\\":0}\"}";
|
||||
|
||||
String getNodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get_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";
|
||||
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.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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* type null test.
|
||||
*/
|
||||
@Test
|
||||
public void f3_GetNodeTaskInfoNullTypeExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\": [\\\"1\\\"]," +
|
||||
"\\\"type\\\":null}\"}";
|
||||
|
||||
String NodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get_node")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(NodeTaskInfo), TaskInfoRsp.class);
|
||||
List<TaskInfoData> taskInfoList = startTaskRsp.getItems();
|
||||
for (TaskInfoData task : taskInfoList
|
||||
) {
|
||||
Assert.assertNotNull(task.getId());
|
||||
Assert.assertNotNull(task.getStatus());
|
||||
Assert.assertNotNull(task.getMessage());
|
||||
Assert.assertNotEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* type empty test.
|
||||
*/
|
||||
@Test
|
||||
public void f4_GetNodeTaskInfoNullTypeExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\": [\\\"1\\\"]," +
|
||||
"\\\"type\\\":}\"}";
|
||||
|
||||
String NodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get_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(NodeTaskInfo), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* taskId empty test. 空字符串表示所有节点任务
|
||||
*/
|
||||
@Test
|
||||
public void g1_NormalGetNodeDetailedInfoTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||
"\"msgContent\":\"{\\\"taskId\\\":[]}\"}";
|
||||
|
||||
String getNodeDetailedInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(getNodeDetailedInfo), TaskInfoRsp.class);
|
||||
|
||||
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.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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* taskId null test.
|
||||
*/
|
||||
@Test
|
||||
public void g2_GetNodeDetailedInfoNullTaskIdExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||
"\"msgContent\":\"{\\\"taskId\\\":null}\"}";
|
||||
|
||||
String NodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/get")
|
||||
.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(NodeTaskInfo), 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