use of com.salaboy.model.Car in project jBPM5-Developer-Guide by Salaboy.
the class GoodOldIntegrationPatterns method statelessDecorationTest.
@Test
public void statelessDecorationTest() {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(new ClassPathResource("good_old_patterns/process-stateless-rule-evaluation.bpmn"), ResourceType.BPMN2);
if (kbuilder.hasErrors()) {
for (KnowledgeBuilderError error : kbuilder.getErrors()) {
System.out.println(">>> Error:" + error.getMessage());
}
fail(">>> Knowledge couldn't be parsed! ");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ksession.getWorkItemManager().registerWorkItemHandler("Rank Car", new RankCarWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Define Car Price", new DefineCarPriceWorkItemHandler());
Car car = new Car("AUDI 78", new Date(), 5, "manual", "gas", 285, 15000);
Map<String, Object> params = new HashMap<String, Object>();
params.put("car", car);
ProcessInstance processInstance = ksession.createProcessInstance("com.salaboy.process.stateless-rules-decoration", params);
assertEquals(processInstance.getState(), ProcessInstance.STATE_PENDING);
ksession.startProcessInstance(processInstance.getId());
System.out.println("Car : " + car);
}
Aggregations