use of io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener in project automatiko-engine by automatiko-io.
the class TimerEventTest method testIntermediateCycleTimerEvent.
@Test
public void testIntermediateCycleTimerEvent() throws Exception {
Application app = generateCodeProcessesOnly("timer/IntermediateCatchEventTimerCycleISO.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("timer", 3);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
Process<? extends Model> p = app.processes().processById("IntermediateCatchEvent");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
boolean completed = listener.waitTillCompleted(5000);
assertThat(completed).isTrue();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
processInstance.abort();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
use of io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener in project automatiko-engine by automatiko-io.
the class TimerEventTest method testBoundaryDurationTimerEventOnSubprocess.
@Test
public void testBoundaryDurationTimerEventOnSubprocess() throws Exception {
Application app = generateCodeProcessesOnly("timer/TimerBoundaryEventDurationISO.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
Process<? extends Model> p = app.processes().processById("TimerBoundaryEvent");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
boolean completed = listener.waitTillCompleted(5000);
assertThat(completed).isTrue();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
use of io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener in project automatiko-engine by automatiko-io.
the class TimerEventTest method testBoundaryDateTimerEventOnTask.
@Test
public void testBoundaryDateTimerEventOnTask() throws Exception {
Application app = generateCodeProcessesOnly("timer/TimerBoundaryEventDateISOOnTask.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
Process<? extends Model> p = app.processes().processById("TimerBoundaryEvent");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
OffsetDateTime plusTwoSeconds = OffsetDateTime.now().plusSeconds(2);
parameters.put("date", plusTwoSeconds.toString());
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
boolean completed = listener.waitTillCompleted(5000);
assertThat(completed).isTrue();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
use of io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testBasicServiceProcessTaskWithRetry.
@Test
@Timeout(unit = TimeUnit.SECONDS, value = 10)
public void testBasicServiceProcessTaskWithRetry() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetry.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("Print error", 1);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
Process<? extends Model> p = app.processes().processById("ServiceProcess");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
parameters.put("s", "john");
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
listener.waitTillCompleted();
assertThat(processInstance.startDate()).isNotNull();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
Model result = (Model) processInstance.variables();
assertThat(result.toMap()).hasSize(1).containsKeys("s");
assertThat(result.toMap().get("s")).isNotNull().isEqualTo("john");
}
use of io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener in project automatiko-engine by automatiko-io.
the class AccessPolicyTest method testIntermediateCycleTimerEvent.
@Test
public void testIntermediateCycleTimerEvent() throws Exception {
IdentityProvider.set(securityPolicy.value());
Application app = generateCodeProcessesOnly("access-policy/IntermediateCatchEventTimerCycleISOAccessPolicy.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("timer", 3);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
Process<? extends Model> p = app.processes().processById("IntermediateCatchEvent");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
assertThat(processInstance.initiator()).hasValue("john");
boolean completed = listener.waitTillCompleted(5000);
assertThat(completed).isTrue();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
processInstance.abort();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
Aggregations