Search in sources :

Example 26 with Model

use of io.automatiko.engine.api.Model 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);
}
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 27 with Model

use of io.automatiko.engine.api.Model 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);
}
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 28 with Model

use of io.automatiko.engine.api.Model in project automatiko-engine by automatiko-io.

the class ServiceTaskTest method testServiceProcessDifferentOperationsTaskFromAnotherNode.

@Test
public void testServiceProcessDifferentOperationsTaskFromAnotherNode() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcessDifferentOperations.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("ServiceProcessDifferentOperations_1_0");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("s", "john");
    m.fromMap(parameters);
    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.startFrom("_A1EE8114-BF7B-4DAF-ABD7-62EEDCFAEFD4");
    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("Goodbye john!");
}
Also used : HashMap(java.util.HashMap) 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 Model

use of io.automatiko.engine.api.Model in project automatiko-engine by automatiko-io.

the class ServiceTaskTest method testBasicServiceProcessTaskMultiinstanceSequential.

@Test
public void testBasicServiceProcessTaskMultiinstanceSequential() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcessMI-sequential.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("ServiceProcess");
    List<String> list = new ArrayList<String>();
    list.add("first");
    list.add("second");
    List<String> listOut = new ArrayList<String>();
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("list", list);
    parameters.put("listOut", listOut);
    m.fromMap(parameters);
    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).hasSize(3).containsKeys("list", "s", "listOut");
    assertThat((List<String>) result.toMap().get("listOut")).isNotNull().hasSize(2).contains("Hello first!", "Hello second!");
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Model(io.automatiko.engine.api.Model) ArrayList(java.util.ArrayList) List(java.util.List) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 30 with Model

use of io.automatiko.engine.api.Model in project automatiko-engine by automatiko-io.

the class ServiceTaskTest method testBasicServiceProcessTask.

@Test
public void testBasicServiceProcessTask() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcess.bpmn2");
    assertThat(app).isNotNull();
    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();
    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 john!");
}
Also used : HashMap(java.util.HashMap) 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

Model (io.automatiko.engine.api.Model)161 Application (io.automatiko.engine.api.Application)142 Test (org.junit.jupiter.api.Test)138 AbstractCodegenTest (io.automatiko.engine.codegen.AbstractCodegenTest)133 HashMap (java.util.HashMap)127 WorkItem (io.automatiko.engine.api.workflow.WorkItem)43 ProcessInstance (io.automatiko.engine.api.workflow.ProcessInstance)26 DefaultProcessEventListenerConfig (io.automatiko.engine.workflow.DefaultProcessEventListenerConfig)23 NodeLeftCountDownProcessEventListener (io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener)23 ArrayList (java.util.ArrayList)16 HumanTaskTransition (io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition)13 JsonNode (com.fasterxml.jackson.databind.JsonNode)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 Person (io.automatiko.engine.codegen.data.Person)10 StaticIdentityProvider (io.automatiko.engine.services.identity.StaticIdentityProvider)10 UnitOfWork (io.automatiko.engine.api.uow.UnitOfWork)9 AbstractProcessInstance (io.automatiko.engine.workflow.AbstractProcessInstance)9 List (java.util.List)9 DataEvent (io.automatiko.engine.api.event.DataEvent)8 ProcessInstanceDataEvent (io.automatiko.engine.services.event.ProcessInstanceDataEvent)8