use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm by kiegroup.
the class BusinessRuleTaskHandlerTest method testDrlStatefulBusinessRuleTaskNoScanner.
@Test
public void testDrlStatefulBusinessRuleTaskNoScanner() {
TestWorkItemManager manager = new TestWorkItemManager();
BusinessRuleTaskHandler handler = new BusinessRuleTaskHandler(GROUP_ID, ARTIFACT_ID, VERSION);
WorkItemImpl workItem = new WorkItemImpl();
workItem.setId(999);
Person person = new Person("john");
workItem.setParameter("person", person);
workItem.setParameter("KieSessionType", BusinessRuleTaskHandler.STATEFULL_TYPE);
handler.executeWorkItem(workItem, manager);
Map<String, Object> results = manager.getResults(workItem.getId());
assertNotNull(results);
assertEquals(1, results.size());
assertEquals(35, ((Person) results.get("person")).getAge().intValue());
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class JiraWorkitemHandlerTest method testResolveIssue.
@Test
public void testResolveIssue() throws Exception {
TestWorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter("IssueKey", "testIssueKey");
workItem.setParameter("Resolution", "testResolved");
workItem.setParameter("ResolutionComment", "testResolutionComment");
ResolveIssueWorkitemHandler handler = new ResolveIssueWorkitemHandler("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 testCreateIssue.
@Test
public void testCreateIssue() throws Exception {
TestWorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter("ProjectKey", "testJiraProject");
workItem.setParameter("IssueSummary", "test issue summary");
workItem.setParameter("IssueDescription", "this is test issue description");
workItem.setParameter("IssueType", "testIssueType");
workItem.setParameter("AssigneeName", "testAssigneeName");
workItem.setParameter("ReporterName", "testReporterName");
workItem.setParameter("ComponentName", "testComponentName");
CreateIssueWorkitemHandler handler = new CreateIssueWorkitemHandler("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("CreatedIssueKey") instanceof String);
String cretedJiraKey = (String) manager.getResults().get(workItem.getId()).get("CreatedIssueKey");
assertNotNull(cretedJiraKey);
assertEquals("testIssueKey", cretedJiraKey);
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class JPAWorkItemHandlerTest method getAllProducts.
private List<Product> getAllProducts() throws Exception {
WorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter(JPAWorkItemHandler.P_ACTION, JPAWorkItemHandler.QUERY_ACTION);
workItem.setParameter(JPAWorkItemHandler.P_QUERY, "SELECT p FROM Product p");
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);
return products;
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class JPAWorkItemHandlerTest method getProduct.
private Product getProduct(String id) throws Exception {
WorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter(JPAWorkItemHandler.P_ACTION, JPAWorkItemHandler.GET_ACTION);
workItem.setParameter(JPAWorkItemHandler.P_TYPE, "org.jbpm.process.workitem.jpa.Product");
workItem.setParameter(JPAWorkItemHandler.P_ID, id);
UserTransaction ut = getUserTransaction();
ut.begin();
handler.executeWorkItem(workItem, manager);
ut.commit();
Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId());
Product product = (Product) results.get(JPAWorkItemHandler.P_RESULT);
return product;
}
Aggregations