Search in sources :

Example 11 with TestWorkItemManager

use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm by kiegroup.

the class RestWorkItemHandlerTest method testGETOperationWithQueryParam.

@Test
public void testGETOperationWithQueryParam() {
    RESTWorkItemHandler handler = new RESTWorkItemHandler();
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setParameter("Url", serverURL + "?param=test");
    workItem.setParameter("Method", "GET");
    WorkItemManager manager = new TestWorkItemManager();
    handler.executeWorkItem(workItem, manager);
    Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId());
    String result = (String) results.get(PARAM_RESULT);
    assertNotNull("result cannot be null", result);
    assertEquals("Hello from REST test", result);
    int responseCode = (Integer) results.get(PARAM_STATUS);
    assertNotNull(responseCode);
    assertEquals(200, responseCode);
    String responseMsg = (String) results.get(PARAM_STATUS_MSG);
    assertNotNull(responseMsg);
    assertEquals("request to endpoint " + workItem.getParameter("Url") + " successfully completed OK", responseMsg);
}
Also used : TestWorkItemManager(org.jbpm.process.workitem.core.TestWorkItemManager) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItemManager(org.kie.api.runtime.process.WorkItemManager) TestWorkItemManager(org.jbpm.process.workitem.core.TestWorkItemManager) Test(org.junit.Test)

Example 12 with TestWorkItemManager

use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm by kiegroup.

the class RestWorkItemHandlerTest method testGETOperationWithJSONHeader.

@Test
public void testGETOperationWithJSONHeader() {
    RESTWorkItemHandler handler = new RESTWorkItemHandler();
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setParameter("Url", serverURL);
    workItem.setParameter("Method", "GET");
    workItem.setParameter("AcceptHeader", "application/json");
    WorkItemManager manager = new TestWorkItemManager();
    handler.executeWorkItem(workItem, manager);
    Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId());
    int responseCode = (Integer) results.get(PARAM_STATUS);
    assertNotNull(responseCode);
    assertEquals(406, responseCode);
    String responseMsg = (String) results.get(PARAM_STATUS_MSG);
    assertNotNull(responseMsg);
    assertEquals("endpoint " + serverURL + " could not be reached: ", responseMsg);
}
Also used : TestWorkItemManager(org.jbpm.process.workitem.core.TestWorkItemManager) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItemManager(org.kie.api.runtime.process.WorkItemManager) TestWorkItemManager(org.jbpm.process.workitem.core.TestWorkItemManager) Test(org.junit.Test)

Example 13 with TestWorkItemManager

use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm by kiegroup.

the class RestWorkItemHandlerTest method testGETOperationWithXmlCharsetTrasformation.

@Test
public void testGETOperationWithXmlCharsetTrasformation() {
    RESTWorkItemHandler handler = new RESTWorkItemHandler();
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setParameter("Url", serverURL + "/xml-charset");
    workItem.setParameter("Method", "GET");
    workItem.setParameter("ResultClass", Person.class.getName());
    WorkItemManager manager = new TestWorkItemManager();
    handler.executeWorkItem(workItem, manager);
    Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId());
    Person result = (Person) results.get(PARAM_RESULT);
    assertNotNull("result cannot be null", result);
    assertEquals("Person Xml", result.getName());
    int responseCode = (Integer) results.get(PARAM_STATUS);
    assertNotNull(responseCode);
    assertEquals(200, responseCode);
    String responseMsg = (String) results.get(PARAM_STATUS_MSG);
    assertNotNull(responseMsg);
    assertEquals("request to endpoint " + workItem.getParameter("Url") + " successfully completed OK", responseMsg);
}
Also used : TestWorkItemManager(org.jbpm.process.workitem.core.TestWorkItemManager) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItemManager(org.kie.api.runtime.process.WorkItemManager) TestWorkItemManager(org.jbpm.process.workitem.core.TestWorkItemManager) Test(org.junit.Test)

Example 14 with TestWorkItemManager

use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm by kiegroup.

the class RestWorkItemHandlerTest method testPOSTOperationWithXMLHeader.

@Test
public void testPOSTOperationWithXMLHeader() {
    RESTWorkItemHandler handler = new RESTWorkItemHandler();
    String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<person><age>25</age><name>Post john</name></person>";
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setParameter("Url", serverURL + "/xml");
    workItem.setParameter("Method", "POST");
    workItem.setParameter(PARAM_CONTENT_TYPE, "application/xml");
    workItem.setParameter(contentParamName, "<person><name>john</name><age>25</age></person>");
    workItem.setParameter("AcceptHeader", "application/xml");
    WorkItemManager manager = new TestWorkItemManager();
    handler.executeWorkItem(workItem, manager);
    Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId());
    String result = (String) results.get(PARAM_RESULT);
    assertNotNull("result cannot be null", result);
    assertEquals(expected, result);
    int responseCode = (Integer) results.get(PARAM_STATUS);
    assertNotNull(responseCode);
    assertEquals(200, responseCode);
    String responseMsg = (String) results.get(PARAM_STATUS_MSG);
    assertNotNull(responseMsg);
    assertEquals("request to endpoint " + workItem.getParameter("Url") + " successfully completed OK", responseMsg);
}
Also used : TestWorkItemManager(org.jbpm.process.workitem.core.TestWorkItemManager) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItemManager(org.kie.api.runtime.process.WorkItemManager) TestWorkItemManager(org.jbpm.process.workitem.core.TestWorkItemManager) Test(org.junit.Test)

Example 15 with TestWorkItemManager

use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm by kiegroup.

the class RestWorkItemHandlerTest method testGETOperationWithJsonCharsetTrasformation.

@Test
public void testGETOperationWithJsonCharsetTrasformation() {
    RESTWorkItemHandler handler = new RESTWorkItemHandler();
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setParameter("Url", serverURL + "/json-charset");
    workItem.setParameter("Method", "GET");
    workItem.setParameter("ResultClass", Person.class.getName());
    WorkItemManager manager = new TestWorkItemManager();
    handler.executeWorkItem(workItem, manager);
    Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId());
    Person result = (Person) results.get(PARAM_RESULT);
    assertNotNull("result cannot be null", result);
    assertEquals("Person Json", result.getName());
    int responseCode = (Integer) results.get(PARAM_STATUS);
    assertNotNull(responseCode);
    assertEquals(200, responseCode);
    String responseMsg = (String) results.get(PARAM_STATUS_MSG);
    assertNotNull(responseMsg);
    assertEquals("request to endpoint " + workItem.getParameter("Url") + " successfully completed OK", responseMsg);
}
Also used : TestWorkItemManager(org.jbpm.process.workitem.core.TestWorkItemManager) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItemManager(org.kie.api.runtime.process.WorkItemManager) TestWorkItemManager(org.jbpm.process.workitem.core.TestWorkItemManager) Test(org.junit.Test)

Aggregations

WorkItemImpl (org.drools.core.process.instance.impl.WorkItemImpl)81 TestWorkItemManager (org.jbpm.process.workitem.core.TestWorkItemManager)81 Test (org.junit.Test)79 WorkItemManager (org.kie.api.runtime.process.WorkItemManager)36 AbstractBaseTest (org.jbpm.test.AbstractBaseTest)19 Matchers.anyString (org.mockito.Matchers.anyString)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 List (java.util.List)7 DocumentImpl (org.jbpm.document.service.impl.DocumentImpl)6 ArrayList (java.util.ArrayList)5 File (java.io.File)3 UserTransaction (javax.transaction.UserTransaction)3 Person (org.jbpm.process.workitem.bpmn2.objects.Person)3 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)2 Document (org.jbpm.document.Document)2 StatusUpdate (twitter4j.StatusUpdate)2 CalendarList (com.google.api.services.calendar.model.CalendarList)1 TaskList (com.google.api.services.tasks.model.TaskList)1 XmlReader (com.sun.syndication.io.XmlReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1