Search in sources :

Example 1 with TrackedEvent

use of org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent in project jbpm by kiegroup.

the class IterableListenerAssert method assertProcessCompleted.

/**
 * Asserts that the process was completed
 *
 * @param it        listener that listened to the process
 * @param processId id of the process
 */
public static void assertProcessCompleted(IterableProcessEventListener it, String processId) {
    TrackedEvent event = getEvent(it);
    Assertions.assertThat(event.getMethod()).isEqualTo(BEFORE_COMPLETED);
    CachedProcessCompletedEvent orig = event.getEvent();
    Assertions.assertThat(orig.getProcessId()).isEqualTo(processId);
}
Also used : TrackedEvent(org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent) CachedProcessCompletedEvent(org.jbpm.test.listener.IterableProcessEventListener.CachedProcessCompletedEvent)

Example 2 with TrackedEvent

use of org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent in project jbpm by kiegroup.

the class IterableListenerAssert method assertMultipleVariablesChanged.

/**
 * When multiple variables are initialized order might be different on
 * different JVMs.
 *
 * @param it        listener that listened to the process
 * @param variables names of changed variables
 */
public static void assertMultipleVariablesChanged(IterableProcessEventListener it, String... variables) {
    for (int i = 0; i < variables.length; i++) {
        TrackedEvent event = getEvent(it);
        Assertions.assertThat(event.getMethod()).isEqualTo(BEFORE_VARIABLE);
        ProcessVariableChangedEvent orig = event.getEvent();
        boolean found = false;
        String name = null;
        for (String str : variables) {
            found = orig.getVariableId().equals(str);
            name = str;
            if (found) {
                break;
            }
        }
        Assertions.assertThat(found).isTrue();
        event = it.next();
        Assertions.assertThat(event.getMethod()).isEqualTo(AFTER_VARIABLE);
        orig = event.getEvent();
        Assertions.assertThat(orig.getVariableId().equals(name)).isTrue();
    }
}
Also used : ProcessVariableChangedEvent(org.kie.api.event.process.ProcessVariableChangedEvent) TrackedEvent(org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent)

Example 3 with TrackedEvent

use of org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent in project jbpm by kiegroup.

the class IterableListenerAssert method assertProcessStarted.

/**
 * Asserts that the process was started
 *
 * @param it        listener that listened to the process
 * @param processId id of the process
 */
public static void assertProcessStarted(IterableProcessEventListener it, String processId) {
    TrackedEvent event = getEvent(it);
    Assertions.assertThat(event.getMethod()).isEqualTo(BEFORE_STARTED);
    CachedProcessStartedEvent orig = event.getEvent();
    Assertions.assertThat(orig.getProcessId()).isEqualTo(processId);
}
Also used : TrackedEvent(org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent) CachedProcessStartedEvent(org.jbpm.test.listener.IterableProcessEventListener.CachedProcessStartedEvent)

Example 4 with TrackedEvent

use of org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent in project jbpm by kiegroup.

the class IterableListenerAssert method assertLeft.

/**
 * Asserts that the node with the given name was left
 *
 * @param it       listener that listened to the process
 * @param nodeName name of the node that is expected to be left
 */
public static void assertLeft(IterableProcessEventListener it, String nodeName) {
    TrackedEvent event = getEvent(it);
    Assertions.assertThat(event.getMethod()).isEqualTo(BEFORE_LEFT);
    CachedProcessNodeLeftEvent orig = event.getEvent();
    Assertions.assertThat(orig.getNodeName()).isEqualTo(nodeName);
}
Also used : TrackedEvent(org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent) CachedProcessNodeLeftEvent(org.jbpm.test.listener.IterableProcessEventListener.CachedProcessNodeLeftEvent)

Example 5 with TrackedEvent

use of org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent in project jbpm by kiegroup.

the class IterableListenerAssert method assertTriggered.

/**
 * Asserts that the node with the given name was triggered
 *
 * @param it       listener that listened to the process
 * @param nodeName name of the node that is expected to be triggered
 */
public static void assertTriggered(IterableProcessEventListener it, String nodeName) {
    TrackedEvent event = getEvent(it);
    Assertions.assertThat(event.getMethod()).isEqualTo(BEFORE_TRIGGERED);
    CachedProcessNodeTriggeredEvent orig = event.getEvent();
    Assertions.assertThat(orig.getNodeName()).isEqualTo(nodeName);
}
Also used : CachedProcessNodeTriggeredEvent(org.jbpm.test.listener.IterableProcessEventListener.CachedProcessNodeTriggeredEvent) TrackedEvent(org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent)

Aggregations

TrackedEvent (org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent)7 ProcessVariableChangedEvent (org.kie.api.event.process.ProcessVariableChangedEvent)3 CachedProcessCompletedEvent (org.jbpm.test.listener.IterableProcessEventListener.CachedProcessCompletedEvent)1 CachedProcessNodeLeftEvent (org.jbpm.test.listener.IterableProcessEventListener.CachedProcessNodeLeftEvent)1 CachedProcessNodeTriggeredEvent (org.jbpm.test.listener.IterableProcessEventListener.CachedProcessNodeTriggeredEvent)1 CachedProcessStartedEvent (org.jbpm.test.listener.IterableProcessEventListener.CachedProcessStartedEvent)1