OCT
REM: 1. 编写service层设备能力节点根据ID、根据IP和端口号获取设备信息的单元测试 2.修改数据库userAccount更新lastAccess字段的SQL语句
This commit is contained in:
parent
052f0de950
commit
bac7489aa6
|
@ -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}
|
||||
</select>
|
||||
|
||||
<update id="upgradeLoginTime">
|
||||
|
|
|
@ -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<AbilityInfo> abilityInfoList = disposeAbilityRouterService.getAllAbilityDevices();
|
||||
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(abilityInfoList));
|
||||
|
||||
abilityInfoList.forEach(v->{
|
||||
abilityInfoList.forEach(v -> {
|
||||
Assert.assertNotNull(v.getDb());
|
||||
Assert.assertNotNull(v.getDev());
|
||||
|
||||
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<DisposeDevice> 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<DisposeDevice> 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());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue