use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class GoogleTasksWorkitemHandlerTest method testGetTasks.
@Test
public void testGetTasks() throws Exception {
TestWorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter("NumOfTasks", "10");
GetTasksWorkitemHandler handler = new GetTasksWorkitemHandler("testAppName", "{}");
handler.setAuth(auth);
handler.executeWorkItem(workItem, manager);
assertNotNull(manager.getResults());
assertEquals(1, manager.getResults().size());
assertTrue(manager.getResults().containsKey(workItem.getId()));
List<TaskInfo> returnedTasks = (List<TaskInfo>) (manager.getResults().get(workItem.getId())).get("FoundTasks");
assertNotNull(returnedTasks);
assertEquals(2, returnedTasks.size());
assertEquals("buy groceries", returnedTasks.get(0).getTitle());
assertEquals("pickup kid from school", returnedTasks.get(1).getTitle());
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class GoogleTasksWorkitemHandlerTest method testAddTasks.
@Test
public void testAddTasks() throws Exception {
TestWorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter("TaskName", "buy groceries");
workItem.setParameter("TaskKind", "home task");
AddTaskWorkitemHandler handler = new AddTaskWorkitemHandler("testAppName", "{}");
handler.setAuth(auth);
handler.executeWorkItem(workItem, manager);
assertNotNull(manager.getResults());
assertEquals(1, manager.getResults().size());
assertTrue(manager.getResults().containsKey(workItem.getId()));
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class ParserWorkItemHandlerTest method testObjectToXml.
@Test
public void testObjectToXml() {
WorkItemManager manager = new TestWorkItemManager();
Person p = new Person(NAME, AGE);
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter(ParserWorkItemHandler.INPUT, p);
workItem.setParameter(ParserWorkItemHandler.FORMAT, ParserWorkItemHandler.XML);
handler.executeWorkItem(workItem, manager);
Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId());
String result = (String) results.get(ParserWorkItemHandler.RESULT);
assertEquals(PERSON_XML, result);
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class ParserWorkItemHandlerTest method testObjectToJson.
@Test
public void testObjectToJson() {
WorkItemManager manager = new TestWorkItemManager();
Person p = new Person(NAME, AGE);
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter(ParserWorkItemHandler.INPUT, p);
workItem.setParameter(ParserWorkItemHandler.FORMAT, ParserWorkItemHandler.JSON);
handler.executeWorkItem(workItem, manager);
Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId());
String result = (String) results.get(ParserWorkItemHandler.RESULT);
assertEquals(PERSON_JSON, result);
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class TwitterWorkitemHandlerTest method testUpdateStatusWithMedia.
@Test
public void testUpdateStatusWithMedia() throws Exception {
DocumentImpl testMediaDoc = new DocumentImpl();
testMediaDoc.setContent(new String("Test media to send").getBytes());
testMediaDoc.setName("testMediaToSend.txt");
TestWorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter("StatusUpdate", "testUpdateStatus");
workItem.setParameter("Media", testMediaDoc);
UpdateStatusWorkitemHandler handler = new UpdateStatusWorkitemHandler("testConsumerKey", "testConsumerSecret", "testAccessKey", "testAccessSecret");
handler.setAuth(auth);
handler.executeWorkItem(workItem, manager);
assertNotNull(manager.getResults());
assertEquals(1, manager.getResults().size());
assertTrue(manager.getResults().containsKey(workItem.getId()));
StatusUpdate handlerStatusUpdate = handler.getStatusUpdate();
assertNotNull(handlerStatusUpdate);
assertEquals("testUpdateStatus", handlerStatusUpdate.getStatus());
}
Aggregations