Search in sources :

Example 1 with WebServiceWorkItemHandler

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

the class WebServiceInvokeTest method testWebServiceAsync.

@Test
@RunAsClient
public void testWebServiceAsync() 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", "ASYNC");
    /*
         * WebService has been called in mode ASYNC so ksession should return
         * control to our program.
         */
    WorkflowProcessInstance pi = (WorkflowProcessInstance) ksession.startProcess(HelloWebService.PROCESS_CALL_WEB_SERVICE, arguments);
    Assertions.assertThat(pi.getVariable("result")).as("Result variable should not yet be set!").isNull();
    Assertions.assertThat(pi.getState()).as("Process finished prematurely.").isEqualTo(ProcessInstance.STATE_ACTIVE);
    /*
         * Wait for the process to complete
         */
    Thread.sleep(4000);
    /*
         * Make sure we got the response back.
         */
    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 2 with WebServiceWorkItemHandler

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

the class WebServiceInvokeTest method testWebServiceOneWay.

@Test
@RunAsClient
public void testWebServiceOneWay() 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", "ONEWAY");
    WorkflowProcessInstance pi = (WorkflowProcessInstance) ksession.startProcess(HelloWebService.PROCESS_CALL_WEB_SERVICE, arguments);
    Assertions.assertThat(pi.getVariable("result")).as("WebService call failed.").isEqualTo(null);
    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 3 with WebServiceWorkItemHandler

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

the class WebServiceInvokeTest method testMultipleImports.

@Test
@RunAsClient
public void testMultipleImports() throws Exception {
    System.out.println("### Running proccess ...");
    KieSession ksession = getSession(hws.getResource(HelloWebService.BPMN_CALL_WEB_SERVICE_MULTI_IMPORTS));
    ksession.getWorkItemManager().registerWorkItemHandler("Service Task", new WebServiceWorkItemHandler(ksession));
    HashMap<String, Object> arguments = new HashMap<String, Object>();
    arguments.put("parameter", "Many Imports");
    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 Many Imports");
    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 4 with WebServiceWorkItemHandler

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

the class JaxWSServiceTaskTest method testServiceInvocationProcessWith2WSImportsWSHandler.

@Test(timeout = 10000)
public void testServiceInvocationProcessWith2WSImportsWSHandler() 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", "sync");
    WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess("org.jboss.qa.jbpm.CallWS", params);
    String variable = (String) processInstance.getVariable("s");
    assertEquals("Hello 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)

Example 5 with WebServiceWorkItemHandler

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

the class JaxWSServiceTaskTest method testServiceInvocationWithMultipleIntParams.

@Test
public void testServiceInvocationWithMultipleIntParams() 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 int[] { 2, 3 });
    params.put("mode", "sync");
    WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess("multiparamws-int", params);
    String variable = (String) processInstance.getVariable("s2");
    assertEquals("Hello 2, 3", 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