final StatefulKnowledgeSessionImpl workingMemory = new StatefulKnowledgeSessionImpl(1, (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase());
InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
BuildContext buildContext = new BuildContext( kBase, kBase.getReteooBuilder().getIdGenerator() );
final JoinNode joinNode = new JoinNode(1, this.tupleSource,
this.objectSource, EmptyBetaConstraints.getInstance(), buildContext);
// Add the first tuple sink and assert a tuple and object
// The sink has no memory
final MockLeftTupleSink sink1 = new MockLeftTupleSink(2);
joinNode.addTupleSink(sink1);
final DefaultFactHandle f0 = new DefaultFactHandle(0, "string0");
final LeftTupleImpl tuple1 = new LeftTupleImpl(f0, this.node, true);
joinNode.assertLeftTuple(tuple1, this.context, workingMemory);
final String string1 = "string1";
final DefaultFactHandle string1Handle = new DefaultFactHandle(1, string1);
ModifyPreviousTuples modifyPreviousTuples = new ModifyPreviousTuples(null, null, new EntryPointNode() );
assertLength(0, sink1.getAsserted());
joinNode.modifyObject(string1Handle, modifyPreviousTuples, contextPassNothing, workingMemory);
assertLength(0, sink1.getAsserted());
joinNode.setRightDeclaredMask(EmptyBitMask.get());
joinNode.initInferredMask();
joinNode.modifyObject(string1Handle, modifyPreviousTuples, contextPass2And3, workingMemory);
assertLength(0, sink1.getAsserted());
joinNode.setRightDeclaredMask(new LongBitMask(9));
joinNode.initInferredMask();
joinNode.modifyObject(string1Handle, modifyPreviousTuples, contextPass2And3, workingMemory);
assertLength(0, sink1.getAsserted());
joinNode.setRightDeclaredMask(new LongBitMask(3));
joinNode.initInferredMask();
joinNode.modifyObject(string1Handle, modifyPreviousTuples, contextPass2And3, workingMemory);
assertLength(1, sink1.getAsserted());
joinNode.modifyObject(string1Handle, modifyPreviousTuples, contextPassAll, workingMemory);
assertLength(2, sink1.getAsserted());
}