use of org.drools.verifier.data.VerifierReport in project drools by kiegroup.
the class ConditionalBranchDescrTest method testVerifier.
@Test
public void testVerifier() {
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
// Check that the builder works.
assertFalse(vBuilder.hasErrors());
assertEquals(0, vBuilder.getErrors().size());
Verifier verifier = vBuilder.newVerifier();
verifier.addResourcesToVerify(new ClassPathResource("ConditionalBranchDescrTest.drl", Verifier.class), ResourceType.DRL);
assertFalse(verifier.hasErrors());
assertEquals(0, verifier.getErrors().size());
boolean works = verifier.fireAnalysis();
assertTrue(works);
VerifierReport result = verifier.getResult();
assertNotNull(result);
// assertEquals( 0,
// result.getBySeverity( Severity.ERROR ).size() );
// assertEquals( 6,
// result.getBySeverity( Severity.WARNING ).size() );
// assertEquals( 1,
// result.getBySeverity( Severity.NOTE ).size() );
}
use of org.drools.verifier.data.VerifierReport in project drools by kiegroup.
the class PatternSolverDRLTest method testOrInsidePattern.
@Test
public void testOrInsidePattern() throws Exception {
StringBuffer rule = new StringBuffer();
rule.append("rule \"Test rule\" ");
rule.append(" when ");
rule.append(" customer : Customer( status > 30 && < 50 ) ");
rule.append(" order : OrderHeader( customer == customer , orderPriority == 3 || == 4 ) ");
rule.append(" then ");
rule.append(" order.setOrderDiscount( 6.0 ); ");
rule.append("end");
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(new ByteArrayInputStream(rule.toString().getBytes()), result.getVerifierData());
int patternCount = 0;
// the right amount of items.
for (Object o : testData) {
if (o instanceof SubPattern) {
SubPattern pp = (SubPattern) o;
if (pp.getItems().size() == 2) {
patternCount++;
}
}
}
assertEquals(3, patternCount);
}
use of org.drools.verifier.data.VerifierReport in project drools by kiegroup.
the class RangeCheckDatesTest method testEqualAndGreaterThan.
@Test
public void testEqualAndGreaterThan() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("rangeChecks/Dates.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("MissingRangesForDates.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Range check for dates, equal and greater than"));
Set<String> rulesThatHadErrors = new HashSet<String>();
for (Object o : session.getObjects()) {
if (o instanceof Gap) {
rulesThatHadErrors.add(((Gap) o).getRuleName());
}
// System.out.println(o);
}
assertTrue(rulesThatHadErrors.remove("Date gap rule 1"));
assertTrue(rulesThatHadErrors.remove("Date gap rule 7b"));
assertTrue(rulesThatHadErrors.remove("Date gap rule 3"));
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 RangeCheckDatesTest method testGreaterOrEqual.
@Test
public void testGreaterOrEqual() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("rangeChecks/Dates.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("MissingRangesForDates.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Range check for dates, if greater than or equal is missing"));
Set<String> rulesThatHadErrors = new HashSet<String>();
for (Object o : session.getObjects()) {
if (o instanceof Gap) {
rulesThatHadErrors.add(((Gap) o).getRuleName());
}
// System.out.println(o);
}
assertTrue(rulesThatHadErrors.remove("Date gap rule 4b"));
assertTrue(rulesThatHadErrors.remove("Date gap rule 5b"));
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 RangeCheckDatesTest method testSmallerOrEqual.
@Test
public void testSmallerOrEqual() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("rangeChecks/Dates.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("MissingRangesForDates.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Range check for dates, if smaller than or equal is missing"));
Set<String> rulesThatHadErrors = new HashSet<String>();
for (Object o : session.getObjects()) {
if (o instanceof Gap) {
rulesThatHadErrors.add(((Gap) o).getRuleName());
}
// System.out.println(o);
}
assertTrue(rulesThatHadErrors.remove("Date gap rule 4a"));
assertTrue(rulesThatHadErrors.remove("Date gap rule 5a"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
Aggregations