use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testBasicServiceProcessTaskWithRetryDefaultLimit.
@Test
@Timeout(unit = TimeUnit.SECONDS, value = 10)
public void testBasicServiceProcessTaskWithRetryDefaultLimit() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetryDefLimit.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");
}
use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testBasicServiceProcessTaskWithRetryAbort.
@Test
@Timeout(unit = TimeUnit.SECONDS, value = 10000)
public void testBasicServiceProcessTaskWithRetryAbort() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetry.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("EndProcess", 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(1500);
processInstance.abort();
assertThat(processInstance.startDate()).isNotNull();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testBasicServiceProcessTaskWithRetryMultiplier.
@Test
@Timeout(unit = TimeUnit.SECONDS, value = 30)
public void testBasicServiceProcessTaskWithRetryMultiplier() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetryMultiplier.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");
}
use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testBasicServiceProcessTaskWithRetryIncrement.
@Test
@Timeout(unit = TimeUnit.SECONDS, value = 30)
public void testBasicServiceProcessTaskWithRetryIncrement() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetryIncrement.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");
}
use of io.automatiko.engine.workflow.DefaultProcessEventListenerConfig in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testBasicServiceProcessTaskWithRetrySuccessful.
@Test
@Timeout(unit = TimeUnit.SECONDS, value = 10000)
public void testBasicServiceProcessTaskWithRetrySuccessful() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetry.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("EndProcess", 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();
m.fromMap(Collections.singletonMap("s", "mary"));
processInstance.updateVariables(m);
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("Hello mary!");
}
Aggregations