use of org.drools.verifier.report.components.VerifierMessage 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.");
}
}
}
use of org.drools.verifier.report.components.VerifierMessage in project drools by kiegroup.
the class IncoherentRestrictionsTest method testIncoherentVariableRestrictionsInSubPattern.
@Test
public void testIncoherentVariableRestrictionsInSubPattern() 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"));
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 3"));
assertTrue(rulesThatHadErrors.remove("Incoherent restrictions 4"));
assertTrue(rulesThatHadErrors.remove("Incoherent restrictions 5"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
use of org.drools.verifier.report.components.VerifierMessage in project drools by kiegroup.
the class IncoherentRestrictionsTest method testIncoherentLiteralRestrictionsInSubPatternImpossibleRange.
@Test
public void testIncoherentLiteralRestrictionsInSubPatternImpossibleRange() 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 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 7"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
use of org.drools.verifier.report.components.VerifierMessage in project drools by kiegroup.
the class IncoherentRestrictionsTest method testIncoherentLiteralRestrictionsInSubPatternImpossibleEqualityLess.
@Test
public void testIncoherentLiteralRestrictionsInSubPatternImpossibleEqualityLess() 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 equality less or equal"));
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 9"));
assertTrue(rulesThatHadErrors.remove("Incoherent restrictions 11"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
use of org.drools.verifier.report.components.VerifierMessage in project drools by kiegroup.
the class IncoherentRestrictionsTest method testIncoherentLiteralRestrictionsInSubPattern.
@Test
public void testIncoherentLiteralRestrictionsInSubPattern() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("Restrictions.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(getClass().getResourceAsStream("RestrictionsTest.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Incoherent LiteralRestrictions in pattern possibility"));
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 1"));
assertTrue(rulesThatHadErrors.remove("Incoherent restrictions 2"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
Aggregations