kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );
List<String> results = new ArrayList<String>();
ksession.setGlobal( "results",
results );
ksession.insert( new Move( 1,
2 ) );
ksession.insert( new Move( 2,
3 ) );
Win win2 = new Win( 2 );
Win win3 = new Win( 3 );
ksession.fireAllRules();
assertEquals( 2,
results.size() );
assertTrue( results.contains( win2 ) );
assertTrue( results.contains( win3 ) );
ksession.dispose();
ksession = createKnowledgeSession( kbase );
results = new ArrayList<String>();
ksession.setGlobal( "results",
results );
// reverse the order of the inserts
ksession.insert( new Move( 2,
3 ) );
ksession.insert( new Move( 1,
2 ) );
ksession.fireAllRules();
assertEquals( 2,
results.size() );