Search in sources :

Example 96 with Application

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

the class ServerlessWorkflowTest method testSimpleIncrementtWorkflow.

@ParameterizedTest
@ValueSource(strings = { "serverless/simple-increment.sw.json" })
public void testSimpleIncrementtWorkflow(String processLocation) throws Exception {
    Application app = generateCodeProcessesOnly(processLocation);
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("helloworld_1_0");
    Model m = p.createModel();
    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).containsKeys("count");
    JsonNode dataOut = (JsonNode) result.toMap().get("count");
    assertThat(dataOut.intValue()).isEqualTo(11);
}
Also used : Model(io.automatiko.engine.api.Model) JsonNode(com.fasterxml.jackson.databind.JsonNode) Application(io.automatiko.engine.api.Application) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 97 with Application

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

the class ServerlessWorkflowTest method testApproveSwitchStateWorkflow.

@ParameterizedTest
@ValueSource(strings = { "serverless/switch-state.sw.json" })
public void testApproveSwitchStateWorkflow(String processLocation) throws Exception {
    Application app = generateCodeProcessesOnly(processLocation);
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("switchworkflow_1_0");
    Model m = p.createModel();
    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).containsKeys("decision");
    JsonNode dataOut = (JsonNode) result.toMap().get("decision");
    assertThat(dataOut.textValue()).isEqualTo("Approved");
}
Also used : Model(io.automatiko.engine.api.Model) JsonNode(com.fasterxml.jackson.databind.JsonNode) Application(io.automatiko.engine.api.Application) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 98 with Application

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

the class ServerlessWorkflowTest method testDenySwitchStateWorkflow.

@ParameterizedTest
@ValueSource(strings = { "serverless/switch-state-deny.sw.json" })
public void testDenySwitchStateWorkflow(String processLocation) throws Exception {
    Application app = generateCodeProcessesOnly(processLocation);
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("switchworkflow_1_0");
    Model m = p.createModel();
    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).containsKeys("decision");
    JsonNode dataOut = (JsonNode) result.toMap().get("decision");
    assertThat(dataOut.textValue()).isEqualTo("Denied");
}
Also used : Model(io.automatiko.engine.api.Model) JsonNode(com.fasterxml.jackson.databind.JsonNode) Application(io.automatiko.engine.api.Application) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 99 with Application

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

the class MessageStartEventTest method testMultipleMessagesStartEventProcessCorrelationExpression.

@Test
public void testMultipleMessagesStartEventProcessCorrelationExpression() throws Exception {
    Application app = generateCodeProcessesOnly("messagestartevent/MessageAndMessageStartEventCorrelationExpr.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 100 with Application

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

the class MessageStartEventTest method testRESTApiForMessageStartEvent.

@Test
public void testRESTApiForMessageStartEvent() throws Exception {
    Application app = generateCodeProcessesOnly("messagestartevent/MessageStartEvent.bpmn2");
    assertThat(app).isNotNull();
    Class<?> resourceClazz = Class.forName("org.kie.kogito.test.MessageStartEventResource_1", true, testClassLoader());
    assertNotNull(resourceClazz);
    Method[] methods = resourceClazz.getMethods();
    for (Method m : methods) {
        if (m.getName().startsWith("create")) {
            fail("For processes without none start event there should not be create resource method");
        }
    }
}
Also used : Method(java.lang.reflect.Method) 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