diff --git a/src/test/java/com/dispose/controller/DeviceNodeInfoControllerQATest.java b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerQATest.java index f30a30c6..5aa4c881 100644 --- a/src/test/java/com/dispose/controller/DeviceNodeInfoControllerQATest.java +++ b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerQATest.java @@ -771,10 +771,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())); } else { Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); @@ -808,10 +809,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())); } else { Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); @@ -845,10 +847,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())); } else { Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); @@ -1023,10 +1026,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())); } else { Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); @@ -1062,10 +1066,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())); } else { Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); @@ -1102,10 +1107,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())); } else { Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); @@ -1291,26 +1297,27 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment { for (NodeTaskData taskData : rspInfo.getItems() ) { Assert.assertNotNull(taskData); - Assert.assertNotNull(taskData.getId()); Assert.assertNotNull(taskData.getStatus()); Assert.assertNotNull(taskData.getMessage()); if (taskData.getStatus() == 0) { + Assert.assertNotNull(taskData.getId()); + Assert.assertNotNull(taskData.getTaskArray()); + + for (TaskInfoData taskInfoData : taskData.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(taskData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); } else { Assert.assertNotEquals(Long.valueOf(taskData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); } - - Assert.assertNotNull(taskData.getTaskArray()); - for (TaskInfoData taskInfoData : taskData.getTaskArray() - ) { - Assert.assertNotNull(taskInfoData); - Assert.assertNotNull(taskInfoData.getTaskId()); - Assert.assertNotNull(taskInfoData.getType()); - Assert.assertNotNull(taskInfoData.getStartTime()); - Assert.assertNotNull(taskInfoData.getDisposeTime()); - Assert.assertNotNull(taskInfoData.getDisposeIp()); - } } } } @@ -1345,26 +1352,27 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment { for (NodeTaskData taskData : rspInfo.getItems() ) { Assert.assertNotNull(taskData); - Assert.assertNotNull(taskData.getId()); Assert.assertNotNull(taskData.getStatus()); Assert.assertNotNull(taskData.getMessage()); if (taskData.getStatus() == 0) { + Assert.assertNotNull(taskData.getId()); + Assert.assertNotNull(taskData.getTaskArray()); + + for (TaskInfoData taskInfoData : taskData.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(taskData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); } else { Assert.assertNotEquals(Long.valueOf(taskData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); } - - Assert.assertNotNull(taskData.getTaskArray()); - for (TaskInfoData taskInfoData : taskData.getTaskArray() - ) { - Assert.assertNotNull(taskInfoData); - Assert.assertNotNull(taskInfoData.getTaskId()); - Assert.assertNotNull(taskInfoData.getType()); - Assert.assertNotNull(taskInfoData.getStartTime()); - Assert.assertNotNull(taskInfoData.getDisposeTime()); - Assert.assertNotNull(taskInfoData.getDisposeIp()); - } } } } @@ -1523,27 +1531,28 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment { for (NodeTaskData taskData : rspInfo.getItems() ) { Assert.assertNotNull(taskData); - Assert.assertNotNull(taskData.getId()); Assert.assertNotNull(taskData.getStatus()); Assert.assertNotNull(taskData.getMessage()); if (taskData.getStatus() == 0) { + Assert.assertNotNull(taskData.getId()); + Assert.assertNotNull(taskData.getTaskArray()); + + for (TaskInfoData taskInfoData : taskData.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(taskData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); } else { Assert.assertNotEquals(Long.valueOf(taskData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); } - - Assert.assertNotNull(taskData.getTaskArray()); - for (TaskInfoData taskInfoData : taskData.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()); - } } } } @@ -1778,6 +1787,9 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment { for (DisposeNodeData disposeNodeData : rspInfo.getItems() ) { Assert.assertNotNull(disposeNodeData); + Assert.assertNotNull(disposeNodeData.getStatus()); + Assert.assertNotNull(disposeNodeData.getMessage()); + if (disposeNodeData.getStatus() == 0) { Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); Assert.assertNotNull(disposeNodeData.getId()); @@ -1787,8 +1799,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment { } else { Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); } - Assert.assertNotNull(disposeNodeData.getStatus()); - Assert.assertNotNull(disposeNodeData.getMessage()); } } } @@ -1822,6 +1832,9 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment { for (DisposeNodeData disposeNodeData : rspInfo.getItems() ) { Assert.assertNotNull(disposeNodeData); + Assert.assertNotNull(disposeNodeData.getStatus()); + Assert.assertNotNull(disposeNodeData.getMessage()); + if (disposeNodeData.getStatus() == 0) { Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); Assert.assertNotNull(disposeNodeData.getId()); @@ -1831,8 +1844,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment { } else { Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); } - Assert.assertNotNull(disposeNodeData.getStatus()); - Assert.assertNotNull(disposeNodeData.getMessage()); } } } @@ -1865,6 +1876,9 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment { for (DisposeNodeData disposeNodeData : rspInfo.getItems() ) { Assert.assertNotNull(disposeNodeData); + Assert.assertNotNull(disposeNodeData.getStatus()); + Assert.assertNotNull(disposeNodeData.getMessage()); + if (disposeNodeData.getStatus() == 0) { Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); Assert.assertNotNull(disposeNodeData.getId()); @@ -1874,8 +1888,6 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment { } else { Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); } - Assert.assertNotNull(disposeNodeData.getStatus()); - Assert.assertNotNull(disposeNodeData.getMessage()); } } } diff --git a/src/test/java/com/dispose/controller/DeviceNodeInfoControllerTest.java b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerTest.java index 1da341b1..679666ff 100644 --- a/src/test/java/com/dispose/controller/DeviceNodeInfoControllerTest.java +++ b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerTest.java @@ -23,6 +23,7 @@ import com.dispose.pojo.vo.information.VersionListRsp; import com.dispose.pojo.vo.information.VersionRsp; import com.dispose.service.DisposeNodeManager; import com.dispose.service.UserAccountService; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Assert; import org.junit.FixMethodOrder; @@ -155,10 +156,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment { System.out.print("msgContent=" + msgContent); //将json字符串转为VersionRsp类 -// List verList = objectMapper.readValue(msgContent, new TypeReference>() { -// }); - VersionListRsp versionListRsp = objectMapper.readValue(msgContent, VersionListRsp.class); - List verList = versionListRsp.getItems(); + List verList = objectMapper.readValue(msgContent, new TypeReference>() { + }); + //VersionListRsp versionListRsp = objectMapper.readValue(msgContent, VersionListRsp.class); + //List verList = versionListRsp.getItems(); for (VersionRsp versionRsp : verList ) { @@ -206,10 +207,11 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment { String msgContent = verifyRep(verAll, reqTimeStamp); System.out.print("msgContent=" + msgContent); -// List verList = objectMapper.readValue(msgContent, new TypeReference>() { -// }); - VersionListRsp versionListRsp = objectMapper.readValue(msgContent, VersionListRsp.class); - List verList = versionListRsp.getItems(); + List verList = objectMapper.readValue(msgContent, new TypeReference>() { + }); + + //VersionListRsp versionListRsp = objectMapper.readValue(msgContent, VersionListRsp.class); + //List verList = versionListRsp.getItems(); for (VersionRsp versionRsp : verList ) {