use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project kogito-runtimes by kiegroup.
the class ActivityGenerationModelTest method testInclusiveSplitAndJoinNested.
@Test
public void testInclusiveSplitAndJoinNested() throws Exception {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-InclusiveSplitAndJoinNested.bpmn2")).get(0);
ProcessMetaData metaData = ProcessToExecModelGenerator.INSTANCE.generate((WorkflowProcess) process.get());
String content = metaData.getGeneratedClassModel().toString();
assertThat(content).isNotNull();
log(content);
Map<String, String> classData = new HashMap<>();
classData.put("org.drools.bpmn2.TestProcess", content);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", 15);
Map<String, BpmnProcess> processes = createProcesses(classData, Collections.singletonMap("Human Task", workItemHandler));
ProcessInstance<BpmnVariables> processInstance = processes.get("com.sample.test").createInstance(BpmnVariables.create(params));
processInstance.start();
assertEquals(STATE_ACTIVE, processInstance.status());
List<KogitoWorkItem> activeWorkItems = workItemHandler.getWorkItems();
assertEquals(2, activeWorkItems.size());
for (KogitoWorkItem wi : activeWorkItems) {
processInstance.completeWorkItem(wi.getStringId(), null);
}
activeWorkItems = workItemHandler.getWorkItems();
assertEquals(2, activeWorkItems.size());
for (KogitoWorkItem wi : activeWorkItems) {
processInstance.completeWorkItem(wi.getStringId(), null);
}
assertEquals(STATE_COMPLETED, processInstance.status());
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project kogito-runtimes by kiegroup.
the class ActivityGenerationModelTest method testInclusiveSplit.
@Test
public void testInclusiveSplit() throws Exception {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-InclusiveSplit.bpmn2")).get(0);
ProcessMetaData metaData = ProcessToExecModelGenerator.INSTANCE.generate((WorkflowProcess) process.get());
String content = metaData.getGeneratedClassModel().toString();
assertThat(content).isNotNull();
log(content);
Map<String, String> classData = new HashMap<>();
classData.put("org.drools.bpmn2.TestProcess", content);
Map<String, BpmnProcess> processes = createProcesses(classData, Collections.emptyMap());
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", 15);
ProcessInstance<BpmnVariables> processInstance = processes.get("com.sample.test").createInstance(BpmnVariables.create(params));
processInstance.start();
assertEquals(STATE_COMPLETED, processInstance.status());
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project kogito-runtimes by kiegroup.
the class ActivityGenerationModelTest method testInclusiveSplitDefaultConnection.
@Test
public void testInclusiveSplitDefaultConnection() throws Exception {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-InclusiveGatewayWithDefault.bpmn2")).get(0);
ProcessMetaData metaData = ProcessToExecModelGenerator.INSTANCE.generate((WorkflowProcess) process.get());
String content = metaData.getGeneratedClassModel().toString();
assertThat(content).isNotNull();
log(content);
Map<String, String> classData = new HashMap<>();
classData.put("org.drools.bpmn2.InclusiveGatewayWithDefaultProcess", content);
Map<String, BpmnProcess> processes = createProcesses(classData, Collections.emptyMap());
Map<String, Object> params = new HashMap<String, Object>();
params.put("test", "c");
ProcessInstance<BpmnVariables> processInstance = processes.get("InclusiveGatewayWithDefault").createInstance(BpmnVariables.create(params));
processInstance.start();
assertEquals(STATE_COMPLETED, processInstance.status());
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project kogito-runtimes by kiegroup.
the class ActivityGenerationModelTest method testMinimalProcess.
@Test
public void testMinimalProcess() throws Exception {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-MinimalProcess.bpmn2")).get(0);
ProcessMetaData metaData = ProcessToExecModelGenerator.INSTANCE.generate((WorkflowProcess) process.get());
String content = metaData.getGeneratedClassModel().toString();
assertThat(content).isNotNull();
log(content);
Map<String, String> classData = new HashMap<>();
classData.put("com.sample.MinimalProcess", content);
Map<String, BpmnProcess> processes = createProcesses(classData, Collections.emptyMap());
ProcessInstance<BpmnVariables> processInstance = processes.get("Minimal").createInstance();
processInstance.start();
assertEquals(STATE_COMPLETED, processInstance.status());
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project kogito-runtimes by kiegroup.
the class VariableTagsTest method testRequiredVariableFiltering.
@Test
public void testRequiredVariableFiltering() {
List<BpmnProcess> processes = BpmnProcess.from(new ClassPathResource("variable-tags/approval-with-custom-variable-tags.bpmn2"));
BpmnProcess process = processes.get(0);
Map<String, Object> params = new HashMap<>();
params.put("approver", "john");
org.kie.kogito.process.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());
}
Aggregations