"then\n" +
" list.add($conversation);\n" +
"end\n";
KnowledgeBase kbase = loadKnowledgeBaseFromString(str);
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
List<Conversation> conversations = new ArrayList<Conversation>();
ksession.setGlobal("list", conversations);
Conversation c0 = new Conversation(0, "Fusco", 2);
Conversation c1 = new Conversation(1, "Fusco", 3);
Conversation c2 = new Conversation(2, "Fusco", 4);
FactHandle fh0 = ksession.insert(c0);
FactHandle fh1 = ksession.insert(c1);
FactHandle fh2 = ksession.insert(c2);
ksession.fireAllRules();
assertEquals(1, conversations.size());
conversations.clear();
c2.setTimeslot(0);
ksession.update(fh2, c2);
ksession.fireAllRules();
c2.setTimeslot(4);
ksession.update(fh2, c2);
ksession.fireAllRules();
conversations.clear();
c0.setTimeslot(3);
ksession.update(fh0, c0);
ksession.fireAllRules();
c0.setTimeslot(2);
ksession.update(fh0, c0);
ksession.fireAllRules();
conversations.clear();
c2.setTimeslot(1);
ksession.update(fh2, c2);
ksession.fireAllRules();
assertEquals(1, conversations.size());
}