use of org.drools.core.base.RuleNameMatchesAgendaFilter 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.core.base.RuleNameMatchesAgendaFilter 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.core.base.RuleNameMatchesAgendaFilter 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.");
}
}
}
use of org.drools.core.base.RuleNameMatchesAgendaFilter 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.core.base.RuleNameMatchesAgendaFilter in project drools by kiegroup.
the class RangeCheckIntegersTest method testSmallerOrEqual.
@Test
public void testSmallerOrEqual() 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, 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("Integer gap rule 4a"));
assertTrue(rulesThatHadErrors.remove("Integer gap rule 5a"));
if (!rulesThatHadErrors.isEmpty()) {
for (String string : rulesThatHadErrors) {
fail("Rule " + string + " caused an error.");
}
}
}
Aggregations