Search in sources :

Example 11 with RuleNameMatchesAgendaFilter

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.");
        }
    }
}
Also used : RuleNameMatchesAgendaFilter(org.drools.core.base.RuleNameMatchesAgendaFilter) VerifierReport(org.drools.verifier.data.VerifierReport) Gap(org.drools.verifier.report.components.Gap) StatelessKieSession(org.kie.api.runtime.StatelessKieSession) KieSession(org.kie.api.runtime.KieSession) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 12 with RuleNameMatchesAgendaFilter

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.");
        }
    }
}
Also used : RuleNameMatchesAgendaFilter(org.drools.core.base.RuleNameMatchesAgendaFilter) VerifierReport(org.drools.verifier.data.VerifierReport) Gap(org.drools.verifier.report.components.Gap) StatelessKieSession(org.kie.api.runtime.StatelessKieSession) KieSession(org.kie.api.runtime.KieSession) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with RuleNameMatchesAgendaFilter

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.");
        }
    }
}
Also used : RuleNameMatchesAgendaFilter(org.drools.core.base.RuleNameMatchesAgendaFilter) VerifierReport(org.drools.verifier.data.VerifierReport) Gap(org.drools.verifier.report.components.Gap) StatelessKieSession(org.kie.api.runtime.StatelessKieSession) KieSession(org.kie.api.runtime.KieSession) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 14 with RuleNameMatchesAgendaFilter

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.");
        }
    }
}
Also used : RuleNameMatchesAgendaFilter(org.drools.core.base.RuleNameMatchesAgendaFilter) VerifierReport(org.drools.verifier.data.VerifierReport) Gap(org.drools.verifier.report.components.Gap) KieSession(org.kie.api.runtime.KieSession) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with RuleNameMatchesAgendaFilter

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.");
        }
    }
}
Also used : RuleNameMatchesAgendaFilter(org.drools.core.base.RuleNameMatchesAgendaFilter) VerifierReport(org.drools.verifier.data.VerifierReport) Gap(org.drools.verifier.report.components.Gap) KieSession(org.kie.api.runtime.KieSession) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

RuleNameMatchesAgendaFilter (org.drools.core.base.RuleNameMatchesAgendaFilter)58 Test (org.junit.Test)58 KieSession (org.kie.api.runtime.KieSession)56 VerifierReport (org.drools.verifier.data.VerifierReport)45 HashSet (java.util.HashSet)29 VerifierMessageBase (org.drools.verifier.report.components.VerifierMessageBase)27 ArrayList (java.util.ArrayList)25 VerifierMessage (org.drools.verifier.report.components.VerifierMessage)25 Pattern (org.drools.verifier.components.Pattern)17 Cause (org.drools.verifier.report.components.Cause)17 VerifierRule (org.drools.verifier.components.VerifierRule)12 Gap (org.drools.verifier.report.components.Gap)12 Set (java.util.Set)11 LiteralRestriction (org.drools.verifier.components.LiteralRestriction)8 VariableRestriction (org.drools.verifier.components.VariableRestriction)5 StatelessKieSession (org.kie.api.runtime.StatelessKieSession)4 InputStream (java.io.InputStream)2 Field (java.lang.reflect.Field)2 HashMap (java.util.HashMap)2 List (java.util.List)2