REM:
1. 获取节点信息接口单测
This commit is contained in:
wangyiyun 2020-06-12 18:58:50 +08:00
parent c922aa6b39
commit 7b3bf739aa
1 changed files with 323 additions and 0 deletions

View File

@ -409,6 +409,113 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* A 11 get version Array contains character test.
*
* @throws Exception the exception
*/
@Test
public void a11_getVersionArrayContainsCharacterTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"12*a \\\"]}\"}";
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());
}
}
}
/**
* A 12 get version Array sort test.
*
* @throws Exception the exception
*/
@Test
public void a12_getVersionArraySortTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"2\\\", \\\"3\\\", \\\"1\\\"]}\"}";
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());
}
}
}
/**
* A 13 get version id json exception test.
*
* @throws Exception the exception
*/
@Test
public void a13_getVersionIdJsonExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":}\"}";
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_PARAMEXCEPTION.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
VersionRsp versionRsp = objectMapper.readValue(verifyResp(ver), new TypeReference<VersionRsp>() {});
Assert.assertEquals(String.valueOf(versionRsp.getStatus()),String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
}
/**
* B 1 get device info normal one exist device test.
*
@ -735,6 +842,109 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* B 11 get device info Array contains character test.
*
* @throws Exception the exception
*/
@Test
public void b11_getDeviceInfoArrayContainsCharacterTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"12*a \\\"]}\"}";
String ver = 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(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
DeviceInfoRsp deviceInfoRsp = objectMapper.readValue(verifyResp(ver), 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());
}
}
}
/**
* B 12 get device info Array sort test.
*
* @throws Exception the exception
*/
@Test
public void b12_getDeviceInfoArraySortTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"2\\\", \\\"3\\\", \\\"1\\\"]}\"}";
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(ErrorCode.ERR_OK.getHttpCode()))
.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());
}
}
}
/**
* B 13 get device info id json exception test.
*
* @throws Exception the exception
*/
@Test
public void b13_getDeviceInfoIdJsonExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":}\"}";
String ver = 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(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
DeviceInfoData deviceInfoData = objectMapper.readValue(verifyResp(ver), new TypeReference<DeviceInfoData>() {});
Assert.assertEquals(String.valueOf(deviceInfoData.getStatus()),String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(deviceInfoData.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
}
/**
* C 1 get link status normal one online device test.
*
@ -1081,6 +1291,119 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
}
}
/**
* C 11 get link status Array contains character test.
*
* @throws Exception the exception
*/
@Test
public void c11_getLinkStatusArrayContainsCharacterTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"12*a \\\"]}\"}";
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 if (linkStatusRsp.getStatus() == 19){
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());
}
}
}
/**
* C 12 get link status Array sort test.
*
* @throws Exception the exception
*/
@Test
public void c12_getLinkStatusArraySortTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":[\\\"2\\\", \\\"3\\\", \\\"1\\\"]}\"}";
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 if (linkStatusRsp.getStatus() == 19){
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());
}
}
}
/**
* C 13 get link status id json exception test.
*
* @throws Exception the exception
*/
@Test
public void c13_getLinkStatusIdJsonExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040," +
"\"msgContent\":\"{\\\"id\\\":}\"}";
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_PARAMEXCEPTION.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
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());
}
/**
* d1 get one node capacity .
*/