new ClassObjectType(Cheese.class));
From fromCe = new From(dataProvider);
fromCe.setResultPattern(pattern );
final FromNode from = new FromNode( 3,
dataProvider,
new MockTupleSource( 80 ),
new AlphaNodeFieldConstraint[]{constraint},
null,
true,
buildContext,
fromCe );
final MockLeftTupleSink sink = new MockLeftTupleSink( 5 );
from.addTupleSink( sink );
final Person person1 = new Person( "xxx1",
30 );
final FactHandle person1Handle = workingMemory.insert( person1 );
final LeftTuple tuple1 = new LeftTupleImpl( (DefaultFactHandle) person1Handle,
from,
true );
from.assertLeftTuple( tuple1,
context,
workingMemory );
// nothing should be asserted, as cheese1 is cheddar and we are filtering on stilton
assertEquals( 0,
sink.getAsserted().size() );
//Set cheese1 to stilton and it should now propagate
cheese1.setType( "stilton" );
final Person person2 = new Person( "xxx2",
30 );
final FactHandle person2Handle = workingMemory.insert( person2 );
final LeftTuple tuple2 = new LeftTupleImpl( (DefaultFactHandle) person2Handle,
from,
true );
from.assertLeftTuple( tuple2,
context,
workingMemory );
final List asserted = sink.getAsserted();
assertEquals( 1,
asserted.size() );
Tuple tuple = (Tuple) ((Object[]) asserted.get( 0 ))[0];
assertSame( person2,
tuple.toFactHandles()[0].getObject() );
assertSame( cheese1,
tuple.toFactHandles()[1].getObject() );
cheese2.setType( "stilton" );
final Person person3 = new Person( "xxx2",
30 );
final FactHandle person3Handle = workingMemory.insert( person3 );
final LeftTuple tuple3 = new LeftTupleImpl( (DefaultFactHandle) person3Handle,
from,
true );
from.assertLeftTuple( tuple3,
context,
workingMemory );
assertEquals( 3,
asserted.size() );