Search in sources :

Example 16 with DefaultProcessEventListenerConfig

use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.

the class ServiceTaskTest method testBasicServiceProcessTaskWithRetryDefaultLimit.

@Test
@Timeout(unit = TimeUnit.SECONDS, value = 10)
public void testBasicServiceProcessTaskWithRetryDefaultLimit() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetryDefLimit.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");
}
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) Timeout(org.junit.jupiter.api.Timeout)

Example 17 with DefaultProcessEventListenerConfig

use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.

the class ServiceTaskTest method testBasicServiceProcessTaskWithRetryAbort.

@Test
@Timeout(unit = TimeUnit.SECONDS, value = 10000)
public void testBasicServiceProcessTaskWithRetryAbort() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetry.bpmn2");
    assertThat(app).isNotNull();
    NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("EndProcess", 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(1500);
    processInstance.abort();
    assertThat(processInstance.startDate()).isNotNull();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
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) Timeout(org.junit.jupiter.api.Timeout)

Example 18 with DefaultProcessEventListenerConfig

use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.

the class ServiceTaskTest method testBasicServiceProcessTaskWithRetryMultiplier.

@Test
@Timeout(unit = TimeUnit.SECONDS, value = 30)
public void testBasicServiceProcessTaskWithRetryMultiplier() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetryMultiplier.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");
}
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) Timeout(org.junit.jupiter.api.Timeout)

Example 19 with DefaultProcessEventListenerConfig

use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.

the class ServiceTaskTest method testBasicServiceProcessTaskWithRetryIncrement.

@Test
@Timeout(unit = TimeUnit.SECONDS, value = 30)
public void testBasicServiceProcessTaskWithRetryIncrement() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetryIncrement.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");
}
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) Timeout(org.junit.jupiter.api.Timeout)

Example 20 with DefaultProcessEventListenerConfig

use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.

the class ServiceTaskTest method testBasicServiceProcessTaskWithRetrySuccessful.

@Test
@Timeout(unit = TimeUnit.SECONDS, value = 10000)
public void testBasicServiceProcessTaskWithRetrySuccessful() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetry.bpmn2");
    assertThat(app).isNotNull();
    NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("EndProcess", 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();
    m.fromMap(Collections.singletonMap("s", "mary"));
    processInstance.updateVariables(m);
    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("Hello mary!");
}
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) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

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