use of org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance in project kogito-runtimes by kiegroup.
the class ProcessInstanceEventBatch method createUserTask.
protected UserTaskInstanceEventBody createUserTask(ProcessWorkItemTransitionEvent workItemTransitionEvent) {
KogitoWorkflowProcessInstance pi = (KogitoWorkflowProcessInstance) workItemTransitionEvent.getProcessInstance();
HumanTaskWorkItem workItem = (HumanTaskWorkItem) workItemTransitionEvent.getWorkItem();
return UserTaskInstanceEventBody.create().id(workItem.getStringId()).state(workItem.getPhaseStatus()).taskName(workItem.getTaskName()).taskDescription(workItem.getTaskDescription()).taskPriority(workItem.getTaskPriority()).referenceName(workItem.getReferenceName()).actualOwner(workItem.getActualOwner()).startDate(workItem.getStartDate()).completeDate(workItem.getCompleteDate()).adminGroups(workItem.getAdminGroups()).adminUsers(workItem.getAdminUsers()).excludedUsers(workItem.getExcludedUsers()).potentialGroups(workItem.getPotentialGroups()).potentialUsers(workItem.getPotentialUsers()).processInstanceId(pi.getStringId()).rootProcessInstanceId(pi.getRootProcessInstanceId()).processId(pi.getProcessId()).rootProcessId(pi.getRootProcessId()).inputs(workItem.getParameters()).outputs(workItem.getResults()).comments(workItem.getComments().values()).attachments(workItem.getAttachments().values()).build();
}
use of org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance in project kogito-runtimes by kiegroup.
the class ActivityTest method testServiceTaskWithAccessToWorkItemInfo.
@Test
public void testServiceTaskWithAccessToWorkItemInfo() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-ServiceProcess.bpmn2");
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Service Task", new ServiceTaskHandler() {
@Override
public void executeWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem workItem, KogitoWorkItemManager manager) {
assertThat(workItem.getProcessInstance()).isNotNull();
assertThat(workItem.getNodeInstance()).isNotNull();
super.executeWorkItem(workItem, manager);
}
});
Map<String, Object> params = new HashMap<>();
params.put("s", "john");
KogitoWorkflowProcessInstance processInstance = (KogitoWorkflowProcessInstance) kruntime.startProcess("ServiceProcess", params);
assertProcessInstanceFinished(processInstance, kruntime);
assertEquals("Hello john!", processInstance.getVariable("s"));
}
use of org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance in project kogito-runtimes by kiegroup.
the class ActivityTest method testDMNBusinessRuleTask.
@Test
public void testDMNBusinessRuleTask() throws Exception {
kruntime = createKogitoProcessRuntime("dmn/BPMN2-BusinessRuleTaskDMN.bpmn2", "dmn/0020-vacation-days.dmn");
// first run 16, 1 and expected days is 27
Map<String, Object> params = new HashMap<>();
params.put("age", 16);
params.put("yearsOfService", 1);
KogitoProcessInstance processInstance = kruntime.startProcess("BPMN2-BusinessRuleTask", params);
assertProcessInstanceFinished(processInstance, kruntime);
BigDecimal vacationDays = (BigDecimal) ((KogitoWorkflowProcessInstance) processInstance).getVariable("vacationDays");
assertEquals(BigDecimal.valueOf(27), vacationDays);
// second run 44, 20 and expected days is 24
params = new HashMap<>();
params.put("age", 44);
params.put("yearsOfService", 20);
processInstance = kruntime.startProcess("BPMN2-BusinessRuleTask", params);
assertProcessInstanceFinished(processInstance, kruntime);
vacationDays = (BigDecimal) ((KogitoWorkflowProcessInstance) processInstance).getVariable("vacationDays");
assertEquals(BigDecimal.valueOf(24), vacationDays);
// second run 50, 30 and expected days is 30
params = new HashMap<>();
params.put("age", 50);
params.put("yearsOfService", 30);
processInstance = kruntime.startProcess("BPMN2-BusinessRuleTask", params);
assertProcessInstanceFinished(processInstance, kruntime);
vacationDays = (BigDecimal) ((KogitoWorkflowProcessInstance) processInstance).getVariable("vacationDays");
assertEquals(BigDecimal.valueOf(30), vacationDays);
}
use of org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance in project kogito-runtimes by kiegroup.
the class ActivityTest method testServiceTaskNoInterfaceName.
@Test
public void testServiceTaskNoInterfaceName() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-ServiceTask-web-service.bpmn2");
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Service Task", new SystemOutWorkItemHandler() {
@Override
public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager manager) {
assertEquals("SimpleService", workItem.getParameter("Interface"));
assertEquals("hello", workItem.getParameter("Operation"));
assertEquals("java.lang.String", workItem.getParameter("ParameterType"));
assertEquals("##WebService", workItem.getParameter("implementation"));
assertEquals("hello", workItem.getParameter("operationImplementationRef"));
assertEquals("SimpleService", workItem.getParameter("interfaceImplementationRef"));
super.executeWorkItem(workItem, manager);
}
});
Map<String, Object> params = new HashMap<>();
KogitoWorkflowProcessInstance processInstance = (KogitoWorkflowProcessInstance) kruntime.startProcess("org.jboss.qa.jbpm.CallWS", params);
assertProcessInstanceFinished(processInstance, kruntime);
}
use of org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance in project kogito-runtimes by kiegroup.
the class ActivityTest method testServiceTask.
@Test
public void testServiceTask() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-ServiceProcess.bpmn2");
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Service Task", new ServiceTaskHandler());
Map<String, Object> params = new HashMap<>();
params.put("s", "john");
KogitoWorkflowProcessInstance processInstance = (KogitoWorkflowProcessInstance) kruntime.startProcess("ServiceProcess", params);
assertProcessInstanceFinished(processInstance, kruntime);
assertEquals("Hello john!", processInstance.getVariable("s"));
}
Aggregations