1、DynamicRule实现新增、删除、修改、id查询、分页查询功能。并在crud时与ProtectObject关联。
2、StaticRule添加批量导入、模板文件下载功能,使用sqlSessionWrapper重写批量删除 3、WhiteList添加模板文件下载功能
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package com.realtime.protection.server.rule.dynamic;
|
||||
|
||||
import com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject;
|
||||
import com.realtime.protection.server.rule.dynamicrule.DynamicRuleService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@SpringBootTest
|
||||
public class DynamicRuleServiceTest {
|
||||
private final DynamicRuleService dynamicRuleService;
|
||||
@Autowired
|
||||
public DynamicRuleServiceTest(DynamicRuleService dynamicRuleService) {
|
||||
this.dynamicRuleService = dynamicRuleService;
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNewDynamicRule() {
|
||||
DynamicRuleObject object = new DynamicRuleObject();
|
||||
object.setDynamicRuleName("UpdateDynamicRule2");
|
||||
object.setDynamicRuleEventType(1);
|
||||
object.setDynamicRuleFrequency(1);
|
||||
object.setDynamicRulePriority(1);
|
||||
object.setDynamicRuleRange("北京");
|
||||
object.setDynamicRuleProtectLevel(2);
|
||||
object.setDynamicRuleSourceSystem(1);
|
||||
object.setProtectObjectIds(List.of(new Integer[]{5521, 5520}));
|
||||
|
||||
|
||||
Integer objectId = dynamicRuleService.newDynamicRuleObject(object);
|
||||
assertTrue(objectId > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeleteDynamicRule() {
|
||||
dynamicRuleService.deleteDynamicRuleObject(8);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueryDynamicRule() {
|
||||
DynamicRuleObject object = dynamicRuleService.queryDynamicRuleById(9);
|
||||
System.out.println(object);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateDynamicRule() {
|
||||
DynamicRuleObject object = new DynamicRuleObject();
|
||||
object.setDynamicRuleName("UpdateDynamicRule2");
|
||||
object.setDynamicRuleEventType(1);
|
||||
object.setDynamicRuleFrequency(1);
|
||||
object.setDynamicRulePriority(1);
|
||||
object.setDynamicRuleRange("北京");
|
||||
object.setDynamicRuleProtectLevel(2);
|
||||
object.setDynamicRuleSourceSystem(1);
|
||||
object.setProtectObjectIds(List.of(new Integer[]{5521, 5520}));
|
||||
|
||||
dynamicRuleService.updateDynamicRuleObject(9, object);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueryDynamicRuleObject() {
|
||||
List<DynamicRuleObject> objects = dynamicRuleService.queryDynamicRuleObject( null,null,1, 10);
|
||||
System.out.println(objects);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.realtime.protection.server.rule.staticrule;
|
||||
|
||||
import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -13,8 +14,31 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
public class StaticRuleServiceTest {
|
||||
private final StaticRuleService staticRuleService;
|
||||
private StaticRuleObject staticRuleTest;
|
||||
@Autowired
|
||||
private StaticRuleService staticRuleService;
|
||||
public StaticRuleServiceTest(StaticRuleService staticRuleService) {
|
||||
this.staticRuleService = staticRuleService;
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
staticRuleTest = new StaticRuleObject();
|
||||
staticRuleTest.setStaticRuleName("test_staticrule");
|
||||
staticRuleTest.setStaticRuleCreateTime(LocalDateTime.now());
|
||||
staticRuleTest.setStaticRuleCreateUsername("mh");
|
||||
staticRuleTest.setStaticRuleCreateDepart("mmeess");
|
||||
staticRuleTest.setStaticRuleCreateUserId(2);
|
||||
staticRuleTest.setStaticRuleAuditStatus(0);
|
||||
|
||||
staticRuleTest.setStaticRuleSip("1.1.2.3");
|
||||
staticRuleTest.setStaticRuleSport(80);
|
||||
|
||||
staticRuleTest.setStaticRulePriority(1);
|
||||
staticRuleTest.setStaticRuleFrequency(1);
|
||||
staticRuleTest.setStaticRuleRange("北京");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNewStaticRule(){
|
||||
@@ -34,12 +58,21 @@ public class StaticRuleServiceTest {
|
||||
object.setStaticRulePriority(2);
|
||||
object.setStaticRuleFrequency(1);
|
||||
object.setStaticRuleRange("北京");
|
||||
object.setStaticRuleProtectLevel(2);
|
||||
// object.setStaticRuleProtectLevel(2);
|
||||
|
||||
Integer id = staticRuleService.newStaticRuleObject(object);
|
||||
}
|
||||
//assertTrue(id>0);
|
||||
}
|
||||
@Test
|
||||
void testNewStaticRules(){
|
||||
List<StaticRuleObject> staticRuleObjects = new ArrayList<>();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
staticRuleObjects.add(staticRuleTest);
|
||||
}
|
||||
Boolean success = staticRuleService.newStaticRuleObjects(staticRuleObjects);
|
||||
assertTrue(success);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeleteStaticRule(){
|
||||
@@ -48,7 +81,7 @@ public class StaticRuleServiceTest {
|
||||
list.add(1);
|
||||
while(i<2) {
|
||||
i++;
|
||||
staticRuleService.deleteStaticRule(list);
|
||||
staticRuleService.deleteStaticRules(list);
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@@ -68,7 +101,7 @@ public class StaticRuleServiceTest {
|
||||
object.setStaticRulePriority(2);
|
||||
object.setStaticRuleFrequency(1);
|
||||
object.setStaticRuleRange("北京");
|
||||
object.setStaticRuleProtectLevel(2);
|
||||
// object.setStaticRuleProtectLevel(2);
|
||||
|
||||
staticRuleService.updateStaticRule(object);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user