use of org.kie.api.runtime.process.WorkItemManager in project jbpm by kiegroup.
the class DataTest method testDataOutputAssociations.
@Test
public void testDataOutputAssociations() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-DataOutputAssociations.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WorkItemHandler() {
public void abortWorkItem(WorkItem manager, WorkItemManager mgr) {
}
public void executeWorkItem(WorkItem workItem, WorkItemManager mgr) {
try {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream("<user hello='hello world' />".getBytes()));
Map<String, Object> params = new HashMap<String, Object>();
params.put("output", document.getFirstChild());
mgr.completeWorkItem(workItem.getId(), params);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
});
ProcessInstance processInstance = ksession.startProcess("process", null);
}
use of org.kie.api.runtime.process.WorkItemManager in project jbpm by kiegroup.
the class DataTest method testDataInputAssociationsWithTwoAssigns.
/**
* TODO testDataInputAssociationsWithTwoAssigns
*/
@Test
@Ignore
public void testDataInputAssociationsWithTwoAssigns() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-DataInputAssociations-two-assigns.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WorkItemHandler() {
public void abortWorkItem(WorkItem manager, WorkItemManager mgr) {
}
public void executeWorkItem(WorkItem workItem, WorkItemManager mgr) {
assertEquals("foo", ((Element) workItem.getParameter("Comment")).getNodeName());
// assertEquals("mynode", ((Element)
// workItem.getParameter("Comment")).getFirstChild().getNodeName());
// assertEquals("user", ((Element)
// workItem.getParameter("Comment")).getFirstChild().getFirstChild().getNodeName());
// assertEquals("hello world", ((Element)
// workItem.getParameter("coId")).getFirstChild().getFirstChild().getAttributes().getNamedItem("hello").getNodeValue());
}
});
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream("<user hello='hello world' />".getBytes()));
Map<String, Object> params = new HashMap<String, Object>();
params.put("instanceMetadata", document.getFirstChild());
ProcessInstance processInstance = ksession.startProcess("process", params);
}
use of org.kie.api.runtime.process.WorkItemManager in project jbpm by kiegroup.
the class DataTest method testDataInputAssociationsWithStringWithoutQuotes.
@Test
public void testDataInputAssociationsWithStringWithoutQuotes() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-DataInputAssociations-string-no-quotes.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WorkItemHandler() {
public void abortWorkItem(WorkItem manager, WorkItemManager mgr) {
}
public void executeWorkItem(WorkItem workItem, WorkItemManager mgr) {
assertEquals("hello", workItem.getParameter("coId"));
}
});
ProcessInstance processInstance = ksession.startProcess("process", null);
}
use of org.kie.api.runtime.process.WorkItemManager in project jbpm by kiegroup.
the class DataTest method testDataInputAssociationsWithLazyLoading.
/**
* TODO testDataInputAssociationsWithLazyLoading
*/
@Test
@Ignore
public void testDataInputAssociationsWithLazyLoading() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-DataInputAssociations-lazy-creating.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WorkItemHandler() {
public void abortWorkItem(WorkItem manager, WorkItemManager mgr) {
}
public void executeWorkItem(WorkItem workItem, WorkItemManager mgr) {
Object coIdParamObj = workItem.getParameter("coId");
assertEquals("mydoc", ((Element) coIdParamObj).getNodeName());
assertEquals("mynode", ((Element) workItem.getParameter("coId")).getFirstChild().getNodeName());
assertEquals("user", ((Element) workItem.getParameter("coId")).getFirstChild().getFirstChild().getNodeName());
assertEquals("hello world", ((Element) workItem.getParameter("coId")).getFirstChild().getFirstChild().getAttributes().getNamedItem("hello").getNodeValue());
}
});
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream("<user hello='hello world' />".getBytes()));
Map<String, Object> params = new HashMap<String, Object>();
params.put("instanceMetadata", document.getFirstChild());
ProcessInstance processInstance = ksession.startProcess("process", params);
}
use of org.kie.api.runtime.process.WorkItemManager in project jbpm by kiegroup.
the class ErrorEventTest method testCatchErrorBoundaryEventOnTask.
@Test
public void testCatchErrorBoundaryEventOnTask() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-ErrorBoundaryEventOnTask.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new TestWorkItemHandler() {
@Override
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
if (workItem.getParameter("ActorId").equals("mary")) {
throw new MyError();
}
}
@Override
public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
manager.abortWorkItem(workItem.getId());
}
});
ProcessInstance processInstance = ksession.startProcess("BPMN2-ErrorBoundaryEventOnTask");
assertProcessInstanceActive(processInstance);
assertNodeTriggered(processInstance.getId(), "start", "split", "User Task", "User task error attached", "Script Task", "error1", "error2");
}
Aggregations