use of io.automatiko.engine.api.Model in project automatiko-engine by automatiko-io.
the class ServerlessWorkflowTest method testSubFlowWorkflow.
@Test
public void testSubFlowWorkflow() throws Exception {
Application app = generateCodeProcessesOnly("serverless/single-subflow.sw.json", "serverless/called-subflow.sw.json");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("singlesubflow_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("parentData", "childData");
Map<String, Object> dataOut = result.toMap();
assertThat(((JsonNode) dataOut.get("parentData")).textValue()).isEqualTo("parentTestData");
assertThat(((JsonNode) dataOut.get("childData")).textValue()).isEqualTo("childTestData");
}
use of io.automatiko.engine.api.Model in project automatiko-engine by automatiko-io.
the class ServerlessWorkflowTest method testSingleInjectWorkflow.
@ParameterizedTest
@ValueSource(strings = { "serverless/single-inject-state.sw.json" })
public void testSingleInjectWorkflow(String processLocation) throws Exception {
Application app = generateCodeProcessesOnly(processLocation);
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("singleinject_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("name");
JsonNode dataOut = (JsonNode) result.toMap().get("name");
assertThat(dataOut.textValue()).isEqualTo("john");
}
use of io.automatiko.engine.api.Model in project automatiko-engine by automatiko-io.
the class ServerlessWorkflowTest method testNoActionsOperationWorkflow.
@ParameterizedTest
@ValueSource(strings = { "serverless/operation-no-actions.sw.json" })
public void testNoActionsOperationWorkflow(String processLocation) throws Exception {
Application app = generateCodeProcessesOnly(processLocation);
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("noactions_1_0");
Model m = p.createModel();
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
use of io.automatiko.engine.api.Model 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.Model 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");
}
Aggregations