Package org.drools.reteoo

Examples of org.drools.reteoo.ReteooRuleBase


     * Test the use of the composite OR constraint.
     *
     * @throws IntrospectionException
     */
    public void testCompositeOrConstraint() {
        final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        final InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newStatefulSession();

        final ClassFieldReader extractor = store.getReader( Cheese.class,
                                                            "type",
                                                            getClass().getClassLoader() );

View Full Code Here


     * Test the use of the composite OR constraint.
     *
     * @throws IntrospectionException
     */
    public void testNestedCompositeConstraints() {
        final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        final InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newStatefulSession();

        final ClassFieldReader typeExtractor = store.getReader( Cheese.class,
                                                                "type",
                                                                getClass().getClassLoader() );

View Full Code Here

public class AgendaItemTest {
   
    @Test
    public void testAddition() {
        ReteooRuleBase rbase = ( ReteooRuleBase ) RuleBaseFactory.newRuleBase();
        StatefulSession wm = rbase.newStatefulSession();
       
        DefaultAgenda agenda = ( DefaultAgenda ) wm.getAgenda();
        AgendaItem item1 = agenda.createAgendaItem( null, 0, null, null );
        AgendaItem item2 = agenda.createAgendaItem( null, 0, null, null );
        AgendaItem item3 = agenda.createAgendaItem( null, 0, null, null );
View Full Code Here

        //agenda.createAgendaItem( tuple, salience, context, rtn )-
    }
   
    @Test
    public void testRemoval() {
        ReteooRuleBase rbase = ( ReteooRuleBase ) RuleBaseFactory.newRuleBase();
        StatefulSession wm = rbase.newStatefulSession();
       
        DefaultAgenda agenda = ( DefaultAgenda ) wm.getAgenda();
        AgendaItem item1 = agenda.createAgendaItem( null, 0, null, null );
        AgendaItem item2 = agenda.createAgendaItem( null, 0, null, null );
        AgendaItem item3 = agenda.createAgendaItem( null, 0, null, null );
View Full Code Here

        assertNull( item1.getBlocked() );       
    }   
   
    @Test
    public void testUnblockAll() {
        ReteooRuleBase rbase = ( ReteooRuleBase ) RuleBaseFactory.newRuleBase();
        StatefulSession wm = rbase.newStatefulSession();
       
        DefaultAgenda agenda = ( DefaultAgenda ) wm.getAgenda();
        AgendaItem item1 = agenda.createAgendaItem( null, 0, null, null );
        AgendaItem item2 = agenda.createAgendaItem( null, 0, null, null );
        AgendaItem item3 = agenda.createAgendaItem( null, 0, null, null );
View Full Code Here

        assertEquals( 0, item1.getBlocked().size() );             
    }       
   
    @Test
    public void testKnowledgeHelperUpdate() {
        ReteooRuleBase rbase = ( ReteooRuleBase ) RuleBaseFactory.newRuleBase();
        StatefulSession wm = rbase.newStatefulSession();
       
        DefaultAgenda agenda = ( DefaultAgenda ) wm.getAgenda();
        AgendaItem item1 = agenda.createAgendaItem( null, 0, null, null );
        AgendaItem item2 = agenda.createAgendaItem( null, 0, null, null );
        AgendaItem item3 = agenda.createAgendaItem( null, 0, null, null );
View Full Code Here

     * @see junit.framework.TestCase#setUp()
     */
    @Before
    public void setUp() throws Exception {
        this.builder = new ReteooRuleBuilder();
        this.rulebase = new ReteooRuleBase( "default" );
    }
View Full Code Here

        this.ruleBase.writeExternal( out );
    }

    public void readExternal(ObjectInput in) throws IOException,
                                            ClassNotFoundException {
        ruleBase = new ReteooRuleBase();
        ruleBase.readExternal( in );
    }
View Full Code Here

        pkgBuilder.addPackageFromDrl( new StringReader( str ) );
        assertTrue( "Should not have errors",
                           pkgBuilder.getErrors().isEmpty() );

        // Add once ...
        ReteooRuleBase rb = new ReteooRuleBase( "dummy" );
        rb.addPackage( pkgBuilder.getPackage() );

        // This one works
        List list = new ArrayList();
        StatefulSession session = rb.newStatefulSession();
        session.setGlobal( "list",
                           list );
        session.fireAllRules();
        assertEquals( 1,
                      list.size() );

        list.clear();
        // ... remove ...
        rb.removePackage( pkgBuilder.getPackage().getName() );
        rb.addPackage( pkgBuilder.getPackage() );
        session = rb.newStatefulSession();
        session.setGlobal( "list",
                           list );
        session.fireAllRules();
        assertEquals( 1,
                      list.size() );
View Full Code Here

        context.put( "TestCase",
                     testCase );

        RuleBaseConfiguration conf = new RuleBaseConfiguration();

        ReteooRuleBase rbase = new ReteooRuleBase( "ID",
                                                   conf );
        BuildContext buildContext = new BuildContext( rbase,
                                                      rbase.getReteooBuilder().getIdGenerator() );

        Rule rule = new Rule("rule1", "org.pkg1", null);
        org.drools.rule.Package pkg = new org.drools.rule.Package( "org.pkg1" );
        pkg.getDialectRuntimeRegistry().setDialectData( "mvel", new MVELDialectRuntimeData() );
        pkg.addRule( rule );
       
        buildContext.setRule( rule );       
       
        rbase.addPackage( pkg );
        context.put( BUILD_CONTEXT,
                     buildContext );
        context.put( "ClassFieldAccessorStore",
                     this.reteTesterHelper.getStore() );

        InternalWorkingMemory wm = (InternalWorkingMemory) rbase.newStatefulSession( true );
        context.put( WORKING_MEMORY,
                     wm );
        return context;
    }
View Full Code Here

TOP

Related Classes of org.drools.reteoo.ReteooRuleBase

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.