Search in sources :

Example 1 with DebugProcessEventListener

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);
}
Also used : DebugProcessEventListener(org.jbpm.test.listener.DebugProcessEventListener) HashMap(java.util.HashMap) IterableProcessEventListener(org.jbpm.test.listener.IterableProcessEventListener) ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 DebugProcessEventListener (org.jbpm.test.listener.DebugProcessEventListener)1 IterableProcessEventListener (org.jbpm.test.listener.IterableProcessEventListener)1 Test (org.junit.Test)1 KieSession (org.kie.api.runtime.KieSession)1 BZ (qa.tools.ikeeper.annotation.BZ)1