ResourceType.DRL );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession kSession = createKnowledgeSession(kbase);
Father abraham = new Father("abraham");
Father bart = new Father("bart");
Collection<Object> youngestFathers;
bart.setFather(abraham);
FactHandle abrahamHandle = kSession.insert(abraham);
FactHandle bartHandle = kSession.insert(bart);
kSession.fireAllRules();
youngestFathers = kSession.getObjects(
new ClassObjectFilter(YoungestFather.class));
assertEquals(1, youngestFathers.size());
assertEquals(bart, ((YoungestFather) youngestFathers.iterator().next()).getMan());
Father homer = new Father("homer");
FactHandle homerHandle = kSession.insert(homer);
homer.setFather(abraham);
// If we do kSession.update(homerHandle, homer) here instead of after bart.setFather(homer) it works
// But in some use cases we cannot do this because fact fields are actually called
// while the facts are in an invalid temporary state
bart.setFather(homer);
// Late update call for homer, after bart has been changed too, but before fireAllRules