when( constraint.isAllowedCachedRight( any( LeftTupleImpl.class ), any( ContextEntry.class ) )).thenReturn(true);
// assert tuple
final Cheese cheddar = new Cheese( "cheddar",
10 );
final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.insert( cheddar );
final LeftTupleImpl tuple1 = new LeftTupleImpl( f0,
this.node,
true );
this.node.assertLeftTuple( tuple1,
this.context,
this.workingMemory );
// no matching objects, so should propagate
assertLength( 1,
this.sink.getAsserted() );
assertLength( 0,
this.sink.getRetracted() );
assertEquals( new LeftTupleImpl( f0,
this.sink,
true ),
((Object[]) this.sink.getAsserted().get( 0 ))[0] );
// LeftTuple has no matches and has propagated, so should be in memory
assertEquals( 1,
this.memory.getLeftTupleMemory().size() );
// assert will match, so propagated tuple should be retracted
final Cheese brie = new Cheese( "brie",
10 );
final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.insert( brie );
this.node.assertObject( f1,
this.context,
this.workingMemory );
// check no as assertions, but should be one retraction
assertLength( 1,
this.sink.getAsserted() );
assertLength( 1,
this.sink.getRetracted() );
assertEquals( new LeftTupleImpl( f0,
this.sink,
true ),
((Object[]) this.sink.getRetracted().get( 0 ))[0] );
//LeftTuple is now matched and is not propagated, so should not be in memory
assertEquals( 0,
this.memory.getLeftTupleMemory().size() );
// assert tuple, will have matches, so no propagation
final DefaultFactHandle f2 = (DefaultFactHandle) this.workingMemory.insert( new Cheese( "gouda",
10 ) );
final LeftTupleImpl tuple2 = new LeftTupleImpl( f2,
this.node,
true );
this.node.assertLeftTuple( tuple2,