diff --git a/src/test/java/com/dispose/controller/DeviceNodeInfoControllerSmokeTest.java b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerSmokeTest.java index 111e674a..b8b57303 100644 --- a/src/test/java/com/dispose/controller/DeviceNodeInfoControllerSmokeTest.java +++ b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerSmokeTest.java @@ -2,8 +2,13 @@ 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.DisposeNodeData; import com.dispose.pojo.vo.information.DisposeNodeListRsp; 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 lombok.extern.slf4j.Slf4j; 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.http.MediaType; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.transaction.annotation.Transactional; + 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.MockMvcResultMatchers.jsonPath; 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) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Transactional +@Rollback @Slf4j public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment { /** @@ -72,7 +84,7 @@ public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment { .getResponse() .getContentAsString(); - NodeTaskRsp rspInfo = objectMapper.readValue(verifyResp(ret), NodeTaskRsp.class) ; + NodeTaskRsp rspInfo = objectMapper.readValue(verifyResp(ret), NodeTaskRsp.class); Assert.assertNotNull(rspInfo); Assert.assertNotEquals(rspInfo.getItems().size(), 0); @@ -100,9 +112,46 @@ public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment { .getResponse() .getContentAsString(); - DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class) ; + DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class); Assert.assertNotNull(rspInfo); 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 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()); + + } } diff --git a/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerQATest.java b/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerQATest.java index fb90824a..a8bcd666 100644 --- a/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerQATest.java +++ b/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerQATest.java @@ -15,9 +15,11 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; @@ -30,6 +32,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Transactional +@Rollback @Slf4j public class DeviceNodeManagerControlllerQATest extends InitTestEnvironment { /** diff --git a/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerSmokeTest.java b/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerSmokeTest.java index c8cc2d58..79eae109 100644 --- a/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerSmokeTest.java +++ b/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerSmokeTest.java @@ -20,9 +20,11 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; @@ -36,6 +38,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Transactional +@Rollback @Slf4j public class DeviceNodeManagerControlllerSmokeTest extends InitTestEnvironment { /**