diff --git a/src/test/java/com/dispose/controller/DeviceNodeManagerControllerTest.java b/src/test/java/com/dispose/controller/DeviceNodeManagerControllerTest.java index a27fb53b..2e998bfc 100644 --- a/src/test/java/com/dispose/controller/DeviceNodeManagerControllerTest.java +++ b/src/test/java/com/dispose/controller/DeviceNodeManagerControllerTest.java @@ -116,17 +116,6 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment { .readme("实验室测试设备") .build()); - addReq.getItems().add(NewNodeInfo.builder() - .ipAddr("10.88.77.16") - .type(DisposeDeviceType.DPTECH_UMC.getCode()) - .areaCode(0) - .name("清洗设备") - .manufacturer("DPTech") - .model("UMC") - .version("5.7.10") - .readme("测试设备") - .build()); - Long reqTimeStamp = System.currentTimeMillis(); ProtocolReqDTO reqInfo = new ProtocolReqDTO(); @@ -135,7 +124,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment { reqInfo.setTimeStamp(reqTimeStamp); reqInfo.setMsgContent(objectMapper.writeValueAsString(addReq)); - List> res = new ArrayList>(); + List> res = new ArrayList<>(); List nesNodes = addReq.getItems(); for (NewNodeInfo node : nesNodes @@ -188,97 +177,6 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment { } } - /** - * T 1 add device. - * - * @throws Exception the exception - */ - @Test - public void t1_addDevice1() throws Exception { - AddNodeReq addReq = AddNodeReq.builder() - .items(new ArrayList<>()) - .build(); - - addReq.getItems().add(NewNodeInfo.builder() - .ipAddr("10.88.77.16") - .type(DisposeDeviceType.DPTECH_UMC.getCode()) - .areaCode(0) - .name("清洗设备") - .manufacturer("DPTech") - .model("UMC") - .version("5.7.10") - .readme("测试设备") - .build()); - - Long reqTimeStamp = System.currentTimeMillis(); - ProtocolReqDTO reqInfo = new ProtocolReqDTO(); - reqInfo.setVer(ConstValue.Protocol.VERSION); - reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE); - reqInfo.setTimeStamp(reqTimeStamp); - reqInfo.setMsgContent(objectMapper.writeValueAsString(addReq)); - - List decsBef = disposeNodeManager.getAllDisposeDevice(); - - String deviceAdd = mockMvc.perform(MockMvcRequestBuilders - .put("/manager/device") - .contentType(MediaType.APPLICATION_JSON) - .header("Authorization", "Bearer " + getLogToken()) - .content(objectMapper.writeValueAsString(reqInfo))) - .andDo(print()).andExpect(status().isOk()) - .andExpect(jsonPath("$.code").value(200)) - .andReturn() - .getResponse() - .getContentAsString(); - - List decsAfter = disposeNodeManager.getAllDisposeDevice(); - - String msgContent = verifyRep(deviceAdd, reqTimeStamp); - System.out.println("msgContent=" + msgContent); - - org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent); - String result = jsonObject.getString("result"); - System.out.println("result=" + result); - - net.sf.json.JSONArray json = JSONArray.fromObject(result); - for (int i = 0; i < json.size(); i++) { - JSONObject Content = json.getJSONObject(i); - String status = Content.getString("status"); - String message = Content.getString("message"); - String ipAddr = Content.getString("ipAddr"); - - //before: no device information - //after: device information exists - boolean before = false; - if (decsBef != null && decsBef.size() > 0) { - for (DisposeDevice v : decsBef) { - if (v.getIpAddr().equals(ipAddr)) { - before = true; - break; - } - } - - boolean after = false; - if (decsAfter != null && decsAfter.size() > 0) { - for (DisposeDevice v : decsAfter) { - if (v.getIpAddr().equals(ipAddr)) { - after = true; - break; - } - } - - if ((!before) && after) { - Assert.assertEquals(status, "0"); - Assert.assertEquals(message, "成功"); - } else { - Assert.assertEquals(status, "20"); - Assert.assertEquals(message, "设备已经存在"); - } - } - } - } - } - - /** * T 2 del device. * @@ -299,7 +197,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment { log.info("Request Json:" + objectMapper.writeValueAsString(reqInfo)); - List> res = new ArrayList>(); + List> res = new ArrayList<>(); String[] ids = reqData.getId(); for (String s : ids) {