use of org.drools.core.reteoo.CompositeObjectSinkAdapter in project drools by kiegroup.
the class IndexingTest method testBuildsIndexedAlphaNodes.
@Test(timeout = 10000)
public void testBuildsIndexedAlphaNodes() {
String drl = "";
drl += "package org.drools.compiler.test\n";
drl += "import org.drools.compiler.Person\n";
drl += "rule test1\n";
drl += "when\n";
drl += " Person(name == \"Mark\", age == 37)\n";
drl += " Person(name == \"Mark\", happy == true)\n";
drl += "then\n";
drl += "end\n";
KieBase kbase = loadKnowledgeBaseFromString(drl);
ObjectTypeNode otn = getObjectTypeNode(kbase, Person.class);
InternalWorkingMemory wm = ((StatefulKnowledgeSessionImpl) kbase.newKieSession());
AlphaNode alphaNode1 = (AlphaNode) otn.getObjectSinkPropagator().getSinks()[0];
CompositeObjectSinkAdapter sinkAdapter = (CompositeObjectSinkAdapter) alphaNode1.getObjectSinkPropagator();
ObjectSinkNodeList hashableSinks = sinkAdapter.getHashableSinks();
assertNotNull(hashableSinks);
assertEquals(2, hashableSinks.size());
AlphaNode alphaNode2 = (AlphaNode) alphaNode1.getObjectSinkPropagator().getSinks()[0];
assertSame(hashableSinks.getFirst(), alphaNode2);
AlphaNode alphaNode3 = (AlphaNode) alphaNode1.getObjectSinkPropagator().getSinks()[1];
assertSame(hashableSinks.getLast(), alphaNode3);
}
Aggregations