use of org.jbpm.test.listener.DefaultCountDownProcessEventListener in project jbpm by kiegroup.
the class ETransactionTest method testTimer.
@Test
public void testTimer() throws Exception {
DefaultCountDownProcessEventListener listener = new DefaultCountDownProcessEventListener(0) {
@Override
public void afterNodeLeft(ProcessNodeLeftEvent event) {
if ("Timer".equals(event.getNodeInstance().getNodeName())) {
countDown();
}
}
};
RuntimeManager manager = deploymentService.getRuntimeManager(kieJar);
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
engine.getKieSession().addEventListener(listener);
Long processInstanceId = startProcessInstance(PROCESS_ID);
UserTransaction ut = InitialContext.doLookup(USER_TRANSACTION_NAME);
ut.begin();
try {
processService.signalProcessInstance(processInstanceId, "start", "timer");
Assertions.assertThat(hasNodeLeft(processInstanceId, "timer")).isTrue();
} catch (Exception e) {
ut.rollback();
throw e;
}
ut.rollback();
ut = InitialContext.doLookup(USER_TRANSACTION_NAME);
ut.begin();
try {
processService.signalProcessInstance(processInstanceId, "start", "timer");
} catch (Exception e) {
ut.rollback();
throw e;
}
ut.commit();
listener.reset(1);
listener.waitTillCompleted();
Assertions.assertThat(hasNodeLeft(processInstanceId, "timer")).isTrue();
Assertions.assertThat(hasNodeLeft(processInstanceId, "Timer")).isTrue();
processService.signalProcessInstance(processInstanceId, "finish", null);
Assertions.assertThat(hasProcessInstanceCompleted(processInstanceId)).isTrue();
}
Aggregations