Rules Tester

This commit is contained in:
Timo 2021-01-06 19:37:39 +02:00
parent 07ffeab3ae
commit 2c4350b8f3
3 changed files with 15 additions and 0 deletions

View File

@ -29,4 +29,7 @@ public interface RedactionResource {
@PostMapping(value = "/rules/update"+RULE_SET_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "/rules/update"+RULE_SET_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
void updateRules(@PathVariable(RULE_SET_PARAMETER_NAME) String ruleSetId); void updateRules(@PathVariable(RULE_SET_PARAMETER_NAME) String ruleSetId);
@PostMapping(value = "/rules/test", consumes = MediaType.APPLICATION_JSON_VALUE)
void testRules(@RequestBody String rules);
} }

View File

@ -139,6 +139,11 @@ public class RedactionController implements RedactionResource {
droolsExecutionService.updateRules(ruleSetId); droolsExecutionService.updateRules(ruleSetId);
} }
@Override
public void testRules(@RequestBody String rules) {
droolsExecutionService.testRules(rules);
}
private RedactionResult convert(PDDocument document, int numberOfPages, String ruleSetId) throws IOException { private RedactionResult convert(PDDocument document, int numberOfPages, String ruleSetId) throws IOException {

View File

@ -103,4 +103,11 @@ public class DroolsExecutionService {
} }
public void testRules(String rules) {
KieServices kieServices = KieServices.Factory.get();
KieModule kieModule = getKieModule("test-rules", rules, kieServices);
var container = kieServices.newKieContainer(kieModule.getReleaseId());
container.newKieSession();
container.dispose();
}
} }