1. 删除Command类,Doris数据库改用TaskCommandInfo类作为实体类
2. 取消FailedState和GeneratingState的使用 3. 修改部分bug
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.realtime.protection.server.task;
|
||||
|
||||
import com.realtime.protection.ProtectionApplicationTests;
|
||||
import com.realtime.protection.configuration.entity.task.Task;
|
||||
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -14,7 +15,7 @@ import java.util.List;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
class TaskServiceTest {
|
||||
class TaskServiceTest extends ProtectionApplicationTests {
|
||||
private final TaskService taskService;
|
||||
private Task task;
|
||||
|
||||
@@ -35,9 +36,9 @@ class TaskServiceTest {
|
||||
task.setTaskEndTime(taskEndTime);
|
||||
task.setTaskAct("阻断");
|
||||
task.setTaskType(1);
|
||||
task.setStaticRuleIds(List.of(1L, 2L));
|
||||
task.setStaticRuleIds(List.of(1, 2));
|
||||
task.setDynamicRuleIds(List.of());
|
||||
task.setTaskCreateUserId(1L);
|
||||
task.setTaskCreateUserId(1);
|
||||
task.setTaskCreateUsername("xxx");
|
||||
task.setTaskCreateDepart("xxx");
|
||||
}
|
||||
@@ -76,7 +77,7 @@ class TaskServiceTest {
|
||||
void testUpdateTasks() {
|
||||
Task originalTask = taskService.queryTask(38L);
|
||||
|
||||
originalTask.setStaticRuleIds(List.of(16L, 17L, 18L, 19L));
|
||||
originalTask.setStaticRuleIds(List.of(16, 17, 18, 19));
|
||||
originalTask.setTaskName("修改测试");
|
||||
|
||||
assertTrue(taskService.updateTask(originalTask));
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.realtime.protection.server.task.status;
|
||||
|
||||
import com.alibaba.excel.util.ListUtils;
|
||||
import com.realtime.protection.ProtectionApplicationTests;
|
||||
import com.realtime.protection.configuration.entity.task.FiveTupleWithMask;
|
||||
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
||||
import com.realtime.protection.server.command.CommandService;
|
||||
@@ -10,13 +12,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
@SpringBootTest
|
||||
class CommandServiceTest {
|
||||
class CommandServiceTest extends ProtectionApplicationTests {
|
||||
|
||||
private final CommandService commandService;
|
||||
private TaskCommandInfo taskCommandInfo;
|
||||
@@ -37,8 +38,10 @@ class CommandServiceTest {
|
||||
taskCommandInfo.setFrequency(30);
|
||||
taskCommandInfo.setTaskId(30L);
|
||||
taskCommandInfo.setFiveTupleWithMask(fiveTupleWithMask);
|
||||
taskCommandInfo.setOperation("阻断");
|
||||
taskCommandInfo.setEndTime(LocalDateTime.now().plusDays(1));
|
||||
taskCommandInfo.setTaskAct("阻断");
|
||||
taskCommandInfo.setStartTime(LocalDateTime.now().plusDays(10));
|
||||
taskCommandInfo.setEndTime(LocalDateTime.now().plusDays(140));
|
||||
taskCommandInfo.setFrequency(30);
|
||||
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
@@ -56,12 +59,13 @@ class CommandServiceTest {
|
||||
|
||||
@Test
|
||||
void createCommands() {
|
||||
List<TaskCommandInfo> taskCommandInfos = new ArrayList<>();
|
||||
List<TaskCommandInfo> taskCommandInfos = ListUtils.newArrayListWithExpectedSize(100);
|
||||
for (int i = 0; i < 100; i++) {
|
||||
int port = i + 1000;
|
||||
taskCommandInfo = new TaskCommandInfo();
|
||||
TaskCommandInfo taskCommandInfo = new TaskCommandInfo();
|
||||
taskCommandInfo.setFiveTupleWithMask(new FiveTupleWithMask());
|
||||
taskCommandInfo.setTaskId(24L);
|
||||
taskCommandInfo.setTaskId(30L);
|
||||
taskCommandInfo.setTaskAct("阻断");
|
||||
taskCommandInfo.getFiveTupleWithMask().setSourcePort(Integer.toString(port));
|
||||
taskCommandInfo.setStartTime(LocalDateTime.now().plusDays(5));
|
||||
taskCommandInfo.setEndTime(LocalDateTime.now().plusDays(10));
|
||||
@@ -70,6 +74,12 @@ class CommandServiceTest {
|
||||
taskCommandInfos.add(taskCommandInfo);
|
||||
}
|
||||
|
||||
for (TaskCommandInfo info : taskCommandInfos) {
|
||||
if (info.getFrequency() == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
assertDoesNotThrow(() -> commandService.createCommands(taskCommandInfos));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user