From 393973d033d0f70834b02a08ed582c94e146a604 Mon Sep 17 00:00:00 2001 From: wangyiyun Date: Fri, 28 Aug 2020 15:55:08 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E6=B7=BB=E5=8A=A0service?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=EF=BC=88=E8=B0=83=E7=94=A8?= =?UTF-8?q?manager=E5=B1=82=E6=8E=A5=E5=8F=A3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DisposeAbilityRouterServiceTest.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/test/java/com/dispose/test/service/DisposeAbilityRouterServiceTest.java b/src/test/java/com/dispose/test/service/DisposeAbilityRouterServiceTest.java index c80d600b..22f5b76e 100644 --- a/src/test/java/com/dispose/test/service/DisposeAbilityRouterServiceTest.java +++ b/src/test/java/com/dispose/test/service/DisposeAbilityRouterServiceTest.java @@ -4,6 +4,7 @@ import com.dispose.common.DisposeDeviceType; import com.dispose.common.ErrorCode; import com.dispose.common.HttpType; import com.dispose.common.ObjectStatus; +import com.dispose.manager.DisposeDeviceManager; import com.dispose.mapper.DisposeDeviceMapper; import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.po.AbilityInfo; @@ -60,6 +61,11 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { */ @Resource private DisposeDeviceMapper disposeDeviceMapper; + /** + * The dispose device manager. + */ + @Resource + private DisposeDeviceManager disposeDeviceManager; /** * The Object mapper. */ @@ -68,6 +74,7 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { public static Integer VIRTUAL_DISPOSE = 999; + public static Integer DPTECH_UMC = 0; /** * User login test. @@ -188,4 +195,78 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { } }); } + /** + * A 5 Add dispose device list. + */ + @Test + public void a5_addDisposeAbilityDeviceTest() throws JsonProcessingException { + DisposeDevice dev = DisposeDevice.builder() + .ipAddr("192.168.1.1") + .ipPort("") + .deviceType(DisposeDeviceType.DPTECH_UMC) + .areaCode(0) + .deviceName("迪普设备添加测试") + .manufacturer("DP") + .model("UMC") + .version("5.7.13") + .userName("admin") + .password("") + .urlPath("UMC/service/AbnormalFlowCleaningService") + .urlType(HttpType.HTTP) + .readme("实验室测试设备") + .status(ObjectStatus.NORMAL) + .build(); + + Assert.assertEquals(ErrorCode.ERR_OK,disposeAbilityRouterService.addDisposeAbilityDevice(dev)); + Assert.assertEquals(dev.getDeviceType().getValue(), DPTECH_UMC); + + AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(dev.getIpAddr(), dev.getIpPort()); + log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(abilityInfo)); + } + + /** + * A 7 Gets ability device by ipAddr and ipPort. + */ + @Test + public void a7_getAbilityDeviceTest() throws JsonProcessingException { + List deviceList = disposeDeviceManager.getAllNormalDisposeDevices(); + log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(deviceList)); + + deviceList.forEach(v -> { + AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getIpAddr(), v.getIpPort()); + + Assert.assertNotNull(abilityInfo); + Assert.assertNotNull(abilityInfo.getDb()); + Assert.assertNotNull(abilityInfo.getDev()); + + if(abilityInfo.getDev().getDeviceType() == DisposeDeviceType.VIRTUAL_DISPOSE){ + Assert.assertNull(abilityInfo.getFirewareInfo()); + Assert.assertFalse(abilityInfo.isLinkStatus()); + }else{ + Assert.assertNotNull(abilityInfo.getFirewareInfo()); + Assert.assertTrue(abilityInfo.isLinkStatus()); + } + }); + } + /** + * A 8 Gets ability device by id. + */ + @Test + public void a8_getAbilityDevice() throws JsonProcessingException { + List deviceList = disposeDeviceManager.getAllNormalDisposeDevices(); + log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(deviceList)); + + deviceList.forEach(v -> { + AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getId()); + + Assert.assertNotNull(abilityInfo); + Assert.assertNotNull(abilityInfo.getDb()); + Assert.assertNotNull(abilityInfo.getDev()); + + if(abilityInfo.getDev().getDeviceType() == DisposeDeviceType.DPTECH_UMC){ + Assert.assertNotNull(abilityInfo.getFirewareInfo()); + Assert.assertTrue(abilityInfo.isLinkStatus()); + } + }); + } }