use of org.drools.verifier.report.components.Redundancy in project drools by kiegroup.
the class NotesTest method testRedundantRestrictionsInPatternPossibilities.
@Test
public void testRedundantRestrictionsInPatternPossibilities() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("Notes.drl"));
Pattern pattern = VerifierComponentMockFactory.createPattern1();
Collection<Object> objects = new ArrayList<Object>();
LiteralRestriction left = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction right = LiteralRestriction.createRestriction(pattern, "");
Redundancy redundancy = new Redundancy(left, right);
SubPattern possibility = new SubPattern(pattern, 0);
possibility.add(left);
possibility.add(right);
objects.add(left);
objects.add(right);
objects.add(redundancy);
objects.add(possibility);
VerifierReport result = VerifierReportFactory.newVerifierReport();
session.setGlobal("result", result);
for (Object o : objects) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Find redundant restrictions from pattern possibilities"));
Collection<VerifierMessageBase> notes = result.getBySeverity(Severity.NOTE);
// Has at least one item.
assertEquals(1, notes.size());
VerifierMessageBase note = notes.iterator().next();
Iterator<Cause> causes = note.getCauses().iterator();
assertEquals(left, causes.next());
assertEquals(right, causes.next());
}
use of org.drools.verifier.report.components.Redundancy in project drools by kiegroup.
the class NotesTest method testRedundantPatternPossibilitiesInRulePossibilities.
@Test
public void testRedundantPatternPossibilitiesInRulePossibilities() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("Notes.drl"));
VerifierRule rule = VerifierComponentMockFactory.createRule1();
Pattern pattern = VerifierComponentMockFactory.createPattern1();
Collection<Object> objects = new ArrayList<Object>();
SubPattern left = new SubPattern(pattern, 0);
SubPattern right = new SubPattern(pattern, 1);
Redundancy redundancy = new Redundancy(left, right);
SubRule possibility = new SubRule(rule, 0);
possibility.add(left);
possibility.add(right);
objects.add(left);
objects.add(right);
objects.add(redundancy);
objects.add(possibility);
VerifierReport result = VerifierReportFactory.newVerifierReport();
session.setGlobal("result", result);
for (Object o : objects) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Find redundant pattern possibilities from rule possibilities"));
Collection<VerifierMessageBase> notes = result.getBySeverity(Severity.NOTE);
// Has at least one item.
assertEquals(1, notes.size());
VerifierMessageBase note = notes.iterator().next();
Iterator<Cause> causes = note.getCauses().iterator();
assertEquals(left, causes.next());
assertEquals(right, causes.next());
}
Aggregations