final Package pkg = builder.getPackage();
RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
ruleBase = SerializationHelper.serializeObject(ruleBase);
final WorkingMemory wm = ruleBase.newStatefulSession();
final List list = new ArrayList();
wm.setGlobal( "list", list );
final Cheese brie = new Cheese( "brie", 13 );
final Person bob = new Person( "bob" );
bob.setCheese( brie );
final Person mic = new Person( "mic" );
mic.setCheese( brie );
final Person mark = new Person( "mark" );
mark.setCheese( brie );
final FactHandle brieHandle = wm.insert( brie );
wm.insert( bob );
wm.insert( mic );
wm.insert( mark );
final DefaultAgenda agenda = (DefaultAgenda) wm.getAgenda();
final AgendaGroup group1 = agenda.getAgendaGroup( "group1" );
agenda.setFocus( group1 );
assertEquals( 3, group1.size() );
agenda.fireNextItem( null, 0, 0 );
assertEquals( 2, group1.size() );
wm.update( brieHandle, brie );
assertEquals( 2, group1.size() );
AgendaGroup group2 = agenda.getAgendaGroup( "group2" );
agenda.setFocus( group2 );
RuleFlowGroupImpl rfg = (RuleFlowGroupImpl) ((DefaultAgenda) wm.getAgenda()).getRuleFlowGroup( "ruleflow2" );
assertEquals( 3, rfg.size() );
agenda.activateRuleFlowGroup( "ruleflow2" );
agenda.fireNextItem( null, 0, 0 );
assertEquals( 2, rfg.size() );
wm.update( brieHandle, brie );
assertEquals( 2, group2.size() );
}