From 0e890ee00883a77f6ce9efcfa8e35b9d33ab4dee Mon Sep 17 00:00:00 2001 From: lijinxing Date: Wed, 8 Jul 2020 09:54:01 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM=EF=BC=9A=201.=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=9A=84=E6=B5=A9=E7=80=9A=E8=83=BD?= =?UTF-8?q?=E5=8A=9B=E8=8A=82=E7=82=B9=E5=86=92=E7=83=9F=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeviceNodeManagerControllerSmokeTest.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/test/java/com/dispose/test/controller/DeviceNodeManagerControllerSmokeTest.java b/src/test/java/com/dispose/test/controller/DeviceNodeManagerControllerSmokeTest.java index 37a699cb..7227e942 100644 --- a/src/test/java/com/dispose/test/controller/DeviceNodeManagerControllerSmokeTest.java +++ b/src/test/java/com/dispose/test/controller/DeviceNodeManagerControllerSmokeTest.java @@ -136,6 +136,52 @@ public class DeviceNodeManagerControllerSmokeTest extends InitTestEnvironment { } } + /** + * A 2 add Normal HaoHan DeviceNodeManager test. + * + * @throws Exception the exception + */ + @Test + public void a2_addNormalHaoHanDeviceNodeManager() throws Exception { + String reqData = "{\n" + + "\"ver\": 2,\n" + + "\"cryptoType\": 0,\n" + + "\"timeStamp\": 1589437275258,\n" + + "\"msgContent\":\"{\\\"items\\\":[{\\\"areaCode\\\":0,\\\"ipAddr\\\":\\\"10.88.77.88:18080\\\"," + + "\\\"manufacturer\\\":\\\"HaoHan\\\",\\\"model\\\":\\\"Unknown\\\"," + + "\\\"name\\\":\\\"中移杭研实验室浩瀚清洗设备\\\",\\\"readme\\\":\\\"实验室测试设备\\\",\\\"type\\\":1," + + "\\\"version\\\":\\\"Unknown\\\",\\\"url\\\":\\\"http://%s/DDoSClean/clean\\\" }]}\"\n" + + "}"; + + String ret = mockMvc.perform(MockMvcRequestBuilders + .put("/manager/device") + .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(); + + AddNodeRsp retStatus = objectMapper.readValue(verifyResp(ret), AddNodeRsp.class); + List r = retStatus.getItems(); + for (AddNodeRetData v : r + ) { + Assert.assertNotNull(v); + Assert.assertNotNull(v.getIpAddr()); + Assert.assertNotNull(v.getDevId()); + Assert.assertNotNull(v.getMessage()); + Assert.assertNotNull(v.getStatus()); + + if (v.getStatus() == 0) { + Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); + } else if (v.getStatus() == 20) { + Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_DEVICEEXISTS.getCode())); + } + } + } + /** * B 1 delete Normal DeviceNodeManager test. *