use of org.kie.kogito.internal.process.runtime.KogitoWorkItem 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.KogitoWorkItem in project kogito-runtimes by kiegroup.
the class CompensationTest method orderedCompensation.
@Test
public void orderedCompensation() throws Exception {
kruntime = createKogitoProcessRuntime("compensation/BPMN2-Compensation-ParallelOrderedCompensation-IntermediateThrowEvent.bpmn2");
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
Map<String, Object> params = new HashMap<>();
params.put("x", "");
KogitoProcessInstance processInstance = kruntime.startProcess("CompensateParallelOrdered", params);
List<KogitoWorkItem> workItems = workItemHandler.getWorkItems();
List<String> workItemIds = new ArrayList<>();
for (KogitoWorkItem workItem : workItems) {
if ("Thr".equals(workItem.getParameter("NodeName"))) {
workItemIds.add(workItem.getStringId());
}
}
for (KogitoWorkItem workItem : workItems) {
if ("Two".equals(workItem.getParameter("NodeName"))) {
workItemIds.add(workItem.getStringId());
}
}
for (KogitoWorkItem workItem : workItems) {
if ("One".equals(workItem.getParameter("NodeName"))) {
workItemIds.add(workItem.getStringId());
}
}
for (String id : workItemIds) {
kruntime.getKogitoWorkItemManager().completeWorkItem(id, null);
}
// user task -> script task (associated with compensation) --> intermeidate throw compensation event
String xVal = getProcessVarValue(processInstance, "x");
// Compensation happens in the *REVERSE* order of completion
// Ex: if the order is 3, 17, 282, then compensation should happen in the order of 282, 17, 3
// Compensation did not fire in the same order as the associated activities completed.
Assertions.assertThat(xVal).isEqualTo("_171:_131:_141:_151:");
}
use of org.kie.kogito.internal.process.runtime.KogitoWorkItem in project kogito-runtimes by kiegroup.
the class DataTest method testDataInputAssociationsWithStringObject.
@Test
public void testDataInputAssociationsWithStringObject() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-DataInputAssociations-string-object.bpmn2");
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new KogitoWorkItemHandler() {
@Override
public void abortWorkItem(KogitoWorkItem manager, KogitoWorkItemManager mgr) {
}
@Override
public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) {
assertEquals("hello", workItem.getParameter("coId"));
}
});
Map<String, Object> params = new HashMap<>();
params.put("instanceMetadata", "hello");
KogitoProcessInstance processInstance = kruntime.startProcess("process", params);
}
use of org.kie.kogito.internal.process.runtime.KogitoWorkItem in project kogito-runtimes by kiegroup.
the class DataTest method testDataInputAssociationsWithStringWithoutQuotes.
@Test
public void testDataInputAssociationsWithStringWithoutQuotes() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-DataInputAssociations-string-no-quotes.bpmn2");
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new KogitoWorkItemHandler() {
public void abortWorkItem(KogitoWorkItem manager, KogitoWorkItemManager mgr) {
}
public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) {
assertEquals("hello", workItem.getParameter("coId"));
}
});
KogitoProcessInstance processInstance = kruntime.startProcess("process");
}
use of org.kie.kogito.internal.process.runtime.KogitoWorkItem in project kogito-runtimes by kiegroup.
the class DataTest method testDataInputAssociationsWithLazyLoading.
/**
* TODO testDataInputAssociationsWithLazyLoading
*/
@Test
@Disabled
public void testDataInputAssociationsWithLazyLoading() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-DataInputAssociations-lazy-creating.bpmn2");
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new KogitoWorkItemHandler() {
public void abortWorkItem(KogitoWorkItem manager, KogitoWorkItemManager mgr) {
}
public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) {
Object coIdParamObj = workItem.getParameter("coId");
assertEquals("mydoc", ((Element) coIdParamObj).getNodeName());
assertEquals("mynode", ((Element) workItem.getParameter("coId")).getFirstChild().getNodeName());
assertEquals("user", ((Element) workItem.getParameter("coId")).getFirstChild().getFirstChild().getNodeName());
assertEquals("hello world", ((Element) workItem.getParameter("coId")).getFirstChild().getFirstChild().getAttributes().getNamedItem("hello").getNodeValue());
}
});
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream("<user hello='hello world' />".getBytes()));
Map<String, Object> params = new HashMap<>();
params.put("instanceMetadata", document.getFirstChild());
KogitoProcessInstance processInstance = kruntime.startProcess("process", params);
}
Aggregations