Search in sources :

Example 16 with Application

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

the class UserTaskTest method testApprovalWithRequiredVariableTags.

@Test
public void testApprovalWithRequiredVariableTags() throws Exception {
    Application app = generateCodeProcessesOnly("usertask/approval-with-required-variable-tags.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("approvals");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    m.fromMap(parameters);
    assertThrows(VariableViolationException.class, () -> {
        ProcessInstance<?> processInstance = p.createInstance(m);
        processInstance.start();
    });
}
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 17 with Application

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

the class VariableTest method testVariablesWithReservedNameOnServiceTask.

@Test
public void testVariablesWithReservedNameOnServiceTask() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceTaskWithReservedNameVariable.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("test_1_0");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("package", "john");
    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("result");
    assertThat(result.toMap()).hasSize(2).containsKeys("package");
    assertThat(result.toMap().get("result")).isNotNull().isEqualTo("Hello Hello john!!");
}
Also used : HashMap(java.util.HashMap) Model(io.automatiko.engine.api.Model) Application(io.automatiko.engine.api.Application) Test(org.junit.jupiter.api.Test) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest)

Example 18 with Application

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

the class MessageStartEventTest method testMessageStartAndEndEventProcess.

@Test
public void testMessageStartAndEndEventProcess() throws Exception {
    Application app = generateCodeProcessesOnly("messagestartevent/MessageStartAndEndEvent.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("MessageStartEvent");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    m.fromMap(parameters);
    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start("customers", null, "CUS-00998877");
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).hasSize(1).containsKeys("customerId");
    assertThat(result.toMap().get("customerId")).isNotNull().isEqualTo("CUS-00998877");
}
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 19 with Application

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

the class MessageStartEventTest method testMultipleMessagesStartEventProcess.

@Test
public void testMultipleMessagesStartEventProcess() throws Exception {
    Application app = generateCodeProcessesOnly("messagestartevent/MessageAndMessageStartEvent.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("MessageStartEvent");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    m.fromMap(parameters);
    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start("customers", null, "CUS-00998877");
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).hasSize(2).containsKeys("customerId");
    assertThat(result.toMap().get("customerId")).isNotNull().isEqualTo("CUS-00998877");
    processInstance.send(Sig.of("managers", "John the manager"));
    List<WorkItem> workItems = processInstance.workItems(securityPolicy);
    assertEquals(2, workItems.size());
    result = (Model) processInstance.variables();
    assertThat(result.toMap()).hasSize(2).containsKeys("customerId", "path");
    assertThat(result.toMap().get("customerId")).isNotNull().isEqualTo("CUS-00998877");
    assertThat(result.toMap().get("path")).isNotNull().isEqualTo("John the manager");
    processInstance.abort();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
Also used : HashMap(java.util.HashMap) Model(io.automatiko.engine.api.Model) Application(io.automatiko.engine.api.Application) WorkItem(io.automatiko.engine.api.workflow.WorkItem) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 20 with Application

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

the class MessageStartEventTest method testMessageStartEventProcess.

@Test
public void testMessageStartEventProcess() throws Exception {
    Application app = generateCodeProcessesOnly("messagestartevent/MessageStartEvent.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("MessageStartEvent_1");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    m.fromMap(parameters);
    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start("customers", null, "CUS-00998877");
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).hasSize(1).containsKeys("customerId");
    assertThat(result.toMap().get("customerId")).isNotNull().isEqualTo("CUS-00998877");
}
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

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