"Do you activate the ruleflow-group before you insert the Car fact?"
No, I don't think so.
This is body of my test class:
public class CarKnowledgeBaseTest {
@Test
public void shouldObtainPriceWhereSalienceIsBigger() throws Exception {
//given
KnowledgeBase kbase = readKnowledgeBaseFromDrl();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
//when
Car car = new Car("red", "small");
Car car2 = new Car("red", "big");
ksession.insert(car);
ksession.insert(car2);
ksession.addEventListener(new DebugAgendaEventListener());
ksession.startProcess("com.car.test");
ksession.fireAllRules();
ksession.dispose();
//then
assertEquals(Integer.valueOf(2), car.getPrice());
assertEquals(Integer.valueOf(1), car2.getPrice());
}
private KnowledgeBase readKnowledgeBaseFromDrl() {
KnowledgeBuilder knowledgeBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
knowledgeBuilder.add(ResourceFactory.newClassPathResource("com/car/test/car.drl"),
ResourceType.DRL);
knowledgeBuilder.add(ResourceFactory.newClassPathResource("com/car/test/flow.rf"),
ResourceType.DRF);
if (knowledgeBuilder.hasErrors()) {
throw new
RuntimeException(knowledgeBuilder.getErrors().toString());
}
KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
return knowledgeBase;
}
}
--
View this message in context:
http://drools.46999.n3.nabble.com/Lock-on-active-and-ruleflow-group-tp323...
Sent from the Drools: User forum mailing list archive at
Nabble.com.