Package org.drools.core.reteoo.ReteooBuilder

Examples of org.drools.core.reteoo.ReteooBuilder.IdGenerator


        pctxFactory = ruleBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
    }

    @Test
    public void testScheduledActivation() throws Exception {
        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(),
                                                           0,
                                                           buildContext);
        final List data = new ArrayList();
View Full Code Here


                     data.size());
    }

    @Test
    public void testDoLoopScheduledActivation() throws Exception {
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();

        final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) 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(),
                                                           0,
                                                           buildContext);
        final List data = new ArrayList();
View Full Code Here

    }

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

        final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) 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(),
                                                           0,
                                                           buildContext);
View Full Code Here

        pctxFactory = ruleBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
    }

    @Test
    public void testAttach() throws Exception {
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();

        final Rete source = this.ruleBase.getRete();

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

        int id = idGenerator.getNextId();
        final ObjectTypeNode objectTypeNode = new ObjectTypeNode(id,
                                                                 this.entryPoint,
                                                                 objectType,
                                                                 buildContext);
View Full Code Here

                                                                                null,
                                                                                null,
                                                                                null);

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

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

        final Rete source = ruleBase.getRete();

        final EntryPointNode entryPoint = new EntryPointNode(0,
                                                             source,
                                                             buildContext);
        entryPoint.attach(buildContext);

        final ObjectTypeNode objectTypeNode = new ObjectTypeNode(idGenerator.getNextId(),
                                                                 entryPoint,
                                                                 new ClassObjectType(String.class),
                                                                 buildContext);

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

    }

    @Test
    public void testMemory() {
        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();

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

        final ObjectTypeNode objectTypeNode = new ObjectTypeNode(idGenerator.getNextId(),
                                                                 this.entryPoint,
                                                                 new ClassObjectType(String.class),
                                                                 buildContext);

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

    }

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

        ObjectTypeNode objectTypeNode = new ObjectTypeNode(idGenerator.getNextId(),
                                                           this.entryPoint,
                                                           new ClassObjectType(String.class),
                                                           buildContext);

        assertFalse(objectTypeNode.isAssignableFrom(new ClassObjectType(new Object().getClass())));
        assertFalse(objectTypeNode.isAssignableFrom(new ClassObjectType(new Integer(5).getClass())));
        assertTrue(objectTypeNode.isAssignableFrom(new ClassObjectType("string".getClass())));

        objectTypeNode = new ObjectTypeNode(idGenerator.getNextId(),
                                            this.entryPoint,
                                            new ClassObjectType(Object.class),
                                            buildContext);

        assertTrue(objectTypeNode.isAssignableFrom(new ClassObjectType(new Object().getClass())));
View Full Code Here

    }

    @Test
    public void testRetractObject() throws Exception {
        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();
        final PropagationContext context = pctxFactory.createPropagationContext(0,
                                                                                PropagationContext.INSERTION,
                                                                                null,
                                                                                null,
                                                                                null);

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

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

        final ObjectTypeNode objectTypeNode = new ObjectTypeNode(idGenerator.getNextId(),
                                                                 this.entryPoint,
                                                                 new ClassObjectType(String.class),
                                                                 buildContext);

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

                                                                                null,
                                                                                null,
                                                                                null);

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

        final Rete source = ruleBase.getRete();

        final EntryPointNode entryPoint = new EntryPointNode(0,
                                                             source,
                                                             buildContext);
        entryPoint.attach(buildContext);

        final ObjectTypeNode objectTypeNode = new ObjectTypeNode(idGenerator.getNextId(),
                                                                 entryPoint,
                                                                 new ClassObjectType(Person.class),
                                                                 buildContext);

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

    /**
     * Test auto-deactivation of RuleFlowGroup.
     */
    @Test
    public void testRuleFlowGroup4() {
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();
        final InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newStatefulSession();
        ;

        final InternalAgenda agenda = (InternalAgenda) workingMemory.getAgenda();

        // create rule0
        final Consequence consequence0 = new Consequence() {
            private static final long serialVersionUID = 510l;

            public void evaluate(KnowledgeHelper knowledgeHelper,
                                 WorkingMemory w) {
                // do nothing
            }

            public void readExternal(ObjectInput in) throws IOException,
                    ClassNotFoundException {

            }

            public void writeExternal(ObjectOutput out) throws IOException {

            }

            public String getName() {
                return "default";
            }
        };

        final Rule rule0 = new Rule("test-rule0");
        rule0.setAgendaGroup("rule-flow-group-0");
        rule0.setConsequence(consequence0);

        final RuleTerminalNode node0 = new RuleTerminalNode(idGenerator.getNextId(),
                                                            new MockTupleSource(idGenerator.getNextId()),
                                                            rule0,
                                                            rule0.getLhs(),
                                                            0,
                                                            buildContext);

View Full Code Here

TOP

Related Classes of org.drools.core.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.