Search in sources :

Example 86 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.

the class GatewayTest method testExclusiveSplitXPathAdvanced.

@Test
@BZ("1071000")
public void testExclusiveSplitXPathAdvanced() throws Exception {
    KieSession ksession = createKSession(XPATH_EVALUATION);
    ksession.getWorkItemManager().registerWorkItemHandler("Email", new SystemOutWorkItemHandler());
    Map<String, Object> params = new HashMap<String, Object>();
    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    Element hi = doc.createElement("hi");
    Element ho = doc.createElement("ho");
    hi.appendChild(ho);
    Attr attr = doc.createAttribute("value");
    ho.setAttributeNode(attr);
    attr.setValue("a");
    params.put("x", hi);
    params.put("y", "Second");
    ProcessInstance processInstance = ksession.startProcess(XPATH_EVALUATION_ID, params);
    assertProcessInstanceCompleted(processInstance.getId());
}
Also used : HashMap(java.util.HashMap) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) Element(org.w3c.dom.Element) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 87 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.

the class EventSubprocessTest method testErrorCodeException.

@Test
@BZ("1082111")
public void testErrorCodeException() {
    KieSession ksession = createKSession(ERROR_CODE_EXCEPTION);
    ksession.getWorkItemManager().registerWorkItemHandler("Request Handler", new SignallingTaskHandlerDecorator(ExceptionOnPurposeHandler.class, "Error-90277"));
    ksession.getWorkItemManager().registerWorkItemHandler("Error Handler", new SystemOutWorkItemHandler());
    try {
        ProcessInstance processInstance = ksession.startProcess(ERROR_CODE_EXCEPTION_ID);
        assertProcessInstanceNotActive(processInstance.getId(), ksession);
        Assertions.assertThat(((WorkflowProcessInstance) processInstance).getOutcome()).isEqualTo("90277");
    } catch (WorkflowRuntimeException e) {
        fail("Error code exceptions in subprocess does not work.");
    }
}
Also used : SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) SignallingTaskHandlerDecorator(org.jbpm.bpmn2.handler.SignallingTaskHandlerDecorator) KieSession(org.kie.api.runtime.KieSession) WorkflowProcessInstance(org.jbpm.workflow.instance.WorkflowProcessInstance) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowRuntimeException(org.jbpm.workflow.instance.WorkflowRuntimeException) WorkflowProcessInstance(org.jbpm.workflow.instance.WorkflowProcessInstance) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Aggregations

SystemOutWorkItemHandler (org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)87 Test (org.junit.Test)77 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)75 KieBase (org.kie.api.KieBase)59 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)45 HashMap (java.util.HashMap)39 KieSession (org.kie.api.runtime.KieSession)38 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)16 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)15 DefaultRegisterableItemsFactory (org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory)14 AbstractExecutorBaseTest (org.jbpm.test.util.AbstractExecutorBaseTest)14 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)14 WorkItemHandler (org.kie.api.runtime.process.WorkItemHandler)14 NodeTriggeredCountDownProcessEventListener (org.jbpm.test.listener.NodeTriggeredCountDownProcessEventListener)13 ProcessEventListener (org.kie.api.event.process.ProcessEventListener)13 ArrayList (java.util.ArrayList)10 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)6 Document (org.w3c.dom.Document)5 Map (java.util.Map)4 PersistenceUtil.createEnvironment (org.jbpm.persistence.util.PersistenceUtil.createEnvironment)4