use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class UserTaskTest method testApprovalWithRequiredVariableTags.
@Test
public void testApprovalWithRequiredVariableTags() throws Exception {
Application app = generateCodeProcessesOnly("usertask/approval-with-required-variable-tags.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("approvals");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);
assertThrows(VariableViolationException.class, () -> {
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
});
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class VariableTest method testVariablesWithReservedNameOnServiceTask.
@Test
public void testVariablesWithReservedNameOnServiceTask() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceTaskWithReservedNameVariable.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("test_1_0");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
parameters.put("package", "john");
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("result");
assertThat(result.toMap()).hasSize(2).containsKeys("package");
assertThat(result.toMap().get("result")).isNotNull().isEqualTo("Hello Hello john!!");
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class MessageStartEventTest method testMessageStartAndEndEventProcess.
@Test
public void testMessageStartAndEndEventProcess() throws Exception {
Application app = generateCodeProcessesOnly("messagestartevent/MessageStartAndEndEvent.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("MessageStartEvent");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
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(1).containsKeys("customerId");
assertThat(result.toMap().get("customerId")).isNotNull().isEqualTo("CUS-00998877");
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class MessageStartEventTest method testMultipleMessagesStartEventProcess.
@Test
public void testMultipleMessagesStartEventProcess() throws Exception {
Application app = generateCodeProcessesOnly("messagestartevent/MessageAndMessageStartEvent.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("MessageStartEvent");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start("customers", null, "CUS-00998877");
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
Model result = (Model) processInstance.variables();
assertThat(result.toMap()).hasSize(2).containsKeys("customerId");
assertThat(result.toMap().get("customerId")).isNotNull().isEqualTo("CUS-00998877");
processInstance.send(Sig.of("managers", "John the manager"));
List<WorkItem> workItems = processInstance.workItems(securityPolicy);
assertEquals(2, workItems.size());
result = (Model) processInstance.variables();
assertThat(result.toMap()).hasSize(2).containsKeys("customerId", "path");
assertThat(result.toMap().get("customerId")).isNotNull().isEqualTo("CUS-00998877");
assertThat(result.toMap().get("path")).isNotNull().isEqualTo("John the manager");
processInstance.abort();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
use of io.automatiko.engine.api.Application in project automatiko-engine by automatiko-io.
the class MessageStartEventTest method testMessageStartEventProcess.
@Test
public void testMessageStartEventProcess() throws Exception {
Application app = generateCodeProcessesOnly("messagestartevent/MessageStartEvent.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("MessageStartEvent_1");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
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(1).containsKeys("customerId");
assertThat(result.toMap().get("customerId")).isNotNull().isEqualTo("CUS-00998877");
}
Aggregations