use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class MessageStartEventTest method testRESTApiForMessageEndEvent.
@Test
public void testRESTApiForMessageEndEvent() throws Exception {
Application app = generateCodeProcessesOnly("messagestartevent/MessageEndEvent.bpmn2");
assertThat(app).isNotNull();
Class<?> resourceClazz = Class.forName("org.kie.kogito.test.MessageStartEventResource", true, testClassLoader());
assertNotNull(resourceClazz);
Method[] methods = resourceClazz.getMethods();
assertThat(methods).haveAtLeast(1, new Condition<Method>(m -> m.getName().startsWith("create"), "Must have method with name 'create'"));
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class MessageStartEventTest method testMessageStartEventIOExpressionProcess.
@Test
public void testMessageStartEventIOExpressionProcess() throws Exception {
Application app = generateCodeProcessesOnly("messagestartevent/MessageStartEventIOExpression.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("MessageStartEvent");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
parameters.put("customerId", "CUS-00998877");
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start("customers", null, "CUS-00998877");
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
Model result = (Model) processInstance.variables();
assertThat(result.toMap()).hasSize(2).containsKeys("customerId", "person");
assertThat(result.toMap().get("person")).isNotNull().extracting("name").isEqualTo("CUS-00998877");
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class TimerEventTest method testBoundaryDurationTimerEventOnTask.
@Test
public void testBoundaryDurationTimerEventOnTask() throws Exception {
Application app = generateCodeProcessesOnly("timer/TimerBoundaryEventDurationISOOnTask.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
Process<? extends Model> p = app.processes().processById("TimerBoundaryEvent");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
boolean completed = listener.waitTillCompleted(5000);
assertThat(completed).isTrue();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class TimerEventTest method testStartTimerEvent.
@Test
public void testStartTimerEvent() throws Exception {
Application app = generateCodeProcessesOnly("timer/StartTimerDuration.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("timer fired", 1);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
Process<? extends Model> p = app.processes().processById("defaultPackage.TimerProcess");
// activate to schedule timers
p.activate();
boolean completed = listener.waitTillCompleted(5000);
assertThat(completed).isTrue();
Collection<?> instances = p.instances().values(1, 10);
if (instances.size() == 0) {
Thread.sleep(1000);
instances = p.instances().values(1, 10);
}
assertThat(instances).hasSize(1);
ProcessInstance<?> processInstance = (ProcessInstance<?>) instances.iterator().next();
assertThat(processInstance).isNotNull();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
processInstance.abort();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
instances = p.instances().values(1, 10);
assertThat(instances).hasSize(0);
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class TimerEventTest method testBoundaryCycleTimerEventOnTask.
@Test
public void testBoundaryCycleTimerEventOnTask() throws Exception {
Application app = generateCodeProcessesOnly("timer/TimerBoundaryEventCycleISOOnTask.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
Process<? extends Model> p = app.processes().processById("TimerBoundaryEvent");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
boolean completed = listener.waitTillCompleted(5000);
assertThat(completed).isTrue();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Aggregations