Package org.drools

Examples of org.drools.StatelessSession


public class OppositePatternsTest extends OppositesBase {

    @Test
    public void testPatternsPossibilitiesOpposite() throws Exception {
        StatelessSession session = getStatelessSession( this.getClass().getResourceAsStream( "Patterns.drl" ) );

        session.setAgendaFilter( new RuleNameMatchesAgendaFilter( "Opposite Patterns" ) );

        Collection<Object> data = new ArrayList<Object>();

        Pattern pattern = VerifierComponentMockFactory.createPattern1();

        /*
         * Working pair
         */
        SubPattern pp1 = new SubPattern( pattern,
                                         0 );
        SubPattern pp2 = new SubPattern( pattern,
                                         1 );

        Restriction r1 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp1.add( r1 );

        Restriction r2 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp2.add( r2 );

        Restriction r3 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp1.add( r3 );

        Restriction r4 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp2.add( r4 );

        Opposites o1 = new Opposites( r1,
                                      r2 );
        Opposites o2 = new Opposites( r3,
                                      r4 );

        /*
         * Pair that doesn't work.
         */
        SubPattern pp3 = new SubPattern( pattern,
                                         2 );
        SubPattern pp4 = new SubPattern( pattern,
                                         3 );

        Restriction r5 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp3.add( r5 );

        Restriction r6 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp4.add( r6 );

        Restriction r7 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp3.add( r7 );

        Restriction r8 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp4.add( r8 );

        Opposites o3 = new Opposites( r5,
                                      r6 );

        data.add( r1 );
        data.add( r2 );
        data.add( r3 );
        data.add( r4 );
        data.add( r5 );
        data.add( r6 );
        data.add( r7 );
        data.add( r8 );
        data.add( pp1 );
        data.add( pp2 );
        data.add( pp3 );
        data.add( pp4 );
        data.add( o1 );
        data.add( o2 );
        data.add( o3 );

        StatelessSessionResult sessionResult = session.executeWithResults( data );

        Map<Cause, Set<Cause>> map = createOppositesMap( VerifierComponentType.SUB_PATTERN,
                                                         sessionResult.iterateObjects() );

        assertTrue( (TestBaseOld.causeMapContains(map,
View Full Code Here


        assertTrue(true);
    }

    @Test
    public void testSmallerOrEqual() throws Exception {
        StatelessSession session = getStatelessSession(this.getClass()
                .getResourceAsStream("rangeChecks/Dates.drl"));

        session.setAgendaFilter(new RuleNameMatchesAgendaFilter(
                "Range check for dates, if smaller than or equal is missing"));

        VerifierReport result = VerifierReportFactory.newVerifierReport();
        Collection<? extends Object> testData = getTestData(this.getClass()
                .getResourceAsStream("MissingRangesForDates.drl"), result
                .getVerifierData());

        session.setGlobal("result", result);

        StatelessSessionResult sessionResult = session
                .executeWithResults(testData);

        Iterator<Object> iter = sessionResult.iterateObjects();

        Set<String> rulesThatHadErrors = new HashSet<String>();
View Full Code Here

        }
    }

    @Test
    public void testGreaterOrEqual() throws Exception {
        StatelessSession session = getStatelessSession(this.getClass()
                .getResourceAsStream("rangeChecks/Dates.drl"));

        session.setAgendaFilter(new RuleNameMatchesAgendaFilter(
                "Range check for dates, if greater than or equal is missing"));

        VerifierReport result = VerifierReportFactory.newVerifierReport();
        Collection<? extends Object> testData = getTestData(this.getClass()
                .getResourceAsStream("MissingRangesForDates.drl"), result
                .getVerifierData());

        session.setGlobal("result", result);

        StatelessSessionResult sessionResult = session
                .executeWithResults(testData);

        Iterator<Object> iter = sessionResult.iterateObjects();

        Set<String> rulesThatHadErrors = new HashSet<String>();
View Full Code Here

        }
    }

    @Test
    public void testEqualAndGreaterThan() throws Exception {
        StatelessSession session = getStatelessSession(this.getClass()
                .getResourceAsStream("rangeChecks/Dates.drl"));

        session.setAgendaFilter(new RuleNameMatchesAgendaFilter(
                "Range check for dates, equal and greater than"));

        VerifierReport result = VerifierReportFactory.newVerifierReport();
        Collection<? extends Object> testData = getTestData(this.getClass()
                .getResourceAsStream("MissingRangesForDates.drl"), result
                .getVerifierData());

        session.setGlobal("result", result);

        StatelessSessionResult sessionResult = session
                .executeWithResults(testData);

        Iterator<Object> iter = sessionResult.iterateObjects();

        Set<String> rulesThatHadErrors = new HashSet<String>();
View Full Code Here

        }
    }

    @Test
    public void testEqualAndSmallerThan() throws Exception {
        StatelessSession session = getStatelessSession(this.getClass()
                .getResourceAsStream("rangeChecks/Dates.drl"));

        session.setAgendaFilter(new RuleNameMatchesAgendaFilter(
                "Range check for dates, equal and smaller than"));

        VerifierReport result = VerifierReportFactory.newVerifierReport();
        Collection<? extends Object> testData = getTestData(this.getClass()
                .getResourceAsStream("MissingRangesForDates.drl"), result
                .getVerifierData());

        session.setGlobal("result", result);

        StatelessSessionResult sessionResult = session
                .executeWithResults(testData);

        Iterator<Object> iter = sessionResult.iterateObjects();

        Set<String> rulesThatHadErrors = new HashSet<String>();
View Full Code Here

public class RangeCheckDoublesTest extends TestBaseOld {

    @Test
    public void testSmallerOrEqual() throws Exception {
        StatelessSession session = getStatelessSession(this.getClass()
                .getResourceAsStream("rangeChecks/Doubles.drl"));

        session
                .setAgendaFilter(new RuleNameMatchesAgendaFilter(
                        "Range check for doubles, if smaller than or equal is missing"));

        VerifierReport result = VerifierReportFactory.newVerifierReport();
        Collection<? extends Object> testData = getTestData(this.getClass()
                .getResourceAsStream("MissingRangesForDoubles.drl"), result
                .getVerifierData());

        session.setGlobal("result", result);

        StatelessSessionResult sessionResult = session
                .executeWithResults(testData);

        Iterator<Object> iter = sessionResult.iterateObjects();

        Set<String> rulesThatHadErrors = new HashSet<String>();
View Full Code Here

        }
    }

    @Test
    public void testGreaterOrEqual() throws Exception {
        StatelessSession session = getStatelessSession(this.getClass()
                .getResourceAsStream("rangeChecks/Doubles.drl"));

        session
                .setAgendaFilter(new RuleNameMatchesAgendaFilter(
                        "Range check for doubles, if greater than or equal is missing"));

        VerifierReport result = VerifierReportFactory.newVerifierReport();
        Collection<? extends Object> testData = getTestData(this.getClass()
                .getResourceAsStream("MissingRangesForDoubles.drl"), result
                .getVerifierData());

        session.setGlobal("result", result);

        StatelessSessionResult sessionResult = session
                .executeWithResults(testData);

        Iterator<Object> iter = sessionResult.iterateObjects();

        Set<String> rulesThatHadErrors = new HashSet<String>();
View Full Code Here

        }
    }

    @Test
    public void testEqualAndGreaterThan() throws Exception {
        StatelessSession session = getStatelessSession(this.getClass()
                .getResourceAsStream("rangeChecks/Doubles.drl"));

        session.setAgendaFilter(new RuleNameMatchesAgendaFilter(
                "Range check for doubles, equal and greater than"));

        VerifierReport result = VerifierReportFactory.newVerifierReport();
        Collection<? extends Object> testData = getTestData(this.getClass()
                .getResourceAsStream("MissingRangesForDoubles.drl"), result
                .getVerifierData());

        session.setGlobal("result", result);

        StatelessSessionResult sessionResult = session
                .executeWithResults(testData);

        Iterator<Object> iter = sessionResult.iterateObjects();

        Set<String> rulesThatHadErrors = new HashSet<String>();
View Full Code Here

        }
    }

    @Test
    public void testEqualAndSmallerThan() throws Exception {
        StatelessSession session = getStatelessSession(this.getClass()
                .getResourceAsStream("rangeChecks/Doubles.drl"));

        session.setAgendaFilter(new RuleNameMatchesAgendaFilter(
                "Range check for doubles, equal and smaller than"));

        VerifierReport result = VerifierReportFactory.newVerifierReport();
        Collection<? extends Object> testData = getTestData(this.getClass()
                .getResourceAsStream("MissingRangesForDoubles.drl"), result
                .getVerifierData());

        session.setGlobal("result", result);

        StatelessSessionResult sessionResult = session
                .executeWithResults(testData);

        Iterator<Object> iter = sessionResult.iterateObjects();

        Set<String> rulesThatHadErrors = new HashSet<String>();
View Full Code Here

public class IncoherentPatternsTest extends TestBaseOld {

    @Test
    public void testIncoherentPatternsInSubRule() throws Exception {
        StatelessSession session = getStatelessSession( this.getClass().getResourceAsStream( "Patterns.drl" ) );

        session.setAgendaFilter( new RuleNameMatchesAgendaFilter( "Incoherent Patterns in rule possibility" ) );

        VerifierReport result = VerifierReportFactory.newVerifierReport();
        Collection< ? extends Object> testData = getTestData( this.getClass().getResourceAsStream( "PatternsTest.drl" ),
                                                              result.getVerifierData() );

        session.setGlobal( "result",
                           result );

        session.executeWithResults( testData );

        Iterator<VerifierMessageBase> iter = result.getBySeverity( Severity.WARNING ).iterator();

        Set<String> rulesThatHadErrors = new HashSet<String>();
        while ( iter.hasNext() ) {
View Full Code Here

TOP

Related Classes of org.drools.StatelessSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.