REM:
添加获取能力节点详细信息p1级测试用例:msgContent为空
This commit is contained in:
lijinxing 2020-05-09 17:26:04 +08:00
parent 6d81a541d8
commit a266bc93ce
3 changed files with 59 additions and 2 deletions

View File

@ -2,8 +2,13 @@ package com.dispose.controller;
import com.dispose.Global.InitTestEnvironment; import com.dispose.Global.InitTestEnvironment;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.pojo.po.ReturnStatus;
import com.dispose.pojo.vo.information.DisposeNodeData;
import com.dispose.pojo.vo.information.DisposeNodeListRsp; import com.dispose.pojo.vo.information.DisposeNodeListRsp;
import com.dispose.pojo.vo.information.NodeTaskRsp; import com.dispose.pojo.vo.information.NodeTaskRsp;
import com.dispose.pojo.vo.information.VersionRsp;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Assert; import org.junit.Assert;
@ -15,10 +20,15 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ -28,6 +38,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback
@Slf4j @Slf4j
public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment { public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment {
/** /**
@ -72,7 +84,7 @@ public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment {
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
NodeTaskRsp rspInfo = objectMapper.readValue(verifyResp(ret), NodeTaskRsp.class) ; NodeTaskRsp rspInfo = objectMapper.readValue(verifyResp(ret), NodeTaskRsp.class);
Assert.assertNotNull(rspInfo); Assert.assertNotNull(rspInfo);
Assert.assertNotEquals(rspInfo.getItems().size(), 0); Assert.assertNotEquals(rspInfo.getItems().size(), 0);
@ -100,9 +112,46 @@ public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment {
.getResponse() .getResponse()
.getContentAsString(); .getContentAsString();
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class) ; DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
Assert.assertNotNull(rspInfo); Assert.assertNotNull(rspInfo);
Assert.assertNotEquals(rspInfo.getItems().size(), 0); Assert.assertNotEquals(rspInfo.getItems().size(), 0);
} }
/**
* C 2 get Node Details MsgContentEmpty Test.
*
* @throws Exception the exception
*/
@Test
public void c2_getNodeDetailsMsgContentEmptyTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040,\"msgContent\":\"\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/information/node_details")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", "Bearer " + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
// DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class) ;
// List<DisposeNodeData> List = rspInfo.getItems();
//
// for (DisposeNodeData r:List){
// Assert.assertNotNull(r.getMessage());
// Assert.assertNotNull(r.getStatus());
// Assert.assertEquals(Long.valueOf(r.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
// }
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(ret), 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());
}
} }

View File

@ -15,9 +15,11 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -30,6 +32,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback
@Slf4j @Slf4j
public class DeviceNodeManagerControlllerQATest extends InitTestEnvironment { public class DeviceNodeManagerControlllerQATest extends InitTestEnvironment {
/** /**

View File

@ -20,9 +20,11 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
@ -36,6 +38,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback
@Slf4j @Slf4j
public class DeviceNodeManagerControlllerSmokeTest extends InitTestEnvironment { public class DeviceNodeManagerControlllerSmokeTest extends InitTestEnvironment {
/** /**