use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testBasicServiceProcessTaskMultiinstanceSequential.
@Test
public void testBasicServiceProcessTaskMultiinstanceSequential() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcessMI-sequential.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("ServiceProcess");
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(3).containsKeys("list", "s", "listOut");
assertThat((List<String>) result.toMap().get("listOut")).isNotNull().hasSize(2).contains("Hello first!", "Hello second!");
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testBasicServiceProcessTask.
@Test
public void testBasicServiceProcessTask() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcess.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("ServiceProcess");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
parameters.put("s", "john");
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
assertThat(processInstance.startDate()).isNotNull();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
Model result = (Model) processInstance.variables();
assertThat(result.toMap()).hasSize(1).containsKeys("s");
assertThat(result.toMap().get("s")).isNotNull().isEqualTo("Hello john!");
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testBasicServiceProcessTaskMultiinstance.
@Test
public void testBasicServiceProcessTaskMultiinstance() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcessMI.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("ServiceProcess");
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(3).containsKeys("list", "s", "listOut");
assertThat((List<String>) result.toMap().get("listOut")).isNotNull().hasSize(2).contains("Hello first!", "Hello second!");
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testOverloadedService.
@Test
public void testOverloadedService() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcessOverloaded.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("ServiceProcessOverloaded_1_0");
ProcessInstance<?> processInstance = p.createInstance(p.createModel());
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testBasicServiceProcessTaskWithRetry.
@Test
@Timeout(unit = TimeUnit.SECONDS, value = 10)
public void testBasicServiceProcessTaskWithRetry() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetry.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("Print error", 1);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
Process<? extends Model> p = app.processes().processById("ServiceProcess");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
parameters.put("s", "john");
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
listener.waitTillCompleted();
assertThat(processInstance.startDate()).isNotNull();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
Model result = (Model) processInstance.variables();
assertThat(result.toMap()).hasSize(1).containsKeys("s");
assertThat(result.toMap().get("s")).isNotNull().isEqualTo("john");
}
Aggregations