use of org.kie.kogito.internal.process.runtime.KogitoWorkItemManager 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.KogitoWorkItemManager 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.KogitoWorkItemManager 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.KogitoWorkItemManager 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.KogitoWorkItemManager 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