@Test
public void testAssertedAllowedThenRetract() throws FactException {
final MockEvalCondition eval = new MockEvalCondition( true );
// Create a test node that always returns false
final EvalConditionNode node = new EvalConditionNode( 1,
new MockTupleSource( 15 ),
eval,
buildContext );
final MockLeftTupleSink sink = new MockLeftTupleSink();
node.addTupleSink( sink );
// Create the Tuple
final DefaultFactHandle f0 = new DefaultFactHandle( 0,
"stilton" );
final LeftTupleImpl tuple0 = new LeftTupleImpl( f0,
sink,
true );
// Tuple should pass and propagate
node.assertLeftTuple( tuple0,
this.context,
this.workingMemory );
// we create and retract two tuples, checking the linkedtuples is null for JBRULES-246 "NPE on retract()"
// Create the Tuple
final DefaultFactHandle f1 = new DefaultFactHandle( 1,
"cheddar" );
final LeftTupleImpl tuple1 = new LeftTupleImpl( f1,
sink,
true );
// Tuple should pass and propagate
node.assertLeftTuple( tuple1,
this.context,
this.workingMemory );
// make sure assertions were propagated
assertEquals( 2,
sink.getAsserted().size() );
// Now test that the fact is retracted correctly
node.retractLeftTuple( tuple0,
this.context,
this.workingMemory );
// make sure retractions were propagated
assertEquals( 1,
sink.getRetracted().size() );
// Now test that the fact is retracted correctly
node.retractLeftTuple( tuple1,
this.context,
this.workingMemory );
// make sure retractions were propagated
assertEquals( 2,