use of org.jbpm.test.listener.DebugProcessEventListener in project jbpm by kiegroup.
the class MultipleInstancesSubProcessTest method testMultipleInstances.
@BZ("802721")
@Test(timeout = 30000)
public void testMultipleInstances() {
KieSession kieSession = createKSession(MULTIPLE_INSTANCES);
IterableProcessEventListener eventListener = new IterableProcessEventListener();
kieSession.addEventListener(eventListener);
kieSession.addEventListener(new DebugProcessEventListener());
List<String> items = new ArrayList<String>();
items.add("breakfast");
items.add("lunch");
items.add("dinner");
Map<String, Object> params = new HashMap<String, Object>();
params.put("list", items);
kieSession.execute((Command<?>) getCommands().newStartProcess(MULTIPLE_INSTANCES_ID, params));
assertChangedVariable(eventListener, "list", null, items);
assertProcessStarted(eventListener, MULTIPLE_INSTANCES_ID);
assertNextNode(eventListener, "start");
assertNextNode(eventListener, "script");
assertTriggered(eventListener, "multipleInstances");
// collection is passed to multiple-instances node
for (String str : items) {
assertChangedMultipleInstancesVariable(eventListener, "listItem", null, str);
}
// multiple-instances node is processed for every collection item
for (String str : items) {
assertNextNode(eventListener, "innerStart");
assertTriggered(eventListener, "innerScript");
assertChangedMultipleInstancesVariable(eventListener, "listItem", str, str + "-eaten");
assertLeft(eventListener, "innerScript");
assertNextNode(eventListener, "innerEnd");
}
assertLeft(eventListener, "multipleInstances");
assertNextNode(eventListener, "end");
assertProcessCompleted(eventListener, MULTIPLE_INSTANCES_ID);
}
Aggregations