use of org.jbpm.process.workitem.rest.RESTWorkItemHandler in project jbpm by kiegroup.
the class RestServiceInvokeTest method testPost.
@Test
@RunAsClient
public void testPost() throws Exception {
System.out.println("### Running proccess ...");
KieSession ksession = getSession(rrs.getResource(RegisterRestService.BPMN_CALL_REST_SERVICE));
ksession.getWorkItemManager().registerWorkItemHandler("REST", new RESTWorkItemHandler());
HashMap<String, Object> arguments = new HashMap<String, Object>();
arguments.put("Url", RegisterRestService.SERVICE_URL + "PersonList/add");
arguments.put("Method", "POST");
arguments.put("ContentType", "application/json");
arguments.put("Content", "{ \"name\": \"Marek\", \"middlename\": \"-\", \"surname\": \"Baluch\" }");
WorkflowProcessInstance pi = (WorkflowProcessInstance) ksession.startProcess(RegisterRestService.PROCESS_CALL_REST_SERVICE, arguments);
Assertions.assertThat(pi.getVariable("Result")).as("REST call failed - Wrong response.").isEqualTo("Ok");
Assertions.assertThat(pi.getVariable("Status")).as("REST call failed - Wrong status code.").isEqualTo(200);
Assertions.assertThat(pi.getState()).as("Process did not finish").isEqualTo(ProcessInstance.STATE_COMPLETED);
}
use of org.jbpm.process.workitem.rest.RESTWorkItemHandler in project jbpm by kiegroup.
the class RestServiceInvokeTest method testGet.
@Test
@RunAsClient
public void testGet() throws Exception {
System.out.println("### Running proccess ...");
KieSession ksession = getSession(rrs.getResource(RegisterRestService.BPMN_CALL_REST_SERVICE_SIMPLE));
ksession.getWorkItemManager().registerWorkItemHandler("REST", new RESTWorkItemHandler());
HashMap<String, Object> arguments = new HashMap<String, Object>();
arguments.put("Url", RegisterRestService.SERVICE_URL + "PersonList/ping");
WorkflowProcessInstance pi = (WorkflowProcessInstance) ksession.startProcess(RegisterRestService.PROCESS_CALL_REST_SERVICE_SIMPLE, arguments);
Assertions.assertThat(pi.getVariable("Result")).as("REST call failed - Wrong response.").isEqualTo("pong");
Assertions.assertThat(pi.getVariable("Status")).as("REST call failed - Wrong status code.").isEqualTo(200);
Assertions.assertThat(pi.getState()).as("Process did not finish").isEqualTo(ProcessInstance.STATE_COMPLETED);
}
use of org.jbpm.process.workitem.rest.RESTWorkItemHandler in project jbpm by kiegroup.
the class RestServiceInvokeTest method testDelete.
@Test
@RunAsClient
public void testDelete() throws Exception {
System.out.println("### Running proccess ...");
KieSession ksession = getSession(rrs.getResource(RegisterRestService.BPMN_CALL_REST_SERVICE));
ksession.getWorkItemManager().registerWorkItemHandler("REST", new RESTWorkItemHandler());
HashMap<String, Object> arguments = new HashMap<String, Object>();
arguments.put("Url", RegisterRestService.SERVICE_URL + "PersonList/delete?name=Don&middlename=Non&surname=Existent");
arguments.put("Method", "DELETE");
arguments.put("ContentType", "text/plain");
WorkflowProcessInstance pi = (WorkflowProcessInstance) ksession.startProcess(RegisterRestService.PROCESS_CALL_REST_SERVICE, arguments);
Assertions.assertThat(pi.getVariable("Result")).as("REST call failed - Wrong response.").isEqualTo("Fail");
Assertions.assertThat(pi.getVariable("Status")).as("REST call failed - Wrong status code.").isEqualTo(200);
Assertions.assertThat(pi.getState()).as("Process did not finish").isEqualTo(ProcessInstance.STATE_COMPLETED);
}
use of org.jbpm.process.workitem.rest.RESTWorkItemHandler in project jbpm by kiegroup.
the class RestServiceInvokeTest method testSecuredFail.
@Test
@RunAsClient
public void testSecuredFail() throws Exception {
System.out.println("### Running proccess ...");
KieSession ksession = getSession(rrs.getResource(RegisterRestService.BPMN_CALL_REST_SERVICE_SIMPLE));
ksession.getWorkItemManager().registerWorkItemHandler("REST", new RESTWorkItemHandler("undefined", "user"));
HashMap<String, Object> arguments = new HashMap<String, Object>();
arguments.put("Url", RegisterRestService.SERVICE_URL + "PersonList/securedPing");
WorkflowProcessInstance pi = (WorkflowProcessInstance) ksession.startProcess(RegisterRestService.PROCESS_CALL_REST_SERVICE_SIMPLE, arguments);
Assertions.assertThat(pi.getVariable("Status")).as("REST call failed").isEqualTo((Object) 401);
Assertions.assertThat(pi.getState()).as("Process did not finish").isEqualTo(ProcessInstance.STATE_COMPLETED);
}
use of org.jbpm.process.workitem.rest.RESTWorkItemHandler in project jbpm by kiegroup.
the class RestServiceInvokeTest method testSecuredGet.
@Test
@RunAsClient
public void testSecuredGet() throws Exception {
System.out.println("### Running proccess ...");
KieSession ksession = getSession(rrs.getResource(RegisterRestService.BPMN_CALL_REST_SERVICE_SIMPLE));
ksession.getWorkItemManager().registerWorkItemHandler("REST", new RESTWorkItemHandler("ibek", "ibek1234;"));
HashMap<String, Object> arguments = new HashMap<String, Object>();
arguments.put("Url", RegisterRestService.SERVICE_URL + "PersonList/securedPing");
WorkflowProcessInstance pi = (WorkflowProcessInstance) ksession.startProcess(RegisterRestService.PROCESS_CALL_REST_SERVICE_SIMPLE, arguments);
Assertions.assertThat(pi.getVariable("Result")).as("REST call failed - Wrong response.").isEqualTo("securedPong");
Assertions.assertThat(pi.getVariable("Status")).as("REST call failed - Wrong status code.").isEqualTo(200);
Assertions.assertThat(pi.getState()).as("Process did not finish").isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Aggregations