any( InternalFactHandle.class ) ) ).thenReturn( true );
when( constraint.isAllowedCachedRight( any( LeftTupleImpl.class ),
any( ContextEntry.class ) ) ).thenReturn( true );
// 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 );
assertEquals( 1,
this.sink.getAsserted().size() );
assertEquals( new LeftTupleImpl( tuple1, f0.getFirstRightTuple(), this.sink,
true ),
( (Object[]) this.sink.getAsserted().get( 0 ) )[0] );
final DefaultFactHandle f2 = new DefaultFactHandle( 2, "cheese" );
final LeftTupleImpl tuple2 = new LeftTupleImpl( f2, this.node, true );
this.node.assertLeftTuple( tuple2,
this.context,
this.workingMemory );
assertEquals( 2,
this.sink.getAsserted().size() );
assertEquals( new LeftTupleImpl( tuple2, f0.getFirstRightTuple(), this.sink,
true ),
( (Object[]) this.sink.getAsserted().get( 1 ) )[0] );
final DefaultFactHandle f3 = (DefaultFactHandle) this.workingMemory
.insert( "test2" );
this.node.assertObject( f3,
this.context,
this.workingMemory );
assertEquals( 4,
this.sink.getAsserted().size() );
final List tuples = new ArrayList();
tuples.add( ( (Object[]) this.sink.getAsserted().get( 2 ) )[0] );
tuples.add( ( (Object[]) this.sink.getAsserted().get( 3 ) )[0] );
assertTrue( tuples.contains( new LeftTupleImpl( tuple1, f3
.getFirstRightTuple(), this.sink, true ) ) );
assertTrue( tuples.contains( new LeftTupleImpl( tuple2, f3
.getFirstRightTuple(), this.sink, true ) ) );
}