setUp( JOIN_NODE );
// Initialise from n3
KieBaseConfiguration kconf = org.kie.internal.KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kconf.setOption( RuleEngineOption.PHREAK );
InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase(kconf);
StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newStatefulKnowledgeSession();
createSegmentMemory(n3, ksession);
BetaMemory bm = (BetaMemory) ksession.getNodeMemory( n1 );
assertNull(bm.getSegmentMemory());
bm = (BetaMemory) ksession.getNodeMemory( n3 );
assertEquals( 1, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n4 );
assertEquals( 2, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n5 );
assertEquals( 4, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n6 );
assertEquals( 8, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
// Initialise from n4
kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase(kconf);
ksession = (StatefulKnowledgeSessionImpl)kBase.newStatefulKnowledgeSession();
bm = createSegmentMemory( n4, ksession );
bm = (BetaMemory) ksession.getNodeMemory( n1 );
assertNull( bm.getSegmentMemory() );
bm = (BetaMemory) ksession.getNodeMemory( n3 );
assertEquals( 1, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n4 );
assertEquals( 2, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n5 );
assertEquals( 4, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n6 );
assertEquals(8, bm.getNodePosMaskBit());
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
// Initialise from n5
kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase(kconf);
ksession = (StatefulKnowledgeSessionImpl)kBase.newStatefulKnowledgeSession();
createSegmentMemory( n5, ksession );
bm = (BetaMemory) ksession.getNodeMemory( n1 );
assertNull(bm.getSegmentMemory());
bm = (BetaMemory) ksession.getNodeMemory( n3 );
assertEquals( 1, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n4 );
assertEquals( 2, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n5 );
assertEquals( 4, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n6 );
assertEquals( 8, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
// Initialise from n6
kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase(kconf);
ksession = (StatefulKnowledgeSessionImpl)kBase.newStatefulKnowledgeSession();
createSegmentMemory( n6, ksession );
bm = (BetaMemory) ksession.getNodeMemory( n1 );
assertNull( bm.getSegmentMemory() );
bm = (BetaMemory) ksession.getNodeMemory( n3 );
assertEquals( 1, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n4 );
assertEquals( 2, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n5 );
assertEquals( 4, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
bm = (BetaMemory) ksession.getNodeMemory( n6 );
assertEquals( 8, bm.getNodePosMaskBit() );
assertEquals( 15, bm.getSegmentMemory().getAllLinkedMaskTest() );
}