Search in sources :

Example 6 with TrackedEvent

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

the class IterableListenerAssert method assertChangedVariable.

/**
 * Asserts that the variable was changed
 *
 * @param it       listener that listened to the process
 * @param name     name of the variable
 * @param oldValue expected old value or null
 * @param newValue expected new value or null
 */
public static void assertChangedVariable(IterableProcessEventListener it, String name, Object oldValue, Object newValue) {
    TrackedEvent event = getEvent(it);
    Assertions.assertThat(event.getMethod()).isEqualTo(BEFORE_VARIABLE);
    ProcessVariableChangedEvent orig = event.getEvent();
    Assertions.assertThat(orig.getVariableId()).isEqualTo(name);
    assertChangedVariableValues(orig, oldValue, newValue);
    event = it.next();
    Assertions.assertThat(event.getMethod()).isEqualTo(AFTER_VARIABLE);
    orig = event.getEvent();
    Assertions.assertThat(orig.getVariableId()).isEqualTo(name);
    assertChangedVariableValues(orig, oldValue, newValue);
}
Also used : ProcessVariableChangedEvent(org.kie.api.event.process.ProcessVariableChangedEvent) TrackedEvent(org.jbpm.test.listener.IterableProcessEventListener.TrackedEvent)

Example 7 with TrackedEvent

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

the class IterableListenerAssert method assertChangedMultipleInstancesVariable.

/**
 * Asserts that the variable was changed within multipleInstances
 * subprocess. Variable has prefix identifying this MI subprocess.
 *
 * @param it       listener that listened to the process
 * @param name     name of the variable
 * @param oldValue expected old value or null
 * @param newValue expected new value or null
 */
public static void assertChangedMultipleInstancesVariable(IterableProcessEventListener it, String name, Object oldValue, Object newValue) {
    TrackedEvent event = getEvent(it);
    Assertions.assertThat(event.getMethod()).isEqualTo(BEFORE_VARIABLE);
    ProcessVariableChangedEvent orig = event.getEvent();
    Assertions.assertThat(orig.getVariableId().endsWith(":" + name)).isTrue();
    assertChangedVariableValues(orig, oldValue, newValue);
    event = it.next();
    Assertions.assertThat(event.getMethod()).isEqualTo(AFTER_VARIABLE);
    orig = event.getEvent();
    Assertions.assertThat(orig.getVariableId().endsWith(":" + name)).isTrue();
    assertChangedVariableValues(orig, oldValue, newValue);
}
Also used : ProcessVariableChangedEvent(org.kie.api.event.process.ProcessVariableChangedEvent) 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