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()); + } }); } }