REM:
1.增加获取能力节点信息相关接口中入参数组重复的测试用例,结果去重
This commit is contained in:
chenlinghy 2020-06-10 16:57:37 +08:00
parent 9b52449359
commit db6ae0f3be
1 changed files with 429 additions and 56 deletions

View File

@ -336,12 +336,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
/**
* A 9 get version Array contains empty string exception test.
* A 9 get version Array contains empty string test.
*
* @throws Exception the exception
*/
@Test
public void a9_getVersionArrayContainsEmptyStringExceptionTest() throws Exception {
public void a9_getVersionArrayContainsEmptyStringTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
@ -368,6 +368,46 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* A 10 get version Array contains repeated elements test. 去重
*
* @throws Exception the exception
*/
@Test
public void a10_getVersionArrayContainsRepeatedElementsTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"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.getStatus());
Assert.assertNotNull(versionRsp.getMessage());
if (versionRsp.getStatus() == 0) {
Assert.assertNotNull(versionRsp.getVersion());
Assert.assertEquals(Long.valueOf(versionRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_OK.getMsg());
} else if (versionRsp.getStatus() == 19) {
Assert.assertEquals(Long.valueOf(versionRsp.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
}
}
}
/**
* B 1 get device info normal one exist device test.
@ -503,7 +543,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(rspInfo.getMessage());
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
}
/**
@ -625,12 +664,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
/**
* b 9 get device info Array contains empty string exception test.
* b 9 get device info Array contains empty string test.
*
* @throws Exception the exception
*/
@Test
public void b9_getDeviceInfoArrayContainsEmptyStringExceptionTest() throws Exception {
public void b9_getDeviceInfoArrayContainsEmptyStringTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
@ -656,6 +695,46 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* B 10 get device info Array contains repeated elements exception test.
*
* @throws Exception the exception
*/
@Test
public void b10_getDeviceInfoArrayContainsRepeatedElementsTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\",\\\"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(200))
.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.assertNotNull(String.valueOf(deviceInfoData.getStatus()));
Assert.assertNotNull(deviceInfoData.getMessage());
if (deviceInfoData.getStatus() == 0) {
Assert.assertEquals(String.valueOf(deviceInfoData.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(deviceInfoData.getMessage(), ErrorCode.ERR_OK.getMsg());
} else {
Assert.assertEquals(String.valueOf(deviceInfoData.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
Assert.assertEquals(deviceInfoData.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
}
}
}
/**
* C 1 get link status normal one online device test.
*
@ -896,7 +975,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* C 8 get link status array contains null exception test.
*
@ -927,12 +1005,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
/**
* C 9 get link status Array contains empty string exception test.
* C 9 get link status Array contains empty string test.
*
* @throws Exception the exception
*/
@Test
public void c9_getLinkStatusArrayContainsEmptyStringExceptionTest() throws Exception {
public void c9_getLinkStatusArrayContainsEmptyStringTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
@ -960,6 +1038,48 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* C 10 get link status Array contains repeated elements test.
*
* @throws Exception the exception
*/
@Test
public void c10_getLinkStatusArrayContainsRepeatedElementsTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\",\\\"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.assertNotNull(linkStatusRsp.getStatus());
Assert.assertNotNull(linkStatusRsp.getMessage());
if (linkStatusRsp.getStatus() == 0) {
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());
} else {
Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "0");
Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
Assert.assertEquals(linkStatusRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
}
}
}
/**
* d1 get one node capacity .
@ -982,11 +1102,11 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
DeviceCapacityRsp deviceCapacityRsp = objectMapper.readValue(verifyResp(capacity), DeviceCapacityRsp.class);
deviceCapacityRsp.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
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 {
@ -1000,7 +1120,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* d2 get multiple node capabilities .
*/
@ -1022,11 +1141,11 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
DeviceCapacityRsp deviceCapacityRsp = objectMapper.readValue(verifyResp(capacity), DeviceCapacityRsp.class);
deviceCapacityRsp.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
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 {
@ -1040,7 +1159,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* d3 Get a node capability that does not exist .
*/
@ -1062,11 +1180,11 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
DeviceCapacityRsp deviceCapacityRsp = objectMapper.readValue(verifyResp(capacity), DeviceCapacityRsp.class);
deviceCapacityRsp.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
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 {
@ -1080,7 +1198,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* d4 get capacity msgContent empty exception test.
*
@ -1204,7 +1321,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* d8 get capacity id Integer exception test.
*
@ -1264,12 +1380,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
/**
* D 10 get capacity Array contains empty string exception test.
* D 10 get capacity Array contains empty string test.
*
* @throws Exception the exception
*/
@Test
public void d10_getCapacityArrayContainsEmptyStringExceptionTest() throws Exception {
public void d10_getCapacityArrayContainsEmptyStringTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
@ -1295,6 +1411,45 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* D 11 get capacity Array contains repeated elements test.
*/
@Test
public void d11_GetMultipleNodeArrayContainsRepeatedElementsTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"1\\\", \\\"2\\\"]}\"}";
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);
deviceCapacityRsp.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
if (v.getStatus() == 0) {
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) {
v.getCapacity().forEach(k -> Assert.assertNotNull(k.getType()));
}
});
}
/**
* e1 get protection IP a node protection IP that exists exception test.
*/
@ -1316,11 +1471,11 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
DeviceCapacityRsp deviceCapacityRsp = objectMapper.readValue(verifyResp(protectedIp), DeviceCapacityRsp.class);
deviceCapacityRsp.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
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 {
@ -1358,11 +1513,11 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
DeviceCapacityRsp deviceCapacityRsp = objectMapper.readValue(verifyResp(protectedIp), DeviceCapacityRsp.class);
deviceCapacityRsp.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
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 {
@ -1379,7 +1534,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* e3 get a node protection IP that does not exist .
*/
@ -1401,11 +1555,11 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
DeviceCapacityRsp deviceCapacityRsp = objectMapper.readValue(verifyResp(protectedIp), DeviceCapacityRsp.class);
deviceCapacityRsp.getItems().forEach(v -> {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
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 {
@ -1451,7 +1605,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
}
/**
* e5 get protection IP msgContent null exception test.
*
@ -1539,7 +1692,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
}
/**
* e8 get protection IP id Integer exception test.
*
@ -1569,7 +1721,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
}
/**
* e9 get protection IP array contains null exception test.
*
@ -1600,12 +1751,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
/**
* e10 get protection IP Array contains empty string exception test.
* e10 get protection IP Array contains empty string test.
*
* @throws Exception the exception
*/
@Test
public void e10_getCapacityArrayContainsEmptyStringExceptionTest() throws Exception {
public void e10_getCapacityArrayContainsEmptyStringTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
@ -1637,6 +1788,48 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* e11 e10 get protection IP Array contains repeated elements test. 去重
*/
@Test
public void e11_getCapacityArrayContainsRepeatedElementsTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"1\\\", \\\"2\\\"]}\"}";
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());
if (v.getStatus() == 0) {
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) {
v.getCapacity().forEach(k -> {
Assert.assertNotNull(k.getType());
Assert.assertNotNull(k.getDisposeIp());
});
}
});
}
/**
* F 1 get multiple node run task normal test.
*
@ -1663,12 +1856,11 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(rspInfo);
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
if (v.getStatus() == 0) {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getTaskArray());
if (v.getStatus() == 0) {
Assert.assertNotNull(v.getTaskArray());
for (TaskInfoData taskInfoData : v.getTaskArray()
) {
Assert.assertNotNull(taskInfoData);
@ -1688,7 +1880,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* F 2 get Node does not exist run task normal test.
*
@ -1715,12 +1906,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(rspInfo);
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
if (v.getStatus() == 0) {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getTaskArray());
if (v.getStatus() == 0) {
Assert.assertNotNull(v.getTaskArray());
for (TaskInfoData taskInfoData : v.getTaskArray()
) {
Assert.assertNotNull(taskInfoData);
@ -1740,7 +1931,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* F 3 get running task msgContent empty exception test.
*
@ -1770,7 +1960,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
}
/**
* F 4 get running task msgContent null exception test.
*
@ -1892,12 +2081,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
/**
* F 8 get running task Array contains empty string exception test.
* F 8 get running task Array contains empty string test.
*
* @throws Exception the exception
*/
@Test
public void f8_getRunTaskArrayContainsEmptyStringExceptionTest() throws Exception {
public void f8_getRunTaskArrayContainsEmptyStringTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
@ -1942,6 +2131,57 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* F 9 get running task Array contains repeated elements test.
*
* @throws Exception the exception
*/
@Test
public void f9_getRunTaskArrayContainsEmptyStringExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"1\\\", \\\"123\\\"]}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/information/run_task")
.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 rspInfo = objectMapper.readValue(verifyResp(ret), NodeTaskRsp.class);
Assert.assertNotNull(rspInfo);
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(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);
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 {
Assert.assertNotEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
}
});
}
/**
* G 1 get multiple node all task normal test.
*
@ -1995,7 +2235,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* G 2 get node does not exits all task normal test.
*
@ -2057,7 +2296,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
}
/**
* G 4 get all msgContent null exception test.
*
@ -2116,7 +2354,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
}
/**
* G 6 get all task id "abd" exception test.
*
@ -2182,12 +2419,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
/**
* G 8 get all task Array contains empty string exception test.
* G 8 get all task Array contains empty string test.
*
* @throws Exception the exception
*/
@Test
public void g8_getAllTaskArrayContainsEmptyStringExceptionTest() throws Exception {
public void g8_getAllTaskArrayContainsEmptyStringTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
@ -2207,13 +2444,64 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(rspInfo);
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
if (v.getStatus() == 0) {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getTaskArray());
for (TaskInfoData taskInfoData : v.getTaskArray()
) {
Assert.assertNotNull(taskInfoData);
Assert.assertNotNull(taskInfoData.getTaskId());
Assert.assertNotNull(taskInfoData.getCurrentStatus());
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 {
Assert.assertNotEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotEquals(v.getMessage(), ErrorCode.ERR_OK.getMsg());
}
});
}
/**
* G 9 get all task Array contains repeated elements test.
*
* @throws Exception the exception
*/
@Test
public void g9_getAllTaskArrayContainsRepeatedElementsTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"1\\\", \\\"123\\\"]}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/information/all_task")
.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 rspInfo = objectMapper.readValue(verifyResp(ret), NodeTaskRsp.class);
Assert.assertNotNull(rspInfo);
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(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);
@ -2271,7 +2559,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* H 2 get multiple node list normal test. "abd"
*
@ -2298,11 +2585,11 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(rspInfo);
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
if (v.getStatus() == 0) {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(String.valueOf(v.getType()));
Assert.assertNotNull(v.getName());
Assert.assertNotNull(v.getIp());
@ -2315,7 +2602,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* H 3 get node does not exits list normal test. "abd"
*
@ -2342,11 +2628,11 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertNotNull(rspInfo);
rspInfo.getItems().forEach(v -> {
Assert.assertNotNull(v);
Assert.assertNotNull(v.getId());
Assert.assertNotNull(v.getStatus());
Assert.assertNotNull(v.getMessage());
if (v.getStatus() == 0) {
Assert.assertNotNull(v.getId());
Assert.assertNotNull(String.valueOf(v.getType()));
Assert.assertNotNull(v.getName());
Assert.assertNotNull(v.getIp());
@ -2388,7 +2674,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertEquals(returnStatus.getMessage(), ErrorCode.ERR_PARAMS.getMsg());
}
/**
* H 5 get node list msgContent null exception test.
*
@ -2479,7 +2764,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* H 8 get node list array contains null exception test.
*
@ -2510,12 +2794,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
/**
* H 9 get node list Array contains empty string exception test.
* H 9 get node list Array contains empty string test.
*
* @throws Exception the exception
*/
@Test
public void h9_getNodeListArrayContainsEmptyStringExceptionTest() throws Exception {
public void h9_getNodeListArrayContainsEmptyStringTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
@ -2546,6 +2830,48 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* H 10 get node list Array contains repeated elements test.
*
* @throws Exception the exception
*/
@Test
public void h9_getNodeListArrayContainsRepeatedElementsTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"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(v.getStatus());
Assert.assertNotNull(v.getMessage());
if (v.getStatus() == 0) {
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());
}
});
}
/**
* I 1 get multiple Node Details Normal Test.
@ -2645,7 +2971,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* I 3 get Node does not exist Details Normal Test.
*
@ -2703,7 +3028,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
}
/**
* I 5 get node details id "abd" exception test.
*
@ -2767,12 +3091,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
/**
* I 7 get node details Array contains empty string exception test.
* I 7 get node details Array contains empty string test.
*
* @throws Exception the exception
*/
@Test
public void i7_getNodeDetailsArrayContainsEmptyStringExceptionTest() throws Exception {
public void i7_getNodeDetailsArrayContainsEmptyStringTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"123\\\", \\\"\\\"]}\"}";
@ -2810,6 +3134,55 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
});
}
/**
* I 8 get node details Array contains repeated elements test.
*
* @throws Exception the exception
*/
@Test
public void i8_getNodeDetailsArrayContainsRepeatedElementsTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504,\"msgContent\":" +
"\"{\\\"id\\\":[\\\"1\\\", \\\"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());
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());
}
});
}
/**
* Verify device id exists boolean.
*