use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class JiraWorkitemHandlerTest method testAddComment.
@Test
public void testAddComment() throws Exception {
TestWorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter("IssueKey", "testIssueKey");
workItem.setParameter("Comment", "testComment");
workItem.setParameter("Commenter", "testCommenter");
workItem.setParameter("CommentVisibleTo", "testVisibilityGroup");
AddCommentOnIssueWorkitemHandler handler = new AddCommentOnIssueWorkitemHandler("testusername", "testpassword", "testjiraurl");
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 JiraWorkitemHandlerTest method testJqlSearch.
@Test
public void testJqlSearch() throws Exception {
TestWorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter("SearchQuery", "test jql query");
JqlSearchWorkitemHandler handler = new JqlSearchWorkitemHandler("testusername", "testpassword", "testjiraurl");
handler.setAuth(auth);
handler.executeWorkItem(workItem, manager);
assertNotNull(manager.getResults());
assertEquals(1, manager.getResults().size());
assertTrue(manager.getResults().containsKey(workItem.getId()));
assertTrue((manager.getResults().get(workItem.getId())).get("SearchResults") instanceof Map);
Map<String, String> searchResults = (Map<String, String>) manager.getResults().get(workItem.getId()).get("SearchResults");
assertNotNull(searchResults);
assertEquals(1, searchResults.size());
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class JPAWorkItemHandlerTest method queryWithParameterActionTest.
@Test
public void queryWithParameterActionTest() throws Exception {
WorkItemManager manager = new TestWorkItemManager();
String DESC = "Cheese";
Product p1 = new Product("Bread", 2f);
Product p2 = new Product("Milk", 3f);
Product p3 = new Product(DESC, 5f);
create(p1);
create(p2);
create(p3);
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter(JPAWorkItemHandler.P_ACTION, JPAWorkItemHandler.QUERY_ACTION);
Map<String, Object> params = new HashMap<>();
params.put("desc", DESC);
workItem.setParameter(JPAWorkItemHandler.P_QUERY, "SELECT p FROM Product p where p.description = :desc");
workItem.setParameter(JPAWorkItemHandler.P_QUERY_PARAMS, params);
UserTransaction ut = getUserTransaction();
ut.begin();
handler.executeWorkItem(workItem, manager);
ut.commit();
Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId());
@SuppressWarnings("unchecked") List<Product> products = (List<Product>) results.get(JPAWorkItemHandler.P_QUERY_RESULTS);
assertEquals(1, products.size());
products = getAllProducts();
assertEquals(3, products.size());
for (Product product : products) {
removeProduct(product);
}
products = getAllProducts();
assertEquals(0, products.size());
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class ParserWorkItemHandlerTest method testXmlToObject.
@Test
public void testXmlToObject() {
WorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter(ParserWorkItemHandler.INPUT, PERSON_XML);
workItem.setParameter(ParserWorkItemHandler.FORMAT, ParserWorkItemHandler.XML);
workItem.setParameter(ParserWorkItemHandler.TYPE, "org.jbpm.process.workitem.parser.Person");
handler.executeWorkItem(workItem, manager);
Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId());
Person result = (Person) results.get(ParserWorkItemHandler.RESULT);
assertEquals(AGE, result.getAge());
assertEquals(NAME, result.getName());
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class ParserWorkItemHandlerTest method testJsonToObject.
@Test
public void testJsonToObject() {
WorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter(ParserWorkItemHandler.INPUT, PERSON_JSON);
workItem.setParameter(ParserWorkItemHandler.FORMAT, ParserWorkItemHandler.JSON);
workItem.setParameter(ParserWorkItemHandler.TYPE, "org.jbpm.process.workitem.parser.Person");
handler.executeWorkItem(workItem, manager);
Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId());
Person result = (Person) results.get(ParserWorkItemHandler.RESULT);
assertEquals(AGE, result.getAge());
assertEquals(NAME, result.getName());
}
Aggregations