use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class CallActivityTaskTest method testCallActivityTaskMultiInstance.
@Test
public void testCallActivityTaskMultiInstance() throws Exception {
Application app = generateCodeProcessesOnly("subprocess/CallActivityMI.bpmn2", "subprocess/CallActivitySubProcess.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("ParentProcess");
List<String> list = new ArrayList<String>();
list.add("first");
list.add("second");
List<String> listOut = new ArrayList<String>();
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
parameters.put("list", list);
parameters.put("listOut", listOut);
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
Model result = (Model) processInstance.variables();
assertThat(result.toMap()).hasSize(4).containsKeys("x", "y", "list", "listOut");
assertThat((List<?>) result.toMap().get("listOut")).isNotNull().hasSize(2);
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class CallActivityTaskTest method testBasicCallActivityTaskWithTypeInfo.
@Test
public void testBasicCallActivityTaskWithTypeInfo() throws Exception {
Application app = generateCodeProcessesOnly("subprocess/CallActivityWithTypeInfo.bpmn2", "subprocess/CallActivitySubProcess.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("ParentProcess");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
parameters.put("x", "a");
parameters.put("y", "b");
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
Model result = (Model) processInstance.variables();
assertThat(result.toMap()).hasSize(2).containsKeys("x", "y");
assertThat(result.toMap().get("y")).isNotNull().isEqualTo("new value");
assertThat(result.toMap().get("x")).isNotNull().isEqualTo("a");
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class ConditionalEventTest method testNonInterruptingEventSubprocessConditionalEventProcess.
@Test
public void testNonInterruptingEventSubprocessConditionalEventProcess() throws Exception {
Application app = generateCodeProcessesOnly("conditionalevent/ConditionalEventSubprocessNonInterrupting.bpmn2");
Process<? extends Model> p = app.processes().processById("subprocessCondition");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
parameters.put("person", new Person("john", 30));
m.fromMap(parameters);
ProcessInstance processInstance = p.createInstance(m);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
m.fromMap(Collections.singletonMap("person", new Person("john", 45)));
processInstance.updateVariables(m);
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
m.fromMap(Collections.singletonMap("person", new Person("john", 15)));
processInstance.updateVariables(m);
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
m.fromMap(Collections.singletonMap("person", new Person("john", 45)));
processInstance.updateVariables(m);
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
Object counter = ((Model) processInstance.variables()).toMap().get("counter");
assertThat(counter).isNotNull().asList().hasSize(2);
processInstance.abort();
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class ConditionalEventTest method testBoundaryConditionalEventProcess.
@Test
public void testBoundaryConditionalEventProcess() throws Exception {
Application app = generateCodeProcessesOnly("conditionalevent/ConditionalBoundaryEvent.bpmn2");
Process<? extends Model> p = app.processes().processById("boundaryCondition");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
parameters.put("person", new Person("john", 30));
m.fromMap(parameters);
ProcessInstance processInstance = p.createInstance(m);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
m.fromMap(Collections.singletonMap("person", new Person("john", 45)));
processInstance.updateVariables(m);
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class ConditionalEventTest method testBasicConditionalEventProcess.
@Test
public void testBasicConditionalEventProcess() throws Exception {
Application app = generateCodeProcessesOnly("conditionalevent/ConditionalEvent.bpmn2");
Process<? extends Model> p = app.processes().processById("conditions");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);
ProcessInstance processInstance = p.createInstance(m);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
m.fromMap(Collections.singletonMap("data", "data"));
processInstance.updateVariables(m);
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Aggregations