use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project kogito-runtimes by kiegroup.
the class AbstractProcessInstancesIT method testBasicFlow.
@Test
void testBasicFlow() {
var factory = new TestProcessInstancesFactory(getDataSource(), false);
BpmnProcess process = createProcess(factory, "BPMN2-UserTask.bpmn2");
ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create(Collections.singletonMap("test", "test")));
processInstance.start();
JDBCProcessInstances processInstances = (JDBCProcessInstances) process.instances();
assertThat(processInstances.size()).isOne();
Optional<?> foundOne = processInstances.findById(processInstance.id());
BpmnProcessInstance instanceOne = (BpmnProcessInstance) foundOne.get();
processInstances.update(processInstance.id(), instanceOne);
assertThat(processInstances.size()).isOne();
assertThat(processInstances.exists(TEST_ID)).isFalse();
Optional<?> foundTwo = processInstances.findById(TEST_ID);
assertThat(foundTwo).isEmpty();
processInstances.remove(processInstance.id());
assertThat(processInstances.size()).isZero();
assertThat(process.instances().values()).isEmpty();
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project automatiko-engine by automatiko-io.
the class VariableTagsTest method testRequiredVariableFiltering.
@Test
public void testRequiredVariableFiltering() {
BpmnProcess process = create("variable-tags/approval-with-custom-variable-tags.bpmn2");
Map<String, Object> params = new HashMap<String, Object>();
params.put("approver", "john");
ProcessInstance<BpmnVariables> instance = process.createInstance(BpmnVariables.create(params));
instance.start();
assertEquals(STATE_ACTIVE, instance.status());
assertThat(instance.variables().toMap()).hasSize(1);
assertThat(instance.variables().toMap(BpmnVariables.OUTPUTS_ONLY)).hasSize(0);
assertThat(instance.variables().toMap(BpmnVariables.INPUTS_ONLY)).hasSize(0);
assertThat(instance.variables().toMap(BpmnVariables.INTERNAL_ONLY)).hasSize(0);
assertThat(instance.variables().toMap(v -> v.hasTag("onlyAdmin"))).hasSize(1).containsEntry("approver", "john");
instance.abort();
assertEquals(STATE_ABORTED, instance.status());
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project automatiko-engine by automatiko-io.
the class ActivityTest method testScriptTask.
@Test
public void testScriptTask() throws Exception {
BpmnProcess process = create("BPMN2-ScriptTask.bpmn2");
ProcessInstance<BpmnVariables> instance = process.createInstance(BpmnVariables.create());
instance.start();
assertEquals(STATE_COMPLETED, instance.status());
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project automatiko-engine by automatiko-io.
the class ActivityTest method testMinimalProcessImplicit.
@Test
public void testMinimalProcessImplicit() throws Exception {
BpmnProcess process = create("BPMN2-MinimalProcessImplicit.bpmn2");
ProcessInstance<BpmnVariables> instance = process.createInstance(BpmnVariables.create());
instance.start();
assertEquals(STATE_COMPLETED, instance.status());
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project automatiko-engine by automatiko-io.
the class FileSystemProcessInstancesTest method testFindByIdReadMode.
@Test
void testFindByIdReadMode() {
BpmnProcess process = createProcess(null, "BPMN2-UserTask-Script.bpmn2");
// workaround as BpmnProcess does not compile the scripts but just reads the xml
for (io.automatiko.engine.api.definition.process.Node node : ((WorkflowProcess) process.process()).getNodes()) {
if (node instanceof ActionNode) {
ProcessAction a = ((ActionNode) node).getAction();
a.removeMetaData("Action");
a.setMetaData("Action", new Action() {
@Override
public void execute(ProcessContext kcontext) throws Exception {
System.out.println("The variable value is " + kcontext.getVariable("s") + " about to call toString on it");
kcontext.getVariable("s").toString();
}
});
}
}
ProcessInstance<BpmnVariables> mutablePi = process.createInstance(BpmnVariables.create(Collections.singletonMap("var", "value")));
mutablePi.start();
assertThat(mutablePi.status()).isEqualTo(STATE_ERROR);
assertThat(mutablePi.errors()).hasValueSatisfying(errors -> {
assertThat(errors.errorMessages()).contains("null");
assertThat(errors.failedNodeIds()).isEqualTo("ScriptTask_1");
});
assertThat(mutablePi.variables().toMap()).containsExactly(entry("var", "value"));
ProcessInstances<BpmnVariables> instances = process.instances();
assertThat(instances.size()).isOne();
ProcessInstance<BpmnVariables> pi = instances.findById(mutablePi.id(), ProcessInstance.STATE_ERROR, ProcessInstanceReadMode.READ_ONLY).get();
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> pi.abort());
ProcessInstance<BpmnVariables> readOnlyPi = instances.findById(mutablePi.id(), ProcessInstance.STATE_ERROR, ProcessInstanceReadMode.READ_ONLY).get();
assertThat(readOnlyPi.status()).isEqualTo(STATE_ERROR);
assertThat(readOnlyPi.errors()).hasValueSatisfying(errors -> {
assertThat(errors.failedNodeIds()).isEqualTo("ScriptTask_1");
});
assertThat(readOnlyPi.variables().toMap()).containsExactly(entry("var", "value"));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> readOnlyPi.abort());
instances.findById(mutablePi.id(), ProcessInstance.STATE_ERROR, ProcessInstanceReadMode.MUTABLE).get().abort();
assertThat(instances.size()).isZero();
}
Aggregations