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);
}
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);
}
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);
}
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());
}
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());
}
Aggregations