use of org.jbpm.compiler.canonical.ProcessMetaData in project kogito-runtimes by kiegroup.
the class ActivityGenerationModelTest method testExclusiveSplit.
@Test
public void testExclusiveSplit() throws Exception {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-ExclusiveSplit.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);
SystemOutWorkItemHandler workItemHandler = new SystemOutWorkItemHandler();
Map<String, BpmnProcess> processes = createProcesses(classData, Collections.singletonMap("Email", workItemHandler));
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "First");
params.put("y", "Second");
ProcessInstance<BpmnVariables> processInstance = processes.get("com.sample.test").createInstance(BpmnVariables.create(params));
processInstance.start();
assertEquals(STATE_COMPLETED, processInstance.status());
}
use of org.jbpm.compiler.canonical.ProcessMetaData in project kogito-runtimes by kiegroup.
the class ActivityGenerationModelTest method testBusinessRuleTaskProcess.
@Test
public void testBusinessRuleTaskProcess() throws Exception {
// This is a workaround to make it compile. A process that includes rules will never execute without a full Kogito context
MockClassLoader classLoader = new MockClassLoader("org.kie.kogito.legacy.rules.KieRuntimeBuilder");
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-BusinessRuleTask.bpmn2")).get(0);
ProcessMetaData metaData = new ProcessToExecModelGenerator(classLoader).generate((WorkflowProcess) process.get());
String content = metaData.getGeneratedClassModel().toString();
assertThat(content).isNotNull();
log(content);
}
use of org.jbpm.compiler.canonical.ProcessMetaData in project kogito-runtimes by kiegroup.
the class ActivityGenerationModelTest method testServiceTaskProcess.
@Test
public void testServiceTaskProcess() throws Exception {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-ServiceProcess.bpmn2")).get(0);
ProcessMetaData metaData = ProcessToExecModelGenerator.INSTANCE.generate((WorkflowProcess) process.get());
String content = metaData.getGeneratedClassModel().toString();
assertThat(content).isNotNull();
log(content);
assertThat(metaData.getWorkItems()).hasSize(1).contains("org.jbpm.bpmn2.objects.HelloService_hello_2_Handler");
}
use of org.jbpm.compiler.canonical.ProcessMetaData 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 org.jbpm.compiler.canonical.ProcessMetaData 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());
}
Aggregations