final DefaultFactHandle f0 = new DefaultFactHandle( 0,
cheddar );
// check alpha memory is empty
final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( alphaNode );
assertEquals( 0,
memory.size() );
// object should assert as it passes text
alphaNode.assertObject( f0,
context,
workingMemory );
assertEquals( 0,
memory.size() );
final DefaultFactHandle f1 = new DefaultFactHandle( 1,
new Cheese( "brie",
10 ) );
// object should NOT retract as it doesn't exist
alphaNode.retractObject( f1,
context,
workingMemory );
// without memory, it will always propagate a retract
assertLength( 0,
sink.getRetracted() );
assertEquals( 0,
memory.size() );
assertFalse( "Should not contain 'cheddar handle'",
memory.contains( f0 ) );
// object should retract as it does exist
alphaNode.retractObject( f0,
context,
workingMemory );
assertLength( 1,
sink.getRetracted() );
assertEquals( 0,
memory.size() );
final Object[] list = (Object[]) sink.getRetracted().get( 0 );
assertSame( f0,
list[0] );
}