REM:
1. 添加增加处置任务单元测试。
This commit is contained in:
wangyiyun 2020-09-02 15:31:45 +08:00
parent 8ef120caa0
commit 38a45d451d
2 changed files with 47 additions and 2 deletions

View File

@ -1,8 +1,10 @@
package com.dispose.test.manager; package com.dispose.test.manager;
import com.dispose.common.DisposeTaskStatus; import com.dispose.common.*;
import com.dispose.manager.DisposeTaskManager; import com.dispose.manager.DisposeTaskManager;
import com.dispose.mapper.DisposeDeviceMapper;
import com.dispose.mapper.DisposeTaskMapper; import com.dispose.mapper.DisposeTaskMapper;
import com.dispose.mapper.UserAccountMapper;
import com.dispose.pojo.entity.DisposeTask; import com.dispose.pojo.entity.DisposeTask;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@ -48,6 +50,17 @@ public class DisposeTaskManagerTest {
*/ */
@Resource @Resource
private DisposeTaskManager disposeTaskManager; private DisposeTaskManager disposeTaskManager;
/**
* The User account mapper.
*/
@Resource
private UserAccountMapper userAccountMapper;
/**
* The Dispose device mapper.
*/
@Resource
private DisposeDeviceMapper disposeDeviceMapper;
/** /**
* A 1 Dispose ip running boolean. * A 1 Dispose ip running boolean.
@ -147,4 +160,36 @@ public class DisposeTaskManagerTest {
} }
}); });
} }
/**
* A 6 add dispose task test.
*/
@Test
public void a6_addDisposeTaskTest() {
Long uId = userAccountMapper.selectAll().get(0).getId();
Long dId = disposeDeviceMapper.selectAll().get(0).getId();
DisposeTask disposeTask = DisposeTask.builder()
.deviceId(dId)
.accountId(uId)
.disposeCapacity(DisposeCapacityType.CLEANUP)
.disposeIp("192.168.0.1")
.planEndTime("30")
.flowDirection(NetflowDirection.DIRECTION_BI)
.attackType(DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[]{DDoSAttackType.ALL_ATTACKS}))
.flowBandWidth(1024)
.build();
ErrorCode err = disposeTaskManager.addDisposeTask(disposeTask);
List<DisposeTask> taskList = disposeTaskMapper.selectAll();
DisposeTask task = disposeTaskMapper.getDisposeTaskById(disposeTask.getId());
if (err == ErrorCode.ERR_OK) {
Assert.assertNotNull(task);
//Assert.assertEquals(disposeTask,task);
Assert.assertNotEquals(taskList.size(), 0);
}else {
Assert.assertNull(task);
Assert.assertEquals(taskList.size(), 0);
}
}
} }