Search in sources :

Example 26 with Rete

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

the class Misc2Test method testFromEPDontRequireLeftInput.

@Test
public void testFromEPDontRequireLeftInput() {
    // DROOLS-1014
    String drl = "rule R when\n" + "    $s1 : String() from entry-point \"xxx\"\n" + "then\n" + "end\n";
    KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl);
    Rete rete = ((RuleBase) kbase).getRete();
    LeftInputAdapterNode liaNode = null;
    for (ObjectTypeNode otn : rete.getObjectTypeNodes()) {
        Class<?> otnType = ((ClassObjectType) otn.getObjectType()).getClassType();
        if (String.class == otnType) {
            assertEquals(1, otn.getObjectSinkPropagator().size());
        } else if (InitialFact.class.isAssignableFrom(otnType)) {
            assertEquals(0, otn.getObjectSinkPropagator().size());
        } else {
            fail("There shouldn't be other OTNs");
        }
    }
}
Also used : Rete(org.drools.core.reteoo.Rete) ClassObjectType(org.drools.core.base.ClassObjectType) KieBase(org.kie.api.KieBase) InitialFact(org.drools.core.InitialFact) ObjectTypeNode(org.drools.core.reteoo.ObjectTypeNode) FactWithString(org.drools.mvel.integrationtests.facts.FactWithString) RuleBase(org.drools.core.impl.RuleBase) LeftInputAdapterNode(org.drools.core.reteoo.LeftInputAdapterNode) Test(org.junit.Test)

Aggregations

Rete (org.drools.core.reteoo.Rete)26 ObjectTypeNode (org.drools.core.reteoo.ObjectTypeNode)20 Test (org.junit.Test)20 ClassObjectType (org.drools.core.base.ClassObjectType)11 KieBase (org.kie.api.KieBase)10 EntryPointNode (org.drools.core.reteoo.EntryPointNode)8 LeftInputAdapterNode (org.drools.core.reteoo.LeftInputAdapterNode)8 KieSession (org.kie.api.runtime.KieSession)8 ArrayList (java.util.ArrayList)7 StatefulKnowledgeSessionImpl (org.drools.kiesession.session.StatefulKnowledgeSessionImpl)7 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)6 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)6 MockObjectSink (org.drools.core.reteoo.MockObjectSink)6 FactHandle (org.kie.api.runtime.rule.FactHandle)6 KieHelper (org.kie.internal.utils.KieHelper)6 List (java.util.List)5 KnowledgeBaseImpl (org.drools.core.impl.KnowledgeBaseImpl)5 RuleBase (org.drools.core.impl.RuleBase)5 InternalKnowledgeBase (org.drools.kiesession.rulebase.InternalKnowledgeBase)5 LeftTupleSink (org.drools.core.reteoo.LeftTupleSink)4