OCT REM:[修改DeviceNodeInfoControllerQATest类:1、修改获取处置设备版本接口测试断言方式 2、修改获取处置设备信息接口测试断言方式 3、修改链路链接状态接口i测试断言方式]

This commit is contained in:
李淑贤 2020-05-09 16:00:42 +08:00
parent 2d646afbe4
commit 6212c72887
1 changed files with 97 additions and 71 deletions

View File

@ -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<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
});
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<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
});
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<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
});
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<DeviceInfoData> 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<DeviceInfoData> 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<DeviceInfoData> 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<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
});
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<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
});
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());
}
/**