REM:
1. 增加获取能力节点列表和详细信息接口数组中存在元素为null的测试用例
2. 增加获取能力节点列表和详细信息接口数组中存在元素为空字符串的测试用例
This commit is contained in:
chenlinghy 2020-06-09 17:42:30 +08:00
parent ed30556cae
commit 9cb6dea00c
1 changed files with 231 additions and 97 deletions

View File

@ -2258,19 +2258,17 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
Assert.assertNotNull(rspInfo);
if (rspInfo.getItems().size() > 0) {
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
) {
Assert.assertNotNull(disposeNodeData);
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
Assert.assertNotNull(disposeNodeData.getName());
Assert.assertNotNull(disposeNodeData.getIp());
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getId());
Assert.assertNotNull(String.valueOf(v.getType()));
Assert.assertNotNull(v.getName());
Assert.assertNotNull(v.getIp());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
});
}
@ -2298,24 +2296,23 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
Assert.assertNotNull(rspInfo);
if (rspInfo.getItems().size() > 0) {
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
) {
Assert.assertNotNull(disposeNodeData);
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
if (disposeNodeData.getStatus() == 0) {
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
Assert.assertNotNull(disposeNodeData.getName());
Assert.assertNotNull(disposeNodeData.getIp());
} else {
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
if (v.getStatus() == 0) {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(String.valueOf(v.getType()));
Assert.assertNotNull(v.getName());
Assert.assertNotNull(v.getIp());
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
} else {
Assert.assertNotEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
}
}
});
}
@ -2343,28 +2340,27 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
Assert.assertNotNull(rspInfo);
if (rspInfo.getItems().size() > 0) {
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
) {
Assert.assertNotNull(disposeNodeData);
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
if (disposeNodeData.getStatus() == 0) {
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
Assert.assertNotNull(disposeNodeData.getName());
Assert.assertNotNull(disposeNodeData.getIp());
} else {
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
if (v.getStatus() == 0) {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(String.valueOf(v.getType()));
Assert.assertNotNull(v.getName());
Assert.assertNotNull(v.getIp());
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
} else {
Assert.assertNotEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
}
}
});
}
/**
* H 4 msgContent empty 目前默认这种情况是允许的获取所有节点列表信息
* H 4 get node list msgContent empty exception test.
*
* @throws Exception the exception
*/
@ -2389,11 +2385,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
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());
}
/**
* H 5 msgContent null 目前默认这种情况是允许的获取所有节点列表信息
* H 5 get node list msgContent null exception test.
*
* @throws Exception the exception
*/
@ -2421,7 +2418,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
/**
* H 6 id null 不允许
* H 6 get node list id null exception test.
*
* @throws Exception the exception
*/
@ -2446,10 +2443,11 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
}
/**
* H 7 id "abd"
* H 7 get node list id "abd" exception test.
*
* @throws Exception the exception
*/
@ -2481,6 +2479,74 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* H 8 get node list array contains null exception test.
*
* @throws Exception the exception
*/
@Test
public void h8_getNodeListArrayContainsNullExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", null]}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/information/node_list")
.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());
}
/**
* H 9 get node list Array contains empty string exception test.
*
* @throws Exception the exception
*/
@Test
public void h9_getNodeListArrayContainsEmptyStringExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/information/node_list")
.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();
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
Assert.assertNotNull(rspInfo);
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getId());
Assert.assertNotNull(String.valueOf(v.getType()));
Assert.assertNotNull(v.getName());
Assert.assertNotNull(v.getIp());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
});
}
/**
* I 1 get multiple Node Details Normal Test.
*
@ -2505,31 +2571,29 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
Assert.assertNotNull(rspInfo);
if (rspInfo.getItems().size() > 0) {
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
) {
Assert.assertNotNull(disposeNodeData);
if (disposeNodeData.getStatus() == 0) {
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
Assert.assertNotNull(disposeNodeData.getIp());
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
Assert.assertNotNull(disposeNodeData.getCapacity());
for (DisposeCapacity disposeCapacity : disposeNodeData.getCapacity()
) {
Assert.assertNotNull(disposeCapacity.getType());
Assert.assertNotNull(disposeCapacity.getDisposeIp());
}
} else {
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
if (v.getStatus() == 0) {
Assert.assertNotNull(String.valueOf(v.getType()));
Assert.assertNotNull(v.getIp());
Assert.assertNotNull(v.getCapacity());
for (DisposeCapacity disposeCapacity : v.getCapacity()
) {
Assert.assertNotNull(disposeCapacity.getType());
Assert.assertNotNull(disposeCapacity.getDisposeIp());
}
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
} else {
Assert.assertNotEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
}
}
});
}
/**
@ -2556,31 +2620,29 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
Assert.assertNotNull(rspInfo);
if (rspInfo.getItems().size() > 0) {
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
) {
Assert.assertNotNull(disposeNodeData);
if (disposeNodeData.getStatus() == 0) {
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
Assert.assertNotNull(disposeNodeData.getIp());
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
Assert.assertNotNull(disposeNodeData.getCapacity());
for (DisposeCapacity disposeCapacity : disposeNodeData.getCapacity()
) {
Assert.assertNotNull(disposeCapacity.getType());
Assert.assertNotNull(disposeCapacity.getDisposeIp());
}
} else {
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
if (v.getStatus() == 0) {
Assert.assertNotNull(String.valueOf(v.getType()));
Assert.assertNotNull(v.getIp());
Assert.assertNotNull(v.getCapacity());
for (DisposeCapacity disposeCapacity : v.getCapacity()
) {
Assert.assertNotNull(disposeCapacity.getType());
Assert.assertNotNull(disposeCapacity.getDisposeIp());
}
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
} else {
Assert.assertNotEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
}
}
});
}
@ -2613,12 +2675,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
/**
* I 3 id null.
* I 4 get node details id null exception test.
*
* @throws Exception the exception
*/
@Test
public void i3_getNodeDetailsNullIdExceptionTest() throws Exception {
public void i4_getNodeDetailsNullIdExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504,\"msgContent\":" +
"\"{\\\"id\\\":null}\"}";
@ -2643,12 +2705,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
/**
* I 4 id "abd".
* I 5 get node details id "abd" exception test.
*
* @throws Exception the exception
*/
@Test
public void i4_getNodeDetailsErrorIdExceptionTest() throws Exception {
public void i5_getNodeDetailsErrorIdExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504,\"msgContent\":" +
"\"{\\\"id\\\":[\\\"abd\\\"]}\"}";
@ -2675,6 +2737,78 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* I 6 get node details array contains null exception test.
*
* @throws Exception the exception
*/
@Test
public void i6_getNodeDetailsArrayContainsNullExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", null]}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/information/node_details")
.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());
}
/**
* I 7 get node details Array contains empty string exception test.
*
* @throws Exception the exception
*/
@Test
public void i7_getNodeDetailsArrayContainsEmptyStringExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/information/node_details")
.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();
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
Assert.assertNotNull(rspInfo);
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
Assert.assertNotNull(String.valueOf(v.getType()));
Assert.assertNotNull(v.getIp());
Assert.assertNotNull(v.getCapacity());
for (DisposeCapacity disposeCapacity : v.getCapacity()
) {
Assert.assertNotNull(disposeCapacity.getType());
Assert.assertNotNull(disposeCapacity.getDisposeIp());
}
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
});
}
/**
* Verify device id exists boolean.