REM:
1. 增加停止指定处置任务接口中taskId数组中存在元素为null或者空字符串的测试用例,这两种情况都不允许,属于参数错误
2. 增加获取指定能力节点处置任务列表接口中id数组中存在元素为null或者为空字符串的测试用例,为null的话则该数组值为null,只要一个元素为空字符串,id数组值就位空字符串
3. 增加获取处置任务详细信息接口中id数组中存在元素为null或者为空字符串的测试用例,同2
This commit is contained in:
chenlinghy 2020-06-10 10:55:09 +08:00
parent 9cb6dea00c
commit 53e06a7924
1 changed files with 200 additions and 1 deletions

View File

@ -401,6 +401,65 @@ public class TaskControllerQATest extends InitTestEnvironment {
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
}
/**
* b3 stop task array contains null exception test.
*
* @throws Exception the exception
*/
@Test
public void b3_stopTaskArrayContainsNullExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"taskId\\\":[\\\"1\\\", \\\"123\\\", null]}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/task/stop")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(ret), ReturnStatus.class);
Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMS.getMsg());
}
/**
* b4 stop task Array contains empty string exception test. taskId如果是空字符串则参数错误
*
* @throws Exception the exception
*/
@Test
public void b4_stopTaskArrayContainsEmptyStringExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"taskId\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/task/stop")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(ret), ReturnStatus.class);
Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMS.getMsg());
}
/**
* c1 id null exception test.
*
@ -1063,7 +1122,7 @@ public class TaskControllerQATest extends InitTestEnvironment {
}
/**
* id empty test.字符串表示所有能力节点
* id empty test.表示所有能力节点
*/
@Test
public void f2_NormalGetNodeTaskInfoIdTest() throws Exception {
@ -1162,6 +1221,85 @@ public class TaskControllerQATest extends InitTestEnvironment {
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
}
/**
* f5 get node task Array contains null exception test .数组中有一个元素为null 参数错误
*/
@Test
public void f5_GetNodeTaskInfoArrayContainsNullExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\": [\\\"1\\\", null]," +
"\\\"type\\\":0}\"}";
String NodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
.post("/task/get_node")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
.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_PARAMS.getCode()));
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMS.getMsg());
}
/**
* get node task Array contains empty string exception test .数组中有一个元素为空字符串表示所有能力节点
*/
@Test
public void f6_GetNodeTaskInfoArrayContainsEmptyStringExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\": " +
"[\\\"1\\\",\\\"2\\\",\\\"\\\"], \\\"type\\\":0}\"}";
String getNodeTaskInfo = mockMvc.perform(MockMvcRequestBuilders
.post("/task/get_node")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
NodeTaskRsp nodeTaskRsp = objectMapper.readValue(verifyResp(getNodeTaskInfo), NodeTaskRsp.class);
Assert.assertNotNull(nodeTaskRsp);
nodeTaskRsp.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
if (v.getStatus() == 0) {
Assert.assertNotNull(v.getTaskArray());
for (TaskInfoData taskInfoData : v.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(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
} else if (v.getStatus() == 19) {
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
} else if (v.getStatus() == 30) {
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode()));
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_NOSUCHTASK.getMsg());
}
});
}
/**
* taskId empty test. 空字符串表示所有节点任务
*/
@ -1221,4 +1359,65 @@ public class TaskControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
}
/**
* g3 get node detailed info Array contains null exception test .数组中有一个元素为null 参数错误
*/
@Test
public void g3_GetNodeDetailedInfoArrayContainsNullExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
"\"msgContent\":\"{\\\"taskId\\\":[\\\"1\\\", null]}\"}";
String getNodeDetailedInfo = mockMvc.perform(MockMvcRequestBuilders
.post("/task/get")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(getNodeDetailedInfo), ReturnStatus.class);
Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMS.getMsg());
}
/**
* g4 get node task Array contains empty string exception test .数组中有一个元素为空字符串表示所有能力节点
*/
@Test
public void g4_GetNodeDetailedInfoArrayContainsEmptyStringExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
"\"msgContent\":\"{\\\"taskId\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
String getNodeDetailedInfo = mockMvc.perform(MockMvcRequestBuilders
.post("/task/get")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.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());
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}