OCT
REM: 1. 增加数组中存在元素为null的测试用例 2. 增加数组中存在元素为空字符串的测试用例 3. 修改断言
This commit is contained in:
parent
0ede48d647
commit
919c1c42a2
|
@ -306,6 +306,69 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A 8 get version array contains null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a8_getVersionArrayContainsNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", null]}\"}";
|
||||
|
||||
String ver = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/version")
|
||||
.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(ver), 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* A 9 get version Array contains empty string exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a9_getVersionArrayContainsEmptyStringExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
|
||||
|
||||
String ver = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/version")
|
||||
.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();
|
||||
|
||||
VersionListRsp versionListRsp = objectMapper.readValue(verifyResp(ver), VersionListRsp.class);
|
||||
List<VersionRsp> verList = versionListRsp.getItems();
|
||||
|
||||
for (VersionRsp versionRsp : verList
|
||||
) {
|
||||
Assert.assertNotNull(versionRsp.getId());
|
||||
Assert.assertNotNull(versionRsp.getVersion());
|
||||
Assert.assertEquals(Long.valueOf(versionRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* B 1 get device info normal one exist device test.
|
||||
*
|
||||
|
@ -532,6 +595,67 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* B 8 get device info array contains null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void b8_getDeviceInfoArrayContainsNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", null]}\"}";
|
||||
|
||||
String deviceInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/deviceinfo")
|
||||
.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(deviceInfo), 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* b 9 get device info Array contains empty string exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void b9_getDeviceInfoArrayContainsEmptyStringExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
|
||||
|
||||
String deviceInfo = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/deviceinfo")
|
||||
.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();
|
||||
|
||||
DeviceInfoRsp deviceInfoRsp = objectMapper.readValue(verifyResp(deviceInfo), DeviceInfoRsp.class);
|
||||
List<DeviceInfoData> verList = deviceInfoRsp.getItems();
|
||||
|
||||
for (DeviceInfoData deviceInfoData : verList
|
||||
) {
|
||||
Assert.assertNotNull(deviceInfoData.getId());
|
||||
Assert.assertEquals(String.valueOf(deviceInfoData.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(deviceInfoData.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* C 1 get link status normal one online device test.
|
||||
*
|
||||
|
@ -772,6 +896,71 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* C 8 get link status array contains null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void c8_getLinkStatusArrayContainsNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", null]}\"}";
|
||||
|
||||
String linkstatus = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/linkstatus")
|
||||
.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(linkstatus), 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* C 9 get link status Array contains empty string exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void c9_getLinkStatusArrayContainsEmptyStringExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
|
||||
|
||||
String linkstatus = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/linkstatus")
|
||||
.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();
|
||||
|
||||
LinkStatusListRsp linkStatusListRsp = objectMapper.readValue(verifyResp(linkstatus), LinkStatusListRsp.class);
|
||||
List<LinkStatusRsp> linkStatusRspList = linkStatusListRsp.getItems();
|
||||
|
||||
for (LinkStatusRsp linkStatusRsp : linkStatusRspList
|
||||
) {
|
||||
Assert.assertNotNull(linkStatusRsp.getId());
|
||||
Assert.assertNotNull(String.valueOf(linkStatusRsp.getOnline()));
|
||||
Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "1");
|
||||
Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(linkStatusRsp.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* d1 get one node capacity .
|
||||
*/
|
||||
|
@ -799,8 +988,10 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
if (v.getStatus() == 0) {
|
||||
Assert.assertNotNull(v.getId());
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
} else {
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
|
||||
if (v.getCapacity() != null) {
|
||||
|
@ -837,8 +1028,10 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
if (v.getStatus() == 0) {
|
||||
Assert.assertNotNull(v.getId());
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
} else {
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
|
||||
if (v.getCapacity() != null) {
|
||||
|
@ -875,8 +1068,10 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
if (v.getStatus() == 0) {
|
||||
Assert.assertNotNull(v.getId());
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
} else {
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
|
||||
if (v.getCapacity() != null) {
|
||||
|
@ -887,7 +1082,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
|
||||
|
||||
/**
|
||||
* d4 msgContent empty .
|
||||
* d4 get capacity msgContent empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -912,10 +1107,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());
|
||||
}
|
||||
|
||||
/**
|
||||
* d5 msgContent null .
|
||||
* d5 get capacity msgContent null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -940,10 +1136,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());
|
||||
}
|
||||
|
||||
/**
|
||||
* d6 id null .
|
||||
* d6 get capacity id null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -968,10 +1165,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());
|
||||
}
|
||||
|
||||
/**
|
||||
* d7 id "abc" .
|
||||
* d7 get capacity id "abc" exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -1008,7 +1206,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
|
||||
|
||||
/**
|
||||
* d8 id Integer .
|
||||
* d8 get capacity id Integer exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -1033,10 +1231,72 @@ 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* e1 get a node protection IP that exists.
|
||||
* D 9 get capacity array contains null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d9_getGetCapacityArrayContainsNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", null]}\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.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(capacity), 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* D 10 get capacity Array contains empty string exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d10_GetCapacityArrayContainsEmptyStringExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.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();
|
||||
|
||||
DeviceCapacityRsp deviceCapacityRsp = objectMapper.readValue(verifyResp(capacity), DeviceCapacityRsp.class);
|
||||
List<DeviceCapacityData> deviceCapacityDataList = deviceCapacityRsp.getItems();
|
||||
|
||||
for (DeviceCapacityData deviceCapacityData : deviceCapacityDataList
|
||||
) {
|
||||
Assert.assertNotNull(deviceCapacityData.getId());
|
||||
Assert.assertEquals(String.valueOf(deviceCapacityData.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(deviceCapacityData.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* e1 get protection IP a node protection IP that exists exception test.
|
||||
*/
|
||||
@Test
|
||||
public void e1_NormalGetOneNodeProtectionIpTest() throws Exception {
|
||||
|
@ -1049,7 +1309,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -1062,8 +1322,10 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
if (v.getStatus() == 0) {
|
||||
Assert.assertNotNull(v.getId());
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
} else {
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
|
||||
if (v.getCapacity() != null) {
|
||||
|
@ -1089,7 +1351,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -1102,8 +1364,10 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
if (v.getStatus() == 0) {
|
||||
Assert.assertNotNull(v.getId());
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
} else {
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
|
||||
if (v.getCapacity() != null) {
|
||||
|
@ -1130,7 +1394,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
@ -1143,8 +1407,10 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
if (v.getStatus() == 0) {
|
||||
Assert.assertNotNull(v.getId());
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
} else {
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
|
||||
if (v.getCapacity() != null) {
|
||||
|
@ -1157,7 +1423,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
/**
|
||||
* e4 msgContent empty .
|
||||
* e4 get protection IP msgContent empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -1166,27 +1432,28 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
String protectedIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(protectedIp), ReturnStatus.class);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* e5 msgContent null .
|
||||
* e5 get protection IP msgContent null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -1195,26 +1462,27 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":null}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
String protectedIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(protectedIp), ReturnStatus.class);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* e6 id empty .
|
||||
* e6 get protection IP id empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -1223,26 +1491,27 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"{\\\"id\\\":null}\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
String protectedIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(protectedIp), ReturnStatus.class);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* e7 id "abd" .
|
||||
* e7 get protection IP id "abd" exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -1251,27 +1520,28 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"{\\\"id\\\":\\\"abd\\\"}\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
String protectedIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(protectedIp), ReturnStatus.class);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* e8 id Integer .
|
||||
* e8 get protection IP id Integer exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -1280,22 +1550,91 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
|||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"{\\\"id\\\":1}\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
String protectedIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(protectedIp), ReturnStatus.class);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* e9 get protection IP array contains null exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d9_GetIpArrayContainsNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", null]}\"}";
|
||||
|
||||
String protectedIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.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(protectedIp), 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* e10 get protection IP Array contains empty string exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d10_getGetCapacityArrayContainsEmptyStringExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
|
||||
|
||||
String protectedIp = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/protected_ip")
|
||||
.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();
|
||||
|
||||
DeviceCapacityRsp deviceCapacityRsp = objectMapper.readValue(verifyResp(protectedIp), DeviceCapacityRsp.class);
|
||||
deviceCapacityRsp.getItems().forEach(v -> {
|
||||
Assert.assertNotNull(v.getId());
|
||||
Assert.assertNotNull(v.getStatus());
|
||||
Assert.assertNotNull(v.getMessage());
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
|
||||
if (v.getCapacity() != null) {
|
||||
v.getCapacity().forEach(k -> {
|
||||
Assert.assertNotNull(k.getType());
|
||||
Assert.assertNotNull(k.getDisposeIp());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue