final Package pkg = builder.getPackage();
RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
ruleBase = SerializationHelper.serializeObject( ruleBase );
final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) ruleBase.newStatefulSession();
final Cheese stilton = new Cheese( "stilton",
7 );
final Cheese muzzarella = new Cheese( "muzzarella",
9 );
final int sum = stilton.getPrice() + muzzarella.getPrice();
final FactHandle stiltonHandle = workingMemory.insert( stilton );
final FactHandle muzzarellaHandle = workingMemory.insert( muzzarella );
workingMemory.fireAllRules();
assertEquals( sum,
stilton.getPrice() );
assertEquals( 1,
workingMemory.getObjectStore().size() );
assertNotNull( workingMemory.getObject( stiltonHandle ) );
assertNotNull( workingMemory.getFactHandle( stilton ) );
assertNull( workingMemory.getObject( muzzarellaHandle ) );
assertNull( workingMemory.getFactHandle( muzzarella ) );
}