use of org.drools.verifier.data.VerifierReport in project drools by kiegroup.
the class ConsequenceTest method testMissingConsequence.
@Test
public void testMissingConsequence() throws Exception {
InputStream in = getClass().getResourceAsStream("Consequence.drl");
KieSession session = getStatelessKieSession(in);
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("ConsequenceTest2.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("No action - possibly commented out"));
Iterator<VerifierMessageBase> iterator = result.getBySeverity(Severity.WARNING).iterator();
Set<String> rulesThatHadErrors = new HashSet<String>();
while (iterator.hasNext()) {
Object o = iterator.next();
if (o instanceof VerifierMessage) {
VerifierMessage message = (VerifierMessage) o;
rulesThatHadErrors.addAll(message.getImpactedRules().values());
}
}
assertFalse(rulesThatHadErrors.contains("Has a consequence 1"));
assertTrue(rulesThatHadErrors.remove("Missing consequence 1"));
assertTrue(rulesThatHadErrors.remove("Missing consequence 2"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
use of org.drools.verifier.data.VerifierReport in project drools by kiegroup.
the class IncoherentPatternsTest method testIncoherentPatternsInSubRuleRangesEqualOrUnequalVariables.
@Test
public void testIncoherentPatternsInSubRuleRangesEqualOrUnequalVariables() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("Patterns.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("PatternsTest.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Incoherent Patterns in rule possibility, ranges when not conflicts with equal or unequal variables"));
Iterator<VerifierMessageBase> iter = result.getBySeverity(Severity.WARNING).iterator();
Set<String> rulesThatHadErrors = new HashSet<String>();
while (iter.hasNext()) {
Object o = iter.next();
if (o instanceof VerifierMessage) {
VerifierRule rule = (VerifierRule) ((VerifierMessage) o).getFaulty();
rulesThatHadErrors.add(rule.getName());
}
}
assertTrue(rulesThatHadErrors.remove("Incoherent patterns 11"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
use of org.drools.verifier.data.VerifierReport in project drools by kiegroup.
the class IncoherentPatternsTest method testIncoherentPatternsInSubRuleRangesLess.
@Test
public void testIncoherentPatternsInSubRuleRangesLess() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("Patterns.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("PatternsTest.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Incoherent Patterns in rule possibility, ranges when not conflicts with lesser value"));
Iterator<VerifierMessageBase> iter = result.getBySeverity(Severity.WARNING).iterator();
Set<String> rulesThatHadErrors = new HashSet<String>();
while (iter.hasNext()) {
Object o = iter.next();
if (o instanceof VerifierMessage) {
VerifierRule rule = (VerifierRule) ((VerifierMessage) o).getFaulty();
rulesThatHadErrors.add(rule.getName());
}
}
assertTrue(rulesThatHadErrors.remove("Incoherent patterns 8"));
assertTrue(rulesThatHadErrors.remove("Incoherent patterns 12"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
use of org.drools.verifier.data.VerifierReport in project drools by kiegroup.
the class IncoherentPatternsTest method testIncoherentPatternsInSubRule.
@Test
public void testIncoherentPatternsInSubRule() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("Patterns.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("PatternsTest.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Incoherent Patterns in rule possibility"));
Iterator<VerifierMessageBase> iter = result.getBySeverity(Severity.WARNING).iterator();
Set<String> rulesThatHadErrors = new HashSet<String>();
while (iter.hasNext()) {
Object o = iter.next();
if (o instanceof VerifierMessage) {
VerifierRule rule = (VerifierRule) ((VerifierMessage) o).getFaulty();
rulesThatHadErrors.add(rule.getName());
}
}
assertTrue(rulesThatHadErrors.remove("Incoherent patterns 1"));
assertTrue(rulesThatHadErrors.remove("Incoherent patterns 2"));
assertTrue(rulesThatHadErrors.remove("Incoherent patterns 7"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
use of org.drools.verifier.data.VerifierReport in project drools by kiegroup.
the class IncoherentRestrictionsTest method testIncoherentVariableRestrictionsInSubPatternImpossibleRange.
@Test
public void testIncoherentVariableRestrictionsInSubPatternImpossibleRange() 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 VariableRestrictions in pattern possibility, impossible range"));
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 6"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
Aggregations