Search in sources :

Example 41 with Application

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

the class AdHocFragmentsTest method testAdHocFragments.

@Test
void testAdHocFragments() throws Exception {
    Application app = generateCodeProcessesOnly("cases/AdHocFragments.bpmn");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("TestCase.AdHocFragments_1_0");
    ProcessInstance<?> processInstance = p.createInstance(p.createModel());
    Collection<AdHocFragment> adHocFragments = processInstance.adHocFragments();
    List<AdHocFragment> expected = new ArrayList<>();
    expected.add(new AdHocFragment.Builder(MilestoneNode.class).withName("AdHoc Milestone").withAutoStart(true).build());
    expected.add(new AdHocFragment.Builder(ActionNode.class).withName("AdHoc Script").withAutoStart(false).build());
    expected.add(new AdHocFragment.Builder(HumanTaskNode.class).withName("AdHoc User Task").withAutoStart(false).build());
    expected.add(new AdHocFragment.Builder(WorkItemNode.class).withName("Service Task").withAutoStart(false).build());
    assertAdHocFragments(expected, adHocFragments);
}
Also used : ArrayList(java.util.ArrayList) Application(io.automatiko.engine.api.Application) AdHocFragment(io.automatiko.engine.api.workflow.flexible.AdHocFragment) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 42 with Application

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

the class AdHocFragmentsTest method testProcessAutoStart.

@Test
void testProcessAutoStart() throws Exception {
    Application app = generateCodeProcessesOnly("cases/AdHocProcess.bpmn");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("AdHocProcess_1_0");
    Model model = p.createModel();
    Map<String, Object> params = new HashMap<>();
    params.put("var1", "Pablo");
    params.put("var2", "Luis");
    model.fromMap(params);
    ProcessInstance<? extends Model> processInstance = p.createInstance(model);
    processInstance.start();
    Model result = processInstance.variables();
    assertEquals("Hello Pablo! Script", result.toMap().get("var1"));
    assertEquals("Luis Script 2", result.toMap().get("var2"));
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.status());
}
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 43 with Application

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

the class AdHocFragmentsTest method testStartUserTask.

@Test
void testStartUserTask() throws Exception {
    String taskName = "AdHoc User Task";
    Application app = generateCodeProcessesOnly("cases/AdHocFragments.bpmn");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("TestCase.AdHocFragments_1_0");
    ProcessInstance<? extends Model> processInstance = p.createInstance(p.createModel());
    processInstance.start();
    Optional<WorkItem> workItem = processInstance.workItems().stream().filter(wi -> wi.getParameters().get("NodeName").equals(taskName)).findFirst();
    assertThat(workItem).isNotPresent();
    processInstance.send(Sig.of(taskName, p.createModel()));
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.status());
    workItem = processInstance.workItems().stream().filter(wi -> wi.getParameters().get("NodeName").equals(taskName)).findFirst();
    assertThat(workItem).isPresent();
    assertThat(workItem.get().getId()).isNotBlank();
    assertThat(workItem.get().getName()).isNotBlank();
}
Also used : AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Model(io.automatiko.engine.api.Model) AdHocFragment(io.automatiko.engine.api.workflow.flexible.AdHocFragment) MilestoneNode(io.automatiko.engine.workflow.process.core.node.MilestoneNode) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Collection(java.util.Collection) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) HashMap(java.util.HashMap) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) List(java.util.List) Application(io.automatiko.engine.api.Application) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode) Sig(io.automatiko.engine.workflow.Sig) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Map(java.util.Map) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) Optional(java.util.Optional) Process(io.automatiko.engine.api.workflow.Process) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) WorkItem(io.automatiko.engine.api.workflow.WorkItem) 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 44 with Application

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

the class AdHocFragmentsTest method testStartFragments.

@Test
void testStartFragments() throws Exception {
    Application app = generateCodeProcessesOnly("cases/AdHocFragments.bpmn");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("TestCase.AdHocFragments_1_0");
    ProcessInstance<? extends Model> processInstance = p.createInstance(p.createModel());
    processInstance.start();
    Map<String, Object> params = new HashMap<>();
    params.put("user", "Juan");
    processInstance.send(Sig.of("Service Task", params));
    Model result = processInstance.variables();
    assertEquals("Hello Juan 5!", result.toMap().get("var1"));
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.status());
}
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 45 with Application

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

the class AdHocSubProcessTest method testCompletionAdHoc.

@Test
void testCompletionAdHoc() throws Exception {
    Application app = generateCodeProcessesOnly("cases/CompletionAdHoc.bpmn");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("TestCase.CompletionAdHoc_1_0");
    Model model = p.createModel();
    Map<String, Object> params = new HashMap<>();
    params.put("favouriteColour", "yellow");
    model.fromMap(params);
    ProcessInstance<?> processInstance = p.createInstance(model);
    assertState(processInstance, ProcessInstance.STATE_PENDING);
    processInstance.start();
    assertState(processInstance, ProcessInstance.STATE_ACTIVE);
    List<WorkItem> workItems = processInstance.workItems();
    assertThat(workItems.size()).isEqualTo(1);
    WorkItem workItem = workItems.get(0);
    workItem.getParameters().put("favouriteColour", "green");
    params.put("favouriteColour", "green");
    processInstance.completeWorkItem(workItem.getId(), params);
    assertState(processInstance, ProcessInstance.STATE_COMPLETED);
}
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) 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