From bac7489aa65d2375a1fafe3e95fe4ffd739dc32b Mon Sep 17 00:00:00 2001 From: chenlinghy Date: Wed, 26 Aug 2020 11:26:12 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E7=BC=96=E5=86=99service?= =?UTF-8?q?=E5=B1=82=E8=AE=BE=E5=A4=87=E8=83=BD=E5=8A=9B=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=A0=B9=E6=8D=AEID=E3=80=81=E6=A0=B9=E6=8D=AEIP=E5=92=8C?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E5=8F=B7=E8=8E=B7=E5=8F=96=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=202.=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E5=BA=93userAccount?= =?UTF-8?q?=E6=9B=B4=E6=96=B0lastAccess=E5=AD=97=E6=AE=B5=E7=9A=84SQL?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/mappers/UserAccount.xml | 4 -- .../DisposeAbilityRouterServiceTest.java | 69 ++++++++++++++++++- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/main/resources/mappers/UserAccount.xml b/src/main/resources/mappers/UserAccount.xml index 0a5ad470..6bf82cfc 100644 --- a/src/main/resources/mappers/UserAccount.xml +++ b/src/main/resources/mappers/UserAccount.xml @@ -54,10 +54,6 @@ user_account SET lastAccess = CURRENT_TIMESTAMP WHERE username = #{username, jdbcType=VARCHAR}; - - SELECT lastAccess - FROM user_account - WHERE username = #{username, jdbcType=VARCHAR} diff --git a/src/test/java/com/dispose/test/service/DisposeAbilityRouterServiceTest.java b/src/test/java/com/dispose/test/service/DisposeAbilityRouterServiceTest.java index 8c74ca63..c80d600b 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.mapper.DisposeDeviceMapper; import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.po.AbilityInfo; import com.dispose.pojo.po.MulReturnType; @@ -54,6 +55,11 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { */ @Resource private DisposeAbilityRouterService disposeAbilityRouterService; + /** + * The dispose device mapper. + */ + @Resource + private DisposeDeviceMapper disposeDeviceMapper; /** * The Object mapper. */ @@ -117,10 +123,69 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { List abilityInfoList = disposeAbilityRouterService.getAllAbilityDevices(); log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(abilityInfoList)); - abilityInfoList.forEach(v->{ + abilityInfoList.forEach(v -> { Assert.assertNotNull(v.getDb()); Assert.assertNotNull(v.getDev()); - Assert.assertFalse(v.isLinkStatus()); + + if(v.getDev().getDeviceType() == DisposeDeviceType.VIRTUAL_DISPOSE){ + Assert.assertNull(v.getFirewareInfo()); + Assert.assertFalse(v.isLinkStatus()); + }else{ + Assert.assertNotNull(v.getFirewareInfo()); + Assert.assertTrue(v.isLinkStatus()); + } + }); + } + + /** + * A 3 Gets ability device by ipAddr and ipPort. + */ + @Test + public void a3_getAbilityDeviceTest() throws JsonProcessingException { + List deviceList = disposeDeviceMapper.selectAll(); + + 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 4 Gets ability device by id. + */ + @Test + public void a4_getAbilityDevice() throws JsonProcessingException { + List deviceList = disposeDeviceMapper.selectAll(); + + 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.VIRTUAL_DISPOSE){ + Assert.assertNull(abilityInfo.getFirewareInfo()); + Assert.assertFalse(abilityInfo.isLinkStatus()); + }else{ + Assert.assertNotNull(abilityInfo.getFirewareInfo()); + Assert.assertTrue(abilityInfo.isLinkStatus()); + } }); } }