Search in sources :

Example 21 with Application

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

the class MessageStartEventTest method testRESTApiForMessageEndEvent.

@Test
public void testRESTApiForMessageEndEvent() throws Exception {
    Application app = generateCodeProcessesOnly("messagestartevent/MessageEndEvent.bpmn2");
    assertThat(app).isNotNull();
    Class<?> resourceClazz = Class.forName("org.kie.kogito.test.MessageStartEventResource", true, testClassLoader());
    assertNotNull(resourceClazz);
    Method[] methods = resourceClazz.getMethods();
    assertThat(methods).haveAtLeast(1, new Condition<Method>(m -> m.getName().startsWith("create"), "Must have method with name 'create'"));
}
Also used : Assertions.fail(org.junit.jupiter.api.Assertions.fail) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) BeforeEach(org.junit.jupiter.api.BeforeEach) Model(io.automatiko.engine.api.Model) SecurityPolicy(io.automatiko.engine.api.auth.SecurityPolicy) AutomatikoBuildConfig(io.automatiko.engine.api.config.AutomatikoBuildConfig) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) Policy(io.automatiko.engine.api.workflow.workitem.Policy) Test(org.junit.jupiter.api.Test) List(java.util.List) Application(io.automatiko.engine.api.Application) Sig(io.automatiko.engine.workflow.Sig) MessagingBuildConfig(io.automatiko.engine.api.config.MessagingBuildConfig) Map(java.util.Map) Condition(org.assertj.core.api.Condition) StaticIdentityProvider(io.automatiko.engine.services.identity.StaticIdentityProvider) Process(io.automatiko.engine.api.workflow.Process) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Method(java.lang.reflect.Method) WorkItem(io.automatiko.engine.api.workflow.WorkItem) Method(java.lang.reflect.Method) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 22 with Application

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

the class MessageStartEventTest method testMessageStartEventIOExpressionProcess.

@Test
public void testMessageStartEventIOExpressionProcess() throws Exception {
    Application app = generateCodeProcessesOnly("messagestartevent/MessageStartEventIOExpression.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("MessageStartEvent");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("customerId", "CUS-00998877");
    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(2).containsKeys("customerId", "person");
    assertThat(result.toMap().get("person")).isNotNull().extracting("name").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 23 with Application

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

the class TimerEventTest method testBoundaryDurationTimerEventOnTask.

@Test
public void testBoundaryDurationTimerEventOnTask() throws Exception {
    Application app = generateCodeProcessesOnly("timer/TimerBoundaryEventDurationISOOnTask.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 24 with Application

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

the class TimerEventTest method testStartTimerEvent.

@Test
public void testStartTimerEvent() throws Exception {
    Application app = generateCodeProcessesOnly("timer/StartTimerDuration.bpmn2");
    assertThat(app).isNotNull();
    NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("timer fired", 1);
    ((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
    Process<? extends Model> p = app.processes().processById("defaultPackage.TimerProcess");
    // activate to schedule timers
    p.activate();
    boolean completed = listener.waitTillCompleted(5000);
    assertThat(completed).isTrue();
    Collection<?> instances = p.instances().values(1, 10);
    if (instances.size() == 0) {
        Thread.sleep(1000);
        instances = p.instances().values(1, 10);
    }
    assertThat(instances).hasSize(1);
    ProcessInstance<?> processInstance = (ProcessInstance<?>) instances.iterator().next();
    assertThat(processInstance).isNotNull();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    processInstance.abort();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
    instances = p.instances().values(1, 10);
    assertThat(instances).hasSize(0);
}
Also used : NodeLeftCountDownProcessEventListener(io.automatiko.engine.workflow.compiler.util.NodeLeftCountDownProcessEventListener) DefaultProcessEventListenerConfig(io.automatiko.engine.workflow.DefaultProcessEventListenerConfig) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 25 with Application

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

the class TimerEventTest method testBoundaryCycleTimerEventOnTask.

@Test
public void testBoundaryCycleTimerEventOnTask() throws Exception {
    Application app = generateCodeProcessesOnly("timer/TimerBoundaryEventCycleISOOnTask.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)

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