Search in sources :

Example 11 with MockObjectSink

use of org.drools.core.reteoo.MockObjectSink in project drools by kiegroup.

the class ReteTest method testIsShadowed.

@Test
public void testIsShadowed() {
    StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl) kBase.newKieSession();
    // Create a Rete network with ObjectTypeNodes for List, Collection and ArrayList
    final Rete rete = kBase.getRete();
    final ObjectTypeNode objectTypeNode = new ObjectTypeNode(1, this.entryPoint, new ClassObjectType(Cheese.class), buildContext);
    objectTypeNode.attach(buildContext);
    final MockObjectSink sink1 = new MockObjectSink();
    objectTypeNode.addObjectSink(sink1);
    // There are no String ObjectTypeNodes, make sure its not propagated
    final Cheese cheese = new Cheese("brie", 15);
    final DefaultFactHandle h1 = new DefaultFactHandle(1, cheese);
    rete.assertObject(h1, pctxFactory.createPropagationContext(0, PropagationContext.Type.INSERTION, null, null, null), ksession);
    ksession.fireAllRules();
    final Object[] results = (Object[]) sink1.getAsserted().get(0);
}
Also used : Rete(org.drools.core.reteoo.Rete) DefaultFactHandle(org.drools.core.common.DefaultFactHandle) ClassObjectType(org.drools.core.base.ClassObjectType) StatefulKnowledgeSessionImpl(org.drools.kiesession.session.StatefulKnowledgeSessionImpl) ObjectTypeNode(org.drools.core.reteoo.ObjectTypeNode) Cheese(org.drools.core.test.model.Cheese) MockObjectSink(org.drools.core.reteoo.MockObjectSink) Test(org.junit.Test)

Aggregations

MockObjectSink (org.drools.core.reteoo.MockObjectSink)11 Test (org.junit.Test)11 StatefulKnowledgeSessionImpl (org.drools.kiesession.session.StatefulKnowledgeSessionImpl)10 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)9 ClassObjectType (org.drools.core.base.ClassObjectType)8 ObjectTypeNode (org.drools.core.reteoo.ObjectTypeNode)8 Rete (org.drools.core.reteoo.Rete)6 BuildContext (org.drools.core.reteoo.builder.BuildContext)5 InternalKnowledgeBase (org.drools.kiesession.rulebase.InternalKnowledgeBase)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 PropagationContextFactory (org.drools.core.common.PropagationContextFactory)3 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)3 AlphaNode (org.drools.core.reteoo.AlphaNode)3 AlphaNodeFieldConstraint (org.drools.core.spi.AlphaNodeFieldConstraint)3 PropagationContext (org.drools.core.spi.PropagationContext)3 Cheese (org.drools.mvel.model.Cheese)3 MockObjectSource (org.drools.mvel.model.MockObjectSource)3 ClassObjectTypeConf (org.drools.core.reteoo.ClassObjectTypeConf)2 EntryPointNode (org.drools.core.reteoo.EntryPointNode)2