use of org.drools.verifier.data.VerifierReport in project drools by kiegroup.
the class RangeCheckDoublesTest method testGreaterOrEqual.
@Test
public void testGreaterOrEqual() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("rangeChecks/Doubles.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("MissingRangesForDoubles.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Range check for doubles, 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("Double gap rule 4b"));
assertTrue(rulesThatHadErrors.remove("Double 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 RangeCheckDoublesTest method testSmallerOrEqual.
@Test
public void testSmallerOrEqual() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("rangeChecks/Doubles.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("MissingRangesForDoubles.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Range check for doubles, 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("Double gap rule 4a"));
assertTrue(rulesThatHadErrors.remove("Double gap rule 5a"));
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 RangeCheckDoublesTest method testEqualAndSmallerThan.
@Test
public void testEqualAndSmallerThan() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("rangeChecks/Doubles.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("MissingRangesForDoubles.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Range check for doubles, equal and smaller 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("Double gap rule 1"));
assertTrue(rulesThatHadErrors.remove("Double gap rule 6b"));
assertTrue(rulesThatHadErrors.remove("Double gap rule 2"));
assertTrue(rulesThatHadErrors.remove("Double gap rule 9a"));
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 RangeCheckIntegersTest method testEqualAndSmallerThan.
@Test
public void testEqualAndSmallerThan() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("rangeChecks/Integers.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("MissingRangesForInts.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Range check for integers, equal and smaller 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("Integer gap rule 1"));
assertTrue(rulesThatHadErrors.remove("Integer gap rule 6b"));
assertTrue(rulesThatHadErrors.remove("Integer gap rule 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 RangeCheckIntegersTest method testEqualAndGreaterThan.
@Test
public void testEqualAndGreaterThan() throws Exception {
KieSession session = getStatelessKieSession(this.getClass().getResourceAsStream("rangeChecks/Integers.drl"));
VerifierReport result = VerifierReportFactory.newVerifierReport();
Collection<? extends Object> testData = getTestData(this.getClass().getResourceAsStream("MissingRangesForInts.drl"), result.getVerifierData());
session.setGlobal("result", result);
for (Object o : testData) {
session.insert(o);
}
session.fireAllRules(new RuleNameMatchesAgendaFilter("Range check for integers, 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("Integer gap rule 1"));
assertTrue(rulesThatHadErrors.remove("Integer gap rule 7b"));
assertTrue(rulesThatHadErrors.remove("Integer gap rule 3"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
Aggregations