use of org.drools.verifier.report.components.VerifierMessage in project drools by kiegroup.
the class IncoherentRestrictionsTest method testIncoherentLiteralRestrictionsInSubPatternImpossibleRanges.
@Test
public void testIncoherentLiteralRestrictionsInSubPatternImpossibleRanges() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("Restrictions.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("RestrictionsTest.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Incoherent LiteralRestrictions with ranges in pattern possibility, impossible ranges"));
Iterator<VerifierMessageBase> iter = result.getBySeverity(Severity.ERROR).iterator();
Set<String> rulesThatHadErrors = new HashSet<String>();
while (iter.hasNext()) {
Object o = (Object) iter.next();
if (o instanceof VerifierMessage) {
Pattern pattern = (Pattern) ((VerifierMessage) o).getFaulty();
rulesThatHadErrors.add(pattern.getRuleName());
}
}
assertTrue(rulesThatHadErrors.remove("Incoherent restrictions 8"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
Aggregations