OCT
REM: 1. 添加DeviceNodeInfoController QA测试用例中获取能力节点接口正常用例和异常用例测试代码
This commit is contained in:
parent
c0175a1692
commit
96cafb847d
|
@ -17,12 +17,7 @@ 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.LinkStatusListRsp;
|
||||
import com.dispose.pojo.vo.information.LinkStatusRsp;
|
||||
import com.dispose.pojo.vo.information.VersionListRsp;
|
||||
import com.dispose.pojo.vo.information.VersionRsp;
|
||||
import com.dispose.pojo.vo.information.*;
|
||||
import com.dispose.service.DisposeNodeManager;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
@ -753,6 +748,266 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{
|
|||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* d1 get one node capacity .
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void d1_NormalGetOneNodeCapacityTest() throws Exception{
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\"]}\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
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.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
}else{
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
}
|
||||
|
||||
if(v.getCapacity() != null){
|
||||
v.getCapacity().forEach(k->{
|
||||
Assert.assertNotNull(k.getType());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* d2 get multiple node capabilities .
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void d2_NormalGetMultipleNodeCapacityTest() throws Exception{
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"1\\\", \\\"2\\\"]}\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
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.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
}else{
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
}
|
||||
|
||||
if(v.getCapacity() != null){
|
||||
v.getCapacity().forEach(k->{
|
||||
Assert.assertNotNull(k.getType());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* d3 Get a node capability that does not exist .
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void d3_NormalGetCapacityNodeNotExistTest() throws Exception{
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"{\\\"id\\\":[\\\"2\\\"]}\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
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.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
}else{
|
||||
Assert.assertEquals(String.valueOf(v.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
}
|
||||
|
||||
if(v.getCapacity() != null){
|
||||
v.getCapacity().forEach(k->{
|
||||
Assert.assertNotNull(k.getType());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* d4 msgContent empty .
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d4_GetCapacityEmptyMsgExistExceptionTest() throws Exception{
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* d5 msgContent null .
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d5_GetCapacityNullMsgExistExceptionTest() throws Exception{
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":null}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* d6 id null .
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d6_GetCapacityEmptyMsgExistExceptionTest() throws Exception{
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"{\\\"id\\\":null}\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* d7 id "abc" .
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d7_GetCapacityErrIdExistExceptionTest() throws Exception{
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"{\\\"id\\\":\\\"abc\\\"}\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* d8 id Integer .
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d8_GetCapacityIntegerIdExistExceptionTest() throws Exception{
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," +
|
||||
"\"msgContent\":\"{\\\"id\\\":1}\"}";
|
||||
|
||||
String capacity = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/capacity")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(521))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(returnStatus.getStatus());
|
||||
Assert.assertNotNull(returnStatus.getMessage());
|
||||
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
/**
|
||||
* Verify device id exists boolean.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue