parent
aa7d242e78
commit
393973d033
|
@ -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<DisposeDevice> 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<DisposeDevice> 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());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue