REM:
1. 添加处置能力验证单元测试。
This commit is contained in:
wangyiyun 2020-09-04 10:48:03 +08:00
parent d899cb5da3
commit c30e609eb4
1 changed files with 35 additions and 4 deletions

View File

@ -1,12 +1,12 @@
package com.dispose.test.service;
import com.dispose.common.DisposeDeviceType;
import com.dispose.common.ErrorCode;
import com.dispose.common.HttpType;
import com.dispose.common.ObjectStatus;
import com.dispose.common.*;
import com.dispose.manager.DisposeDeviceManager;
import com.dispose.mapper.DisposeDeviceMapper;
import com.dispose.mapper.DisposeTaskMapper;
import com.dispose.pojo.entity.DisposeCapacity;
import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.pojo.entity.DisposeTask;
import com.dispose.pojo.po.AbilityInfo;
import com.dispose.pojo.po.MulReturnType;
import com.dispose.service.DisposeAbilityRouterService;
@ -66,6 +66,11 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment {
*/
@Resource
private DisposeDeviceManager disposeDeviceManager;
/**
* The dispose device manager.
*/
@Resource
private DisposeTaskMapper disposeTaskMapper;
/**
* The Object mapper.
*/
@ -269,4 +274,30 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment {
}
});
}
/**
* A 9 verify dispose capacity test.
*/
@Test
public void a9_verifyDisposeCapacityTest(){
long deviceId = disposeDeviceMapper.selectAll().get(0).getId();
DisposeCapacityType capacityType = DisposeCapacityType.CLEANUP;
String disposeIp = disposeTaskMapper.selectAll().get(0).getDisposeIp();
ErrorCode err = disposeAbilityRouterService.verifyDisposeCapacity(deviceId,disposeIp,capacityType);
if(err == ErrorCode.ERR_NOSUCHDEVICE){
Assert.assertNotEquals(deviceId,-1L);
for (DisposeDevice d : disposeDeviceMapper.selectAll()) {
Assert.assertNotEquals(java.util.Optional.ofNullable(d.getId()),deviceId);
}
}else if(err == ErrorCode.ERR_NOSUCHTYPE){
Assert.assertNotEquals((int) capacityType.getValue(), 0);
Assert.assertNotEquals((int) capacityType.getValue(), 1);
Assert.assertNotEquals((int) capacityType.getValue(), 2);
Assert.assertNotEquals((int) capacityType.getValue(), 3);
}
else if(err == ErrorCode.ERR_IPNODEVICE)
{
disposeTaskMapper.selectAll().forEach(i -> Assert.assertNotEquals(i.getDisposeIp(), disposeIp));
}
}
}