@Test public void testAllLinkedInWithNotNodesOnly() { setUp( NOT_NODE ); assertEquals( NotNode.class, n3.getClass() ); // make sure it created NotNodes KieBaseConfiguration kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase(kconf); StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession(); BetaMemory bm = (BetaMemory) ksession.getNodeMemory( n3 ); createSegmentMemory( n3, ksession ); assertTrue( bm.getSegmentMemory().isSegmentLinked() ); // not nodes start off linked DefaultFactHandle f1 = (DefaultFactHandle) ksession.insert( "test1" ); // unlinked after first assertion n3.assertObject( f1, context, ksession ); // this doesn't unlink on the assertObject, as the node's memory must be processed. So use the helper method the main network evaluator uses. PhreakNotNode.unlinkNotNodeOnRightInsert( (NotNode) n3, bm, ksession ); assertFalse( bm.getSegmentMemory().isSegmentLinked() ); n3.retractRightTuple( f1.getFirstRightTuple(), context, ksession ); assertTrue( bm.getSegmentMemory().isSegmentLinked() ); //assertFalse( bm.getSegmentMemory().isSigmentLinked() ); // check retraction unlinks again }
@Test public void testConstraintPropagations() throws Exception { when( constraint.isAllowedCachedLeft( any( ContextEntry.class ), any( InternalFactHandle.class ) ) ).thenReturn( false ); when( constraint.isAllowedCachedRight( any( LeftTupleImpl.class ), any( ContextEntry.class ) ) ).thenReturn( false ); // assert first right object final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory .insert( "test0" ); this.node.assertObject( f0, this.context, this.workingMemory ); // assert tuple, should add left memory should be 2 final DefaultFactHandle f1 = new DefaultFactHandle( 1, "cheese" ); final LeftTupleImpl tuple1 = new LeftTupleImpl( f1, this.node, true ); this.node.assertLeftTuple( tuple1, this.context, this.workingMemory ); // Should be no assertions assertLength( 0, this.sink.getAsserted() ); this.node.retractRightTuple( f0.getFirstRightTuple(), this.context, this.workingMemory ); assertLength( 0, this.sink.getRetracted() ); }
this.sink.getAsserted().size() ); assertEquals( new LeftTupleImpl( tuple1, f0.getFirstRightTuple(), this.sink, true ), ( (Object[]) this.sink.getAsserted().get( 0 ) )[0] ); assertEquals( new LeftTupleImpl( tuple2, f0.getFirstRightTuple(), this.sink, true ), ( (Object[]) this.sink.getAsserted().get( 1 ) )[0] ); .getFirstRightTuple(), this.sink, true ) ) ); assertTrue( tuples.contains( new LeftTupleImpl( tuple2, f3 .getFirstRightTuple(), this.sink, true ) ) );
.getNodeMemory( this.node ); assertTrue( memory.getRightTupleMemory().contains( f0.getFirstRightTuple() ) ); this.node.retractRightTuple( f0.getFirstRightTuple(), this.context, this.workingMemory ); .getFirstRightTuple(), this.sink, true ) ) ); assertTrue( tuples.contains( new LeftTupleImpl( tuple1, f0 .getFirstRightTuple(), this.sink, true ) ) ); f0.getFirstRightTuple() ) ); .getFirstRightTuple(), this.sink, true ) ) ); assertTrue( tuples.contains( new LeftTupleImpl( tuple2, f4 .getFirstRightTuple(), this.sink, true ) ) );
n2.retractRightTuple( f2.getFirstRightTuple(), context, wm ); assertFalse( rtn1Rs.isRuleLinked() ); assertFalse( rtn2Rs.isRuleLinked() );
n2.retractRightTuple( f2.getFirstRightTuple(), context, wm ); assertFalse( rtn1Rs.isRuleLinked() ); assertFalse( rtn2Rs.isRuleLinked() );
this.memory.getRightTupleMemory().size() ); assertEquals( new LeftTupleImpl( tuple0, f0.getFirstRightTuple(), this.sink, true ), ( (Object[]) this.sink.getAsserted().get( 0 ) )[0] );