Search in sources :

Example 1 with KogitoWorkItemManager

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"));
}
Also used : ServiceTaskHandler(org.jbpm.bpmn2.handler.ServiceTaskHandler) KogitoWorkflowProcessInstance(org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance) KogitoWorkItemManager(org.kie.kogito.internal.process.runtime.KogitoWorkItemManager) HashMap(java.util.HashMap) KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) Test(org.junit.jupiter.api.Test)

Example 2 with KogitoWorkItemManager

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);
}
Also used : KogitoWorkflowProcessInstance(org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance) KogitoWorkItemManager(org.kie.kogito.internal.process.runtime.KogitoWorkItemManager) HashMap(java.util.HashMap) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) InternalKogitoWorkItem(org.kie.kogito.process.workitems.InternalKogitoWorkItem) KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) Test(org.junit.jupiter.api.Test)

Example 3 with KogitoWorkItemManager

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);
}
Also used : KogitoWorkItemManager(org.kie.kogito.internal.process.runtime.KogitoWorkItemManager) HashMap(java.util.HashMap) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) KogitoWorkItemHandler(org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler) KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) Test(org.junit.jupiter.api.Test)

Example 4 with KogitoWorkItemManager

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");
}
Also used : KogitoWorkItemManager(org.kie.kogito.internal.process.runtime.KogitoWorkItemManager) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) KogitoWorkItemHandler(org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler) KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) Test(org.junit.jupiter.api.Test)

Example 5 with KogitoWorkItemManager

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);
}
Also used : KogitoWorkItemManager(org.kie.kogito.internal.process.runtime.KogitoWorkItemManager) ByteArrayInputStream(java.io.ByteArrayInputStream) HashMap(java.util.HashMap) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) Element(org.w3c.dom.Element) KogitoWorkItemHandler(org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler) KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) Document(org.w3c.dom.Document) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

KogitoWorkItemManager (org.kie.kogito.internal.process.runtime.KogitoWorkItemManager)25 Test (org.junit.jupiter.api.Test)23 KogitoWorkItem (org.kie.kogito.internal.process.runtime.KogitoWorkItem)23 KogitoProcessInstance (org.kie.kogito.internal.process.runtime.KogitoProcessInstance)20 HashMap (java.util.HashMap)16 KogitoWorkItemHandler (org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler)14 Map (java.util.Map)7 Document (org.w3c.dom.Document)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 TestWorkItemHandler (org.jbpm.bpmn2.objects.TestWorkItemHandler)5 SystemOutWorkItemHandler (org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)5 DefaultKogitoProcessEventListener (org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener)5 ProcessNodeTriggeredEvent (org.kie.api.event.process.ProcessNodeTriggeredEvent)4 Disabled (org.junit.jupiter.api.Disabled)3 InternalKogitoWorkItem (org.kie.kogito.process.workitems.InternalKogitoWorkItem)3 Element (org.w3c.dom.Element)3 ArrayList (java.util.ArrayList)2 MyError (org.jbpm.bpmn2.objects.MyError)2 KogitoProcessRuntime (org.kie.kogito.internal.process.runtime.KogitoProcessRuntime)2 KogitoWorkflowProcessInstance (org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance)2