Search in sources :

Example 26 with DefaultProcessEventListenerConfig

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);
}
Also used : StaticProcessConfig(io.automatiko.engine.workflow.StaticProcessConfig) CollectingUnitOfWorkFactory(io.automatiko.engine.services.uow.CollectingUnitOfWorkFactory) DefaultProcessEventListenerConfig(io.automatiko.engine.workflow.DefaultProcessEventListenerConfig) DefaultUnitOfWorkManager(io.automatiko.engine.services.uow.DefaultUnitOfWorkManager) DefaultVariableInitializer(io.automatiko.engine.workflow.base.instance.context.variable.DefaultVariableInitializer) DefaultWorkItemHandlerConfig(io.automatiko.engine.workflow.DefaultWorkItemHandlerConfig)

Example 27 with DefaultProcessEventListenerConfig

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;
}
Also used : StaticProcessConfig(io.automatiko.engine.workflow.StaticProcessConfig) ProcessConfig(io.automatiko.engine.api.workflow.ProcessConfig) StaticProcessConfig(io.automatiko.engine.workflow.StaticProcessConfig) CollectingUnitOfWorkFactory(io.automatiko.engine.services.uow.CollectingUnitOfWorkFactory) DefaultProcessEventListenerConfig(io.automatiko.engine.workflow.DefaultProcessEventListenerConfig) DefaultUnitOfWorkManager(io.automatiko.engine.services.uow.DefaultUnitOfWorkManager) DefaultVariableInitializer(io.automatiko.engine.workflow.base.instance.context.variable.DefaultVariableInitializer) DefaultWorkItemHandlerConfig(io.automatiko.engine.workflow.DefaultWorkItemHandlerConfig)

Example 28 with DefaultProcessEventListenerConfig

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);
}
Also used : NodeLeftCountDownProcessEventListener(io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener) HashMap(java.util.HashMap) DefaultProcessEventListenerConfig(io.automatiko.engine.workflow.DefaultProcessEventListenerConfig) Model(io.automatiko.engine.api.Model) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 29 with DefaultProcessEventListenerConfig

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);
}
Also used : NodeLeftCountDownProcessEventListener(io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener) HashMap(java.util.HashMap) OffsetDateTime(java.time.OffsetDateTime) DefaultProcessEventListenerConfig(io.automatiko.engine.workflow.DefaultProcessEventListenerConfig) Model(io.automatiko.engine.api.Model) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 30 with DefaultProcessEventListenerConfig

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);
}
Also used : HashMap(java.util.HashMap) WorkItem(io.automatiko.engine.api.workflow.WorkItem) NodeLeftCountDownProcessEventListener(io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener) DefaultProcessEventListenerConfig(io.automatiko.engine.workflow.DefaultProcessEventListenerConfig) Model(io.automatiko.engine.api.Model) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultProcessEventListenerConfig (io.automatiko.engine.workflow.DefaultProcessEventListenerConfig)31 Application (io.automatiko.engine.api.Application)26 NodeLeftCountDownProcessEventListener (io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener)26 Test (org.junit.jupiter.api.Test)26 AbstractCodegenTest (io.automatiko.engine.codegen.AbstractCodegenTest)25 Model (io.automatiko.engine.api.Model)23 HashMap (java.util.HashMap)23 Timeout (org.junit.jupiter.api.Timeout)7 CollectingUnitOfWorkFactory (io.automatiko.engine.services.uow.CollectingUnitOfWorkFactory)5 DefaultUnitOfWorkManager (io.automatiko.engine.services.uow.DefaultUnitOfWorkManager)5 StaticProcessConfig (io.automatiko.engine.workflow.StaticProcessConfig)5 DefaultVariableInitializer (io.automatiko.engine.workflow.base.instance.context.variable.DefaultVariableInitializer)5 ProcessInstance (io.automatiko.engine.api.workflow.ProcessInstance)4 DefaultWorkItemHandlerConfig (io.automatiko.engine.workflow.DefaultWorkItemHandlerConfig)3 ProcessConfig (io.automatiko.engine.api.workflow.ProcessConfig)2 WorkItem (io.automatiko.engine.api.workflow.WorkItem)2 CachedWorkItemHandlerConfig (io.automatiko.engine.workflow.CachedWorkItemHandlerConfig)2 HumanTaskWorkItemHandler (io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemHandler)2 OffsetDateTime (java.time.OffsetDateTime)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2