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);
}
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");
}
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");
}
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);
}
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");
}
}
}
Aggregations