diff --git a/src/test/java/com/dispose/controller/DeviceNodeInfoControllerQATest.java b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerQATest.java index cbca8a29..f5d90a9d 100644 --- a/src/test/java/com/dispose/controller/DeviceNodeInfoControllerQATest.java +++ b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerQATest.java @@ -16,6 +16,7 @@ package com.dispose.controller; import com.dispose.Global.InitTestEnvironment; import com.dispose.common.ErrorCode; import com.dispose.pojo.entity.DisposeDevice; +import com.dispose.pojo.po.ReturnStatus; import com.dispose.pojo.vo.information.DeviceInfoData; import com.dispose.pojo.vo.information.DeviceInfoRsp; import com.dispose.pojo.vo.information.LinkStatusRsp; @@ -95,17 +96,19 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ String msgContent = verifyResp(ver); List verList = objectMapper.readValue(msgContent, new TypeReference>() { }); - Assert.assertEquals(1, verList.size()); + Assert.assertEquals(verList.size(), 1); for (VersionRsp versionRsp : verList ) { if (verifyDeviceIdExists(versionRsp.getId())) { - Assert.assertEquals(String.valueOf(versionRsp.getStatus()), "0"); - Assert.assertEquals(versionRsp.getMessage(), "成功"); + Assert.assertEquals(String.valueOf(versionRsp.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode())); + Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_OK.getMsg()); Assert.assertNotNull(versionRsp.getId()); Assert.assertNotNull(versionRsp.getVersion()); } else { - Assert.assertNotEquals(String.valueOf(versionRsp.getStatus()), "0"); - Assert.assertNotEquals(versionRsp.getMessage(), "成功"); + Assert.assertNotNull(versionRsp.getId()); + Assert.assertNull(versionRsp.getVersion()); + Assert.assertEquals(String.valueOf(versionRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); + Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg()); } } } @@ -134,16 +137,19 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ String msgContent = verifyResp(ver); List verList = objectMapper.readValue(msgContent, new TypeReference>() { }); + Assert.assertTrue(verList.size() > 1); for (VersionRsp versionRsp : verList ) { if (verifyDeviceIdExists(versionRsp.getId())) { - Assert.assertEquals(String.valueOf(versionRsp.getStatus()), "0"); - Assert.assertEquals(versionRsp.getMessage(), "成功"); + Assert.assertEquals(String.valueOf(versionRsp.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode())); + Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_OK.getMsg()); Assert.assertNotNull(versionRsp.getId()); Assert.assertNotNull(versionRsp.getVersion()); } else { - Assert.assertNotEquals(String.valueOf(versionRsp.getStatus()), "0"); - Assert.assertNotEquals(versionRsp.getMessage(), "成功"); + Assert.assertNotNull(versionRsp.getId()); + Assert.assertNull(versionRsp.getVersion()); + Assert.assertEquals(String.valueOf(versionRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); + Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg()); } } } @@ -170,10 +176,13 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ String msgContent = verifyResp(ver); List verList = objectMapper.readValue(msgContent, new TypeReference>() { }); + Assert.assertEquals(verList.size(), 1); for (VersionRsp versionRsp : verList ) { - Assert.assertNotEquals(String.valueOf(versionRsp.getStatus()), "0"); - Assert.assertNotEquals(versionRsp.getMessage(), "成功"); + Assert.assertNotNull(versionRsp.getId()); + Assert.assertNull(versionRsp.getVersion()); + Assert.assertEquals(String.valueOf(versionRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); + Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg()); } } @@ -309,16 +318,17 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ String msgContent = verifyResp(deviceInfo); DeviceInfoRsp deviceInfoRsp = objectMapper.readValue(msgContent, DeviceInfoRsp.class); List deviceInfoList = deviceInfoRsp.getItems(); + Assert.assertEquals(deviceInfoList.size(), 1); for (DeviceInfoData d : deviceInfoList ) { if (verifyDeviceIdExists(d.getId())) { Assert.assertNotNull(d.getId()); - Assert.assertEquals(d.getStatus(), 0); - Assert.assertEquals(d.getMessage(), "成功"); + Assert.assertEquals(d.getStatus(), ErrorCode.ERR_OK.getCode()); + Assert.assertEquals(d.getMessage(), ErrorCode.ERR_OK.getMsg()); } else { Assert.assertNotNull(d.getId()); - Assert.assertNotEquals(d.getStatus(), 0); - Assert.assertNotEquals(d.getMessage(), "成功"); + Assert.assertNotEquals(d.getStatus(), ErrorCode.ERR_OK.getCode()); + Assert.assertNotEquals(d.getMessage(), ErrorCode.ERR_OK.getMsg()); } } } @@ -346,16 +356,17 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ String msgContent = verifyResp(deviceInfo); DeviceInfoRsp deviceInfoRsp = objectMapper.readValue(msgContent, DeviceInfoRsp.class); List deviceInfoList = deviceInfoRsp.getItems(); + Assert.assertTrue(deviceInfoList.size() > 1); for (DeviceInfoData d : deviceInfoList ) { if (verifyDeviceIdExists(d.getId())) { Assert.assertNotNull(d.getId()); - Assert.assertEquals(d.getStatus(), 0); - Assert.assertEquals(d.getMessage(), "成功"); + Assert.assertEquals(d.getStatus(), ErrorCode.ERR_OK.getCode()); + Assert.assertEquals(d.getMessage(), ErrorCode.ERR_OK.getMsg()); } else { Assert.assertNotNull(d.getId()); - Assert.assertNotEquals(d.getStatus(), 0); - Assert.assertNotEquals(d.getMessage(), "成功"); + Assert.assertEquals(d.getStatus(), ErrorCode.ERR_NOSUCHDEVICE.getCode()); + Assert.assertEquals(d.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg()); } } } @@ -383,17 +394,13 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ String msgContent = verifyResp(deviceInfo); DeviceInfoRsp deviceInfoRsp = objectMapper.readValue(msgContent, DeviceInfoRsp.class); List deviceInfoList = deviceInfoRsp.getItems(); + + Assert.assertEquals(deviceInfoList.size(), 1); for (DeviceInfoData d : deviceInfoList ) { - if (verifyDeviceIdExists(d.getId())) { - Assert.assertNotNull(d.getId()); - Assert.assertEquals(d.getStatus(), 0); - Assert.assertEquals(d.getMessage(), "成功"); - } else { - Assert.assertNotNull(d.getId()); - Assert.assertNotEquals(d.getStatus(), 0); - Assert.assertNotEquals(d.getMessage(), "成功"); - } + Assert.assertNotNull(d.getId()); + Assert.assertEquals(d.getStatus(), ErrorCode.ERR_NOSUCHDEVICE.getCode()); + Assert.assertEquals(d.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg()); } } @@ -416,9 +423,13 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ .getResponse() .getContentAsString(); - String msgContent = verifyResp(deviceInfo); - Assert.assertTrue(msgContent.contains(String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()))); - Assert.assertTrue(msgContent.contains(ErrorCode.ERR_PARAMEXCEPTION.getMsg())); + ReturnStatus rspInfo = objectMapper.readValue(verifyResp(deviceInfo), ReturnStatus.class) ; + + Assert.assertNotNull(rspInfo.getStatus()); + Assert.assertNotNull(rspInfo.getMessage()); + Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode())); + Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg()); + } /** @@ -440,9 +451,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ .getResponse() .getContentAsString(); - String msgContent = verifyResp(deviceInfo); - Assert.assertTrue(msgContent.contains(String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()))); - Assert.assertTrue(msgContent.contains(ErrorCode.ERR_PARAMEXCEPTION.getMsg())); + ReturnStatus rspInfo = objectMapper.readValue(verifyResp(deviceInfo), ReturnStatus.class) ; + + Assert.assertNotNull(rspInfo.getStatus()); + Assert.assertNotNull(rspInfo.getMessage()); + Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode())); + Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg()); } /** @@ -464,9 +478,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ .getResponse() .getContentAsString(); - String msgContent = verifyResp(deviceInfo); - Assert.assertTrue(msgContent.contains(String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()))); - Assert.assertTrue(msgContent.contains(ErrorCode.ERR_PARAMEXCEPTION.getMsg())); + ReturnStatus rspInfo = objectMapper.readValue(verifyResp(deviceInfo), ReturnStatus.class) ; + + Assert.assertNotNull(rspInfo.getStatus()); + Assert.assertNotNull(rspInfo.getMessage()); + Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode())); + Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg()); } /** @@ -489,9 +506,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ .getResponse() .getContentAsString(); - String msgContent = verifyResp(deviceInfo); - Assert.assertTrue(msgContent.contains(String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()))); - Assert.assertTrue(msgContent.contains(ErrorCode.ERR_PARAMEXCEPTION.getMsg())); + ReturnStatus rspInfo = objectMapper.readValue(verifyResp(deviceInfo), ReturnStatus.class) ; + + Assert.assertNotNull(rspInfo.getStatus()); + Assert.assertNotNull(rspInfo.getMessage()); + Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode())); + Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg()); } /** @@ -519,17 +539,18 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ List linkStatusList = objectMapper.readValue(msgContent, new TypeReference>() { }); + Assert.assertEquals(linkStatusList.size(), 1); for (LinkStatusRsp linkStatusRsp : linkStatusList ) { if (verifyDeviceIdExists(linkStatusRsp.getId())) { - Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), "0"); - Assert.assertEquals(linkStatusRsp.getMessage(), "成功"); + Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode())); + Assert.assertEquals(linkStatusRsp.getMessage(), ErrorCode.ERR_OK.getMsg()); Assert.assertNotNull(linkStatusRsp.getId()); Assert.assertNotNull(String.valueOf(linkStatusRsp.getOnline())); Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "1"); } else { - Assert.assertNotEquals(String.valueOf(linkStatusRsp.getStatus()), "0"); - Assert.assertNotEquals(linkStatusRsp.getMessage(), "成功"); + Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); + Assert.assertEquals(linkStatusRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg()); Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "0"); } } @@ -563,14 +584,14 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ for (LinkStatusRsp linkStatusRsp : linkStatusList ) { if (verifyDeviceIdExists(linkStatusRsp.getId())) { - Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), "0"); - Assert.assertEquals(linkStatusRsp.getMessage(), "成功"); + Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode())); + Assert.assertEquals(linkStatusRsp.getMessage(), ErrorCode.ERR_OK.getMsg()); Assert.assertNotNull(linkStatusRsp.getId()); Assert.assertNotNull(String.valueOf(linkStatusRsp.getOnline())); Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "1"); } else { - Assert.assertNotEquals(String.valueOf(linkStatusRsp.getStatus()), "0"); - Assert.assertNotEquals(linkStatusRsp.getMessage(), "成功"); + Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode())); + Assert.assertEquals(linkStatusRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg()); Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "0"); } } @@ -601,19 +622,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ List linkStatusList = objectMapper.readValue(msgContent, new TypeReference>() { }); + Assert.assertEquals(linkStatusList.size(), 1); for (LinkStatusRsp linkStatusRsp : linkStatusList ) { - if (verifyDeviceIdExists(linkStatusRsp.getId())) { - Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), "0"); - Assert.assertEquals(linkStatusRsp.getMessage(), "成功"); - Assert.assertNotNull(linkStatusRsp.getId()); - Assert.assertNotNull(String.valueOf(linkStatusRsp.getOnline())); - Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "1"); - } else { - Assert.assertNotEquals(String.valueOf(linkStatusRsp.getStatus()), "0"); - Assert.assertNotEquals(linkStatusRsp.getMessage(), "成功"); - 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()); + Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "0"); } } @@ -636,9 +650,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ .getResponse() .getContentAsString(); - String msgContent = verifyResp(linkstatus); - Assert.assertTrue(msgContent.contains(String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()))); - Assert.assertTrue(msgContent.contains(ErrorCode.ERR_PARAMEXCEPTION.getMsg())); + ReturnStatus rspInfo = objectMapper.readValue(verifyResp(linkstatus), ReturnStatus.class) ; + + Assert.assertNotNull(rspInfo.getStatus()); + Assert.assertNotNull(rspInfo.getMessage()); + Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode())); + Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg()); } /** @@ -660,9 +677,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ .getResponse() .getContentAsString(); - String msgContent = verifyResp(linkstatus); - Assert.assertTrue(msgContent.contains(String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()))); - Assert.assertTrue(msgContent.contains(ErrorCode.ERR_PARAMEXCEPTION.getMsg())); + ReturnStatus rspInfo = objectMapper.readValue(verifyResp(linkstatus), ReturnStatus.class) ; + + Assert.assertNotNull(rspInfo.getStatus()); + Assert.assertNotNull(rspInfo.getMessage()); + Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode())); + Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg()); } /** @@ -684,9 +704,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ .getResponse() .getContentAsString(); - String msgContent = verifyResp(linkstatus); - Assert.assertTrue(msgContent.contains(String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()))); - Assert.assertTrue(msgContent.contains(ErrorCode.ERR_PARAMEXCEPTION.getMsg())); + ReturnStatus rspInfo = objectMapper.readValue(verifyResp(linkstatus), ReturnStatus.class) ; + + Assert.assertNotNull(rspInfo.getStatus()); + Assert.assertNotNull(rspInfo.getMessage()); + Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode())); + Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg()); } /** @@ -709,9 +732,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{ .getResponse() .getContentAsString(); - String msgContent = verifyResp(linkstatus); - Assert.assertTrue(msgContent.contains(String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()))); - Assert.assertTrue(msgContent.contains(ErrorCode.ERR_PARAMEXCEPTION.getMsg())); + ReturnStatus rspInfo = objectMapper.readValue(verifyResp(linkstatus), ReturnStatus.class) ; + + Assert.assertNotNull(rspInfo.getStatus()); + Assert.assertNotNull(rspInfo.getMessage()); + Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode())); + Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg()); } /**