REM:
1. 修改测试断言代码
This commit is contained in:
chenlinghy 2020-05-13 17:03:23 +08:00
parent 034a105164
commit a96306fc46
3 changed files with 86 additions and 167 deletions

View File

@ -2,6 +2,7 @@ package com.dispose.controller;
import com.dispose.Global.InitTestEnvironment;
import com.dispose.common.ConstValue;
import com.dispose.common.ErrorCode;
import com.dispose.mapper.DisposeDeviceMapper;
import com.dispose.pojo.dto.ProtocolReqDTO;
import com.dispose.pojo.entity.DisposeDevice;
@ -146,7 +147,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -163,13 +164,11 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
for (VersionRsp versionRsp : verList
) {
if (verifyDeviceIdExists(versionRsp.getId())) {
Assert.assertEquals(String.valueOf(versionRsp.getStatus()), "0");
Assert.assertEquals(versionRsp.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(versionRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(versionRsp.getId());
Assert.assertNotNull(versionRsp.getVersion());
} else {
Assert.assertNotEquals(String.valueOf(versionRsp.getStatus()), "0");
Assert.assertNotEquals(versionRsp.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(versionRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -199,7 +198,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -216,13 +215,11 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
for (VersionRsp versionRsp : verList
) {
if (verifyDeviceIdExists(versionRsp.getId())) {
Assert.assertEquals(String.valueOf(versionRsp.getStatus()), "0");
Assert.assertEquals(versionRsp.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(versionRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(versionRsp.getId());
Assert.assertNotNull(versionRsp.getVersion());
} else {
Assert.assertNotEquals(String.valueOf(versionRsp.getStatus()), "0");
Assert.assertNotEquals(versionRsp.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(versionRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -252,7 +249,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -268,12 +265,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
) {
if (verifyDeviceIdExists(d.getId())) {
Assert.assertNotNull(d.getId());
Assert.assertEquals(d.getStatus(), 0);
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(d.getStatus(), 0);
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -303,7 +298,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -319,12 +314,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
) {
if (verifyDeviceIdExists(d.getId())) {
Assert.assertNotNull(d.getId());
Assert.assertEquals(d.getStatus(), 0);
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(d.getStatus(), 0);
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -354,7 +347,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -370,8 +363,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
) {
if (verifyDeviceIdExists(d.getId())) {
Assert.assertNotNull(d.getId());
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
if (d.getCapacity().size() != 0) {
for (DisposeCapacity cap : d.getCapacity()
) {
@ -380,8 +372,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
}
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -411,7 +402,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -427,8 +418,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
) {
if (verifyDeviceIdExists(d.getId())) {
Assert.assertNotNull(d.getId());
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
if (d.getCapacity().size() != 0) {
for (DisposeCapacity cap : d.getCapacity()
) {
@ -437,8 +427,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
}
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -467,7 +456,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -484,8 +473,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
) {
if (verifyDeviceIdExists(d.getId())) {
Assert.assertNotNull(d.getId());
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
if (d.getCapacity().size() != 0) {
for (DisposeCapacity cap : d.getCapacity()
) {
@ -499,8 +487,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
}
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -529,7 +516,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -546,8 +533,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
) {
if (verifyDeviceIdExists(d.getId())) {
Assert.assertNotNull(d.getId());
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
if (d.getCapacity().size() != 0) {
for (DisposeCapacity cap : d.getCapacity()
) {
@ -561,8 +547,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
}
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -592,7 +577,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -609,16 +594,14 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
) {
if (verifyDeviceIdExists(d.getId())) {
Assert.assertNotNull(d.getId());
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(String.valueOf(d.getType()));
Assert.assertNotNull(d.getIp());
Assert.assertTrue(d.getIp().matches(regex));
Assert.assertNotNull(d.getName());
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -647,7 +630,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -664,16 +647,14 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
) {
if (verifyDeviceIdExists(d.getId())) {
Assert.assertNotNull(d.getId());
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(String.valueOf(d.getType()));
Assert.assertNotNull(d.getIp());
Assert.assertTrue(d.getIp().matches(regex));
Assert.assertNotNull(d.getName());
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -702,7 +683,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -719,8 +700,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
) {
if (verifyDeviceIdExists(d.getId())) {
Assert.assertNotNull(d.getId());
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(String.valueOf(d.getType()));
Assert.assertNotNull(d.getIp());
Assert.assertTrue(d.getIp().matches(regex));
@ -732,8 +712,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
}
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -762,7 +741,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -779,8 +758,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
) {
if (verifyDeviceIdExists(d.getId())) {
Assert.assertNotNull(d.getId());
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(String.valueOf(d.getType()));
Assert.assertNotNull(d.getIp());
Assert.assertTrue(d.getIp().matches(regex));
@ -792,8 +770,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
}
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -817,7 +794,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -833,14 +810,12 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
for (LinkStatusRsp linkStatusRsp : linkStatusList
) {
if (verifyDeviceIdExists(linkStatusRsp.getId())) {
Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), "0");
Assert.assertEquals(linkStatusRsp.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(linkStatusRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
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.assertNotEquals(Long.valueOf(linkStatusRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "0");
}
}
@ -866,7 +841,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -882,14 +857,12 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
for (LinkStatusRsp linkStatusRsp : linkStatusList
) {
if (verifyDeviceIdExists(linkStatusRsp.getId())) {
Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), "0");
Assert.assertEquals(linkStatusRsp.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(linkStatusRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
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.assertNotEquals(Long.valueOf(linkStatusRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "0");
}
}
@ -914,7 +887,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -932,11 +905,9 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
// no task
if (d.getTaskArray().size() == 0) {
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
Assert.assertNotNull(d.getTaskArray());
@ -950,8 +921,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
}
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -976,7 +946,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -994,11 +964,9 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
// no task
if (d.getTaskArray().size() == 0) {
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
Assert.assertNotNull(d.getTaskArray());
@ -1012,8 +980,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
}
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -1038,7 +1005,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -1056,11 +1023,9 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
// no task
if (d.getTaskArray().size() == 0) {
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
Assert.assertNotNull(d.getTaskArray());
@ -1075,8 +1040,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
}
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(d.getTaskArray());
}
}
@ -1102,7 +1066,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -1120,11 +1084,9 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
// no task
if (d.getTaskArray().size() == 0) {
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
Assert.assertNotNull(d.getTaskArray());
@ -1139,8 +1101,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
}
} else {
Assert.assertNotNull(d.getId());
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(d.getTaskArray());
}
}

View File

@ -3,6 +3,7 @@ package com.dispose.controller;
import com.dispose.Global.InitTestEnvironment;
import com.dispose.common.ConstValue;
import com.dispose.common.DisposeDeviceType;
import com.dispose.common.ErrorCode;
import com.dispose.pojo.dto.ProtocolReqDTO;
import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.pojo.po.MReturnType;
@ -136,7 +137,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -175,11 +176,9 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
Assert.assertNotNull(d.getIpAddr());
Assert.assertNotNull(d.getDevId());
if ((!before) && after) {
Assert.assertEquals(String.valueOf(d.getStatus()), "0");
Assert.assertEquals(d.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(String.valueOf(d.getStatus()), "0");
Assert.assertNotEquals(d.getIpAddr(), "成功");
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -211,7 +210,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -249,11 +248,9 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
Assert.assertNotNull(iDReturnStatus.getId());
if (before && (!after)) {
Assert.assertEquals(String.valueOf(iDReturnStatus.getStatus()), "0");
Assert.assertEquals(iDReturnStatus.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(iDReturnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(String.valueOf(iDReturnStatus.getStatus()), "0");
Assert.assertNotEquals(iDReturnStatus.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(iDReturnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -290,7 +287,5 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
.getContentAsString();
System.out.println(delAll);
}
}

View File

@ -140,7 +140,7 @@ public class TaskControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -158,11 +158,9 @@ public class TaskControllerTest extends InitTestEnvironment {
Assert.assertNotNull(startTaskRsp.getMessage());
if (startTaskRsp.getStatus() == 0) {
Assert.assertEquals(String.valueOf(startTaskRsp.getStatus()), "0");
Assert.assertEquals(startTaskRsp.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(String.valueOf(startTaskRsp.getStatus()), "0");
Assert.assertNotEquals(startTaskRsp.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
@ -190,12 +188,11 @@ public class TaskControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
String regex = "\\A(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z";
String msgContent = verifyRep(taskStop, reqTimeStamp);
System.out.print("msgContent=" + msgContent);
@ -211,23 +208,9 @@ public class TaskControllerTest extends InitTestEnvironment {
Assert.assertNotNull(task.getMessage());
if (task.getStatus() == 0) {
Assert.assertEquals(String.valueOf(task.getStatus()), "0");
Assert.assertEquals(task.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(String.valueOf(task.getStatus()), "0");
Assert.assertNotEquals(task.getMessage(), "成功");
}
if (task.getType() != null) {
Assert.assertNotEquals(String.valueOf(task.getType()), -1);
}
if (task.getDisposeIp() != null) {
Assert.assertTrue(task.getDisposeIp().matches(regex));
}
if (task.getDisposeTime() != null) {
Assert.assertNotEquals(String.valueOf(task.getDisposeTime()), -1);
Assert.assertNotEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -263,12 +246,11 @@ public class TaskControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
String regex = "\\A(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z";
String msgContent = verifyRep(taskStopByIp, reqTimeStamp);
System.out.print("msgContent=" + msgContent);
@ -284,23 +266,9 @@ public class TaskControllerTest extends InitTestEnvironment {
Assert.assertNotNull(task.getMessage());
if (task.getStatus() == 0) {
Assert.assertEquals(String.valueOf(task.getStatus()), "0");
Assert.assertEquals(task.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(String.valueOf(task.getStatus()), "0");
Assert.assertNotEquals(task.getMessage(), "成功");
}
if (task.getType() != null) {
Assert.assertNotEquals(String.valueOf(task.getType()), -1);
}
if (task.getDisposeIp() != null) {
Assert.assertTrue(task.getDisposeIp().matches(regex));
}
if (task.getDisposeTime() != null) {
Assert.assertNotEquals(String.valueOf(task.getDisposeTime()), -1);
Assert.assertNotEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
@ -332,7 +300,7 @@ public class TaskControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -391,7 +359,7 @@ public class TaskControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -444,12 +412,11 @@ public class TaskControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
String regex = "\\A(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z";
String msgContent = verifyRep(taskStopAll, reqTimeStamp);
System.out.print("msgContent=" + msgContent);
@ -498,7 +465,7 @@ public class TaskControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -517,11 +484,9 @@ public class TaskControllerTest extends InitTestEnvironment {
Assert.assertNotNull(taskNode.getStatus());
Assert.assertNotNull(taskNode.getMessage());
if (taskNode.getStatus() == 0) {
Assert.assertEquals(String.valueOf(taskNode.getStatus()), "0");
Assert.assertEquals(taskNode.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(String.valueOf(taskNode.getStatus()), "0");
Assert.assertNotEquals(taskNode.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
Assert.assertNotNull(taskNode.getTaskArray());
@ -574,7 +539,7 @@ public class TaskControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -593,11 +558,9 @@ public class TaskControllerTest extends InitTestEnvironment {
Assert.assertNotNull(taskNode.getStatus());
Assert.assertNotNull(taskNode.getMessage());
if (taskNode.getStatus() == 0) {
Assert.assertEquals(String.valueOf(taskNode.getStatus()), "0");
Assert.assertEquals(taskNode.getMessage(), "成功");
Assert.assertEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(String.valueOf(taskNode.getStatus()), "0");
Assert.assertNotEquals(taskNode.getMessage(), "成功");
Assert.assertNotEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
Assert.assertNotNull(taskNode.getTaskArray());
@ -648,7 +611,7 @@ public class TaskControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
@ -677,7 +640,7 @@ public class TaskControllerTest extends InitTestEnvironment {
.header("Authorization", "Bearer " + getLogToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();