Search in sources :

Example 51 with Application

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

the class CallActivityTaskTest method testCallActivityTaskMultiInstance.

@Test
public void testCallActivityTaskMultiInstance() throws Exception {
    Application app = generateCodeProcessesOnly("subprocess/CallActivityMI.bpmn2", "subprocess/CallActivitySubProcess.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("ParentProcess");
    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(4).containsKeys("x", "y", "list", "listOut");
    assertThat((List<?>) result.toMap().get("listOut")).isNotNull().hasSize(2);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) 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 52 with Application

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

the class CallActivityTaskTest method testBasicCallActivityTaskWithTypeInfo.

@Test
public void testBasicCallActivityTaskWithTypeInfo() throws Exception {
    Application app = generateCodeProcessesOnly("subprocess/CallActivityWithTypeInfo.bpmn2", "subprocess/CallActivitySubProcess.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("ParentProcess");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("x", "a");
    parameters.put("y", "b");
    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(2).containsKeys("x", "y");
    assertThat(result.toMap().get("y")).isNotNull().isEqualTo("new value");
    assertThat(result.toMap().get("x")).isNotNull().isEqualTo("a");
}
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 53 with Application

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

the class ConditionalEventTest method testNonInterruptingEventSubprocessConditionalEventProcess.

@Test
public void testNonInterruptingEventSubprocessConditionalEventProcess() throws Exception {
    Application app = generateCodeProcessesOnly("conditionalevent/ConditionalEventSubprocessNonInterrupting.bpmn2");
    Process<? extends Model> p = app.processes().processById("subprocessCondition");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("person", new Person("john", 30));
    m.fromMap(parameters);
    ProcessInstance processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    m.fromMap(Collections.singletonMap("person", new Person("john", 45)));
    processInstance.updateVariables(m);
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    m.fromMap(Collections.singletonMap("person", new Person("john", 15)));
    processInstance.updateVariables(m);
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    m.fromMap(Collections.singletonMap("person", new Person("john", 45)));
    processInstance.updateVariables(m);
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    Object counter = ((Model) processInstance.variables()).toMap().get("counter");
    assertThat(counter).isNotNull().asList().hasSize(2);
    processInstance.abort();
}
Also used : HashMap(java.util.HashMap) Model(io.automatiko.engine.api.Model) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) Application(io.automatiko.engine.api.Application) Person(io.automatiko.engine.codegen.data.Person) Test(org.junit.jupiter.api.Test) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest)

Example 54 with Application

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

the class ConditionalEventTest method testBoundaryConditionalEventProcess.

@Test
public void testBoundaryConditionalEventProcess() throws Exception {
    Application app = generateCodeProcessesOnly("conditionalevent/ConditionalBoundaryEvent.bpmn2");
    Process<? extends Model> p = app.processes().processById("boundaryCondition");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("person", new Person("john", 30));
    m.fromMap(parameters);
    ProcessInstance processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    m.fromMap(Collections.singletonMap("person", new Person("john", 45)));
    processInstance.updateVariables(m);
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : HashMap(java.util.HashMap) Model(io.automatiko.engine.api.Model) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) Application(io.automatiko.engine.api.Application) Person(io.automatiko.engine.codegen.data.Person) Test(org.junit.jupiter.api.Test) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest)

Example 55 with Application

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

the class ConditionalEventTest method testBasicConditionalEventProcess.

@Test
public void testBasicConditionalEventProcess() throws Exception {
    Application app = generateCodeProcessesOnly("conditionalevent/ConditionalEvent.bpmn2");
    Process<? extends Model> p = app.processes().processById("conditions");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    m.fromMap(parameters);
    ProcessInstance processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    m.fromMap(Collections.singletonMap("data", "data"));
    processInstance.updateVariables(m);
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : HashMap(java.util.HashMap) Model(io.automatiko.engine.api.Model) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) Application(io.automatiko.engine.api.Application) Test(org.junit.jupiter.api.Test) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest)

Aggregations

Application (io.automatiko.engine.api.Application)157 Model (io.automatiko.engine.api.Model)146 AbstractCodegenTest (io.automatiko.engine.codegen.AbstractCodegenTest)143 Test (org.junit.jupiter.api.Test)143 HashMap (java.util.HashMap)126 WorkItem (io.automatiko.engine.api.workflow.WorkItem)46 ProcessInstance (io.automatiko.engine.api.workflow.ProcessInstance)29 DefaultProcessEventListenerConfig (io.automatiko.engine.workflow.DefaultProcessEventListenerConfig)27 NodeLeftCountDownProcessEventListener (io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener)27 ArrayList (java.util.ArrayList)17 List (java.util.List)16 StaticIdentityProvider (io.automatiko.engine.services.identity.StaticIdentityProvider)14 HumanTaskTransition (io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition)14 Process (io.automatiko.engine.api.workflow.Process)13 Map (java.util.Map)12 Person (io.automatiko.engine.codegen.data.Person)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 JsonNode (com.fasterxml.jackson.databind.JsonNode)10 UnitOfWork (io.automatiko.engine.api.uow.UnitOfWork)9 SecurityPolicy (io.automatiko.engine.api.auth.SecurityPolicy)8