final List list = new ArrayList();
workingMemory.setGlobal( "list",
list );
final FactTemplate cheese = pkg.getFactTemplate( "Cheese" );
final Fact stilton = cheese.createFact( 0 );
stilton.setFieldValue( "name",
"stilton" );
stilton.setFieldValue( "price",
new Integer( 100 ) );
InternalFactHandle stiltonHandle = (InternalFactHandle) workingMemory.insert( stilton );
// TODO does not work for facts now. adding equals(object) to it.
// workingMemory = SerializationHelper.serializeObject(workingMemory);
workingMemory.fireAllRules();
assertEquals( 1,
((List) workingMemory.getGlobal( "list" )).size() );
assertEquals( stilton,
((List) workingMemory.getGlobal( "list" )).get( 0 ) );
final Fact fact = (Fact) ((List) workingMemory.getGlobal( "list" )).get( 0 );
assertEquals( stilton,
fact );
assertEquals( new Integer( 200 ),
fact.getFieldValue( "price" ) );
assertEquals( -1,
stiltonHandle.getId() );
}