Search in sources :

Example 6 with WebServiceWorkItemHandler

use of org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler in project jbpm by kiegroup.

the class JaxWSServiceTaskTest method testOneWayServiceInvocationProcessWSHandler.

@Test
public void testOneWayServiceInvocationProcessWSHandler() throws Exception {
    KieBase kbase = readKnowledgeBase();
    KieSession ksession = createSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Service Task", new WebServiceWorkItemHandler(ksession));
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("s", "john");
    params.put("mode", "oneway");
    WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess("org.jboss.qa.jbpm.CallWS", params);
    logger.info("Execution finished");
    String variable = (String) processInstance.getVariable("s");
    assertNull(variable);
    assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}
Also used : HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) WebServiceWorkItemHandler(org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) AbstractBaseTest(org.jbpm.test.AbstractBaseTest) Test(org.junit.Test)

Example 7 with WebServiceWorkItemHandler

use of org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler in project jbpm by kiegroup.

the class WebServiceInvokeTest method testInterfaceNamePassedViaAssignemnt.

@Test
@RunAsClient
public void testInterfaceNamePassedViaAssignemnt() throws Exception {
    System.out.println("### Running proccess ...");
    KieSession ksession = getSession(hws.getResource(HelloWebService.BPMN_CALL_WEB_SERVICE_NO_INTERFACE));
    ksession.getWorkItemManager().registerWorkItemHandler("Service Task", new WebServiceWorkItemHandler(ksession));
    HashMap<String, Object> arguments = new HashMap<String, Object>();
    arguments.put("parameter", "No Name");
    arguments.put("mode", "SYNC");
    WorkflowProcessInstance pi = (WorkflowProcessInstance) ksession.startProcess(HelloWebService.PROCESS_CALL_WEB_SERVICE, arguments);
    Assertions.assertThat(pi.getVariable("result")).as("WebService call failed.").isEqualTo("Hello No Name");
    Assertions.assertThat(pi.getState()).as("Process did not finish.").isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : HashMap(java.util.HashMap) WebServiceWorkItemHandler(org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) JbpmContainerTest(org.jbpm.test.container.JbpmContainerTest) Test(org.junit.Test)

Example 8 with WebServiceWorkItemHandler

use of org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler in project jbpm by kiegroup.

the class WebServiceInvokeTest method testWebServiceSync.

@Test
@RunAsClient
public void testWebServiceSync() throws Exception {
    System.out.println("### Running proccess ...");
    KieSession ksession = getSession(hws.getResource(HelloWebService.BPMN_CALL_WEB_SERVICE_NO_INTERFACE));
    ksession.getWorkItemManager().registerWorkItemHandler("Service Task", new WebServiceWorkItemHandler(ksession));
    HashMap<String, Object> arguments = new HashMap<String, Object>();
    arguments.put("parameter", "Fredy");
    arguments.put("mode", "SYNC");
    WorkflowProcessInstance pi = (WorkflowProcessInstance) ksession.startProcess(HelloWebService.PROCESS_CALL_WEB_SERVICE, arguments);
    Assertions.assertThat(pi.getVariable("result")).as("WebService call failed.").isEqualTo("Hello Fredy");
    Assertions.assertThat(pi.getState()).as("Process did not finish.").isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : HashMap(java.util.HashMap) WebServiceWorkItemHandler(org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) JbpmContainerTest(org.jbpm.test.container.JbpmContainerTest) Test(org.junit.Test)

Example 9 with WebServiceWorkItemHandler

use of org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler in project jbpm by kiegroup.

the class JaxWSServiceTaskTest method testServiceInvocationWithMultipleParams.

@Test
public void testServiceInvocationWithMultipleParams() throws Exception {
    KieBase kbase = readKnowledgeBase();
    KieSession ksession = createSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Service Task", new WebServiceWorkItemHandler(ksession));
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("s", new String[] { "john", "doe" });
    params.put("mode", "sync");
    WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess("multiparamws", params);
    String variable = (String) processInstance.getVariable("s2");
    assertEquals("Hello doe, john", variable);
    assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}
Also used : HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) WebServiceWorkItemHandler(org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) AbstractBaseTest(org.jbpm.test.AbstractBaseTest) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)9 WebServiceWorkItemHandler (org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler)9 Test (org.junit.Test)9 KieSession (org.kie.api.runtime.KieSession)9 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)9 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)5 JbpmContainerTest (org.jbpm.test.container.JbpmContainerTest)5 AbstractBaseTest (org.jbpm.test.AbstractBaseTest)4 KieBase (org.kie.api.KieBase)4