diff --git a/src/main/java/com/dispose/config/DisposeConfigure.java b/src/main/java/com/dispose/config/DisposeConfigure.java index 3b8eaf55..25f140da 100644 --- a/src/main/java/com/dispose/config/DisposeConfigure.java +++ b/src/main/java/com/dispose/config/DisposeConfigure.java @@ -56,6 +56,6 @@ public class DisposeConfigure { DisposeConfigValue.CHECK_PROTO_REQUEST_TIMEOUT = Optional.ofNullable(checkProtocolTimeout).orElse(true); DisposeConfigValue.USED_PRIVACY_PROTECT = Optional.ofNullable(usedPrivacyProtect).orElse(true); DisposeConfigValue.CALL_ERROR_RETRY_TIMES = Optional.ofNullable(callErrorRetryTimes).orElse(5); - DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH=Optional.ofNullable(defaultDisposeBandWidth).orElse(1024); + DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH = Optional.ofNullable(defaultDisposeBandWidth).orElse(1024); } } diff --git a/src/test/java/com/dispose/test/manager/DisposeTaskManagerTest.java b/src/test/java/com/dispose/test/manager/DisposeTaskManagerTest.java index 2fff4bed..6acf6864 100644 --- a/src/test/java/com/dispose/test/manager/DisposeTaskManagerTest.java +++ b/src/test/java/com/dispose/test/manager/DisposeTaskManagerTest.java @@ -1,8 +1,10 @@ package com.dispose.test.manager; -import com.dispose.common.DisposeTaskStatus; +import com.dispose.common.*; import com.dispose.manager.DisposeTaskManager; +import com.dispose.mapper.DisposeDeviceMapper; import com.dispose.mapper.DisposeTaskMapper; +import com.dispose.mapper.UserAccountMapper; import com.dispose.pojo.entity.DisposeTask; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -48,6 +50,17 @@ public class DisposeTaskManagerTest { */ @Resource 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. @@ -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 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); + } + + } }