Package org.drools.reteoo.ReteooBuilder

Examples of org.drools.reteoo.ReteooBuilder.IdGenerator


*/

public class SchedulerTest extends DroolsTestCase {
    public void testScheduledActivation() throws Exception {
        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();
        InternalWorkingMemory workingMemory = ( InternalWorkingMemory ) ruleBase.newStatefulSession();

        final Rule rule = new Rule( "test-rule" );
        final RuleTerminalNode node = new RuleTerminalNode( idGenerator.getNextId(),
                                                            new MockTupleSource( idGenerator.getNextId() ),
                                                            rule,
                                                            rule.getLhs() );
        final List data = new ArrayList();

        // add consequence
View Full Code Here


                      data.size() );
    }

    public void testDoLoopScheduledActivation() throws Exception {
        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();

        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
        final Agenda agenda = workingMemory.getAgenda();

        final Rule rule = new Rule( "test-rule" );
        final RuleTerminalNode node = new RuleTerminalNode( idGenerator.getNextId(),
                                                            new MockTupleSource( idGenerator.getNextId() ),
                                                            rule,
                                                            rule.getLhs() );
        final List data = new ArrayList();

        /* 1/10th of a second */
 
View Full Code Here

    }

    public void testNoLoopScheduledActivation() throws Exception {
        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();

        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
        final Agenda agenda = workingMemory.getAgenda();

        final Rule rule = new Rule( "test-rule" );
        final List data = new ArrayList();

        final RuleTerminalNode node = new RuleTerminalNode( idGenerator.getNextId(),
                                                            new MockTupleSource( idGenerator.getNextId() ),
                                                            rule,
                                                            rule.getLhs() );

        /* 1/10th of a second */
        final Duration duration = new Duration() {
View Full Code Here

                                                                       PropagationContext.ASSERTION,
                                                                       null,
                                                                       null );

        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();
        final InternalWorkingMemory workingMemory = ( InternalWorkingMemory ) ruleBase.newStatefulSession();               

        final LeftInputAdapterNode liaNode = new LeftInputAdapterNode( idGenerator.getNextId(),
                                                                       new MockObjectSource( idGenerator.getNextId() ));

        final MockTupleSink sink = new MockTupleSink();
        liaNode.addTupleSink( sink );

        //force liaNode to have memory
View Full Code Here

                                                                       PropagationContext.ASSERTION,
                                                                       null,
                                                                       null );

        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();
        final InternalWorkingMemory workingMemory = ( InternalWorkingMemory ) ruleBase.newStatefulSession();               

        final LeftInputAdapterNode liaNode = new LeftInputAdapterNode( idGenerator.getNextId(),
                                                                       new MockObjectSource( idGenerator.getNextId() ));
        //force liaNode to have memory
        final Field field = BaseNode.class.getDeclaredField( "hasMemory" );
        field.setAccessible( true );
        field.set( liaNode,
                   new Boolean( true ) );
View Full Code Here

public class ObjectTypeNodeTest extends DroolsTestCase {

    public void testAttach() throws Exception {
        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();

        final Rete source = new Rete( (InternalRuleBase)ruleBase);       

        final ObjectType objectType = new ClassObjectType( String.class );

        int id = idGenerator.getNextId();
        final ObjectTypeNode objectTypeNode = new ObjectTypeNode( id,
                                                                  objectType,
                                                                  source,
                                                                  3 );
View Full Code Here

                                                                       PropagationContext.ASSERTION,
                                                                       null,
                                                                       null );

        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();

        final ReteooWorkingMemory workingMemory = ( ReteooWorkingMemory ) ruleBase.newStatefulSession();

        final Rete source = ruleBase.getRete();

        final ObjectTypeNode objectTypeNode = new ObjectTypeNode( idGenerator.getNextId(),
                                                                  new ClassObjectType( String.class ),
                                                                  source,
                                                                  3 );

        final MockObjectSink sink = new MockObjectSink();
View Full Code Here

                      memory.size() );
    }

    public void testMemory() {
        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();  
       
        final ReteooWorkingMemory workingMemory = ( ReteooWorkingMemory ) ruleBase.newStatefulSession();

        final ObjectTypeNode objectTypeNode = new ObjectTypeNode( idGenerator.getNextId(),
                                                                  new ClassObjectType( String.class ),
                                                                  new Rete( (InternalRuleBase) ruleBase),
                                                                  3 );

        final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( objectTypeNode );
View Full Code Here

        assertNotNull( memory );
    }

    public void testMatches() {
        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();
        final Rete source = new Rete((InternalRuleBase) ruleBase);

        ObjectTypeNode objectTypeNode = new ObjectTypeNode( idGenerator.getNextId(),
                                                            new ClassObjectType( String.class ),
                                                            source,
                                                            3 );

        assertFalse( objectTypeNode.matches( new Object() ) );
        assertFalse( objectTypeNode.matches( new Integer( 5 ) ) );
        assertTrue( objectTypeNode.matches( "string" ) );

        objectTypeNode = new ObjectTypeNode( idGenerator.getNextId(),
                                             new ClassObjectType( Object.class ),
                                             source,
                                             3 );

        assertTrue( objectTypeNode.matches( new Object() ) );
View Full Code Here

    }

    public void testRetractObject() throws Exception {
        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();     
        final PropagationContext context = new PropagationContextImpl( 0,
                                                                       PropagationContext.ASSERTION,
                                                                       null,
                                                                       null );

        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory)ruleBase.newStatefulSession();

        final Rete source = new Rete((InternalRuleBase) ruleBase);

        final ObjectTypeNode objectTypeNode = new ObjectTypeNode( idGenerator.getNextId(),
                                                                  new ClassObjectType( String.class ),
                                                                  source,
                                                                  3 );

        final MockObjectSink sink = new MockObjectSink();
View Full Code Here

TOP

Related Classes of org.drools.reteoo.ReteooBuilder.IdGenerator

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.