use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.
the class ServerlessProcess method processConfig.
public static ProcessConfig processConfig() {
DefaultWorkItemHandlerConfig workItemHandlerConfig = new DefaultWorkItemHandlerConfig();
DefaultProcessEventListenerConfig processEventListenerConfig = new DefaultProcessEventListenerConfig();
return new StaticProcessConfig(workItemHandlerConfig, processEventListenerConfig, new DefaultUnitOfWorkManager(new CollectingUnitOfWorkFactory()), null, new DefaultVariableInitializer(), null);
}
use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.
the class JbpmBpmn2TestCase method config.
protected ProcessConfig config(List<WorkItemHandler> handlers, List<ProcessEventListener> listeners) {
DefaultWorkItemHandlerConfig handlerConfig = new DefaultWorkItemHandlerConfig();
handlers.forEach(h -> handlerConfig.register(h.getName(), h));
DefaultProcessEventListenerConfig listenerConfig = new DefaultProcessEventListenerConfig();
listeners.forEach(h -> listenerConfig.register(h));
ProcessConfig config = new StaticProcessConfig(handlerConfig, listenerConfig, new DefaultUnitOfWorkManager(new CollectingUnitOfWorkFactory()), null, new DefaultVariableInitializer(), null);
return config;
}
use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.
the class TimerEventTest method testBoundaryCycleCronTimerEventOnTask.
@Test
public void testBoundaryCycleCronTimerEventOnTask() throws Exception {
Application app = generateCodeProcessesOnly("timer/TimerBoundaryEventCycleCronOnTask.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.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.
the class TimerEventTest method testIntermediateDateTimerEvent.
@Test
public void testIntermediateDateTimerEvent() throws Exception {
Application app = generateCodeProcessesOnly("timer/IntermediateCatchEventTimerDateISO.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("timer", 1);
((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<>();
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.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.
the class UserTaskTest method testBasicUserTaskProcessExecutionTimeout.
@Test
public void testBasicUserTaskProcessExecutionTimeout() throws Exception {
Application app = generateCodeProcessesOnly("usertask/UserTasksProcessExecTimeout.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("Execution timeout :: end", 1);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
Process<? extends Model> p = app.processes().processById("UserTasksProcess");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
parameters.put("name", "john");
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
List<WorkItem> workItems = processInstance.workItems(securityPolicy);
assertEquals(1, workItems.size());
assertEquals("FirstTask", workItems.get(0).getName());
processInstance.completeWorkItem(workItems.get(0).getId(), null, securityPolicy);
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
boolean completed = listener.waitTillCompleted(3000);
assertThat(completed).isTrue();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
Aggregations