use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.
the class ActivityTest method testCallActivityWithBoundaryErrorEvent.
@Test
public void testCallActivityWithBoundaryErrorEvent() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-CallActivityProcessBoundaryError.bpmn2", "BPMN2-CallActivitySubProcessBoundaryError.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("task1", new SystemOutWorkItemHandler());
ProcessInstance processInstance = ksession.startProcess("ParentProcess");
assertProcessInstanceFinished(processInstance, ksession);
assertNodeTriggered(processInstance.getId(), "StartProcess", "Call Activity 1", "Boundary event", "Task Parent", "End2");
// then check child process executed nodes - is there better way to get child process id than simply increment?
assertNodeTriggered(processInstance.getId() + 1, "StartProcess", "Task 1", "End");
}
use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.
the class StandaloneBPMNProcessTest method testEventBasedSplit5.
@Test
public void testEventBasedSplit5() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-EventBasedSplit5.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
ReceiveTaskHandler receiveTaskHandler = new ReceiveTaskHandler(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
// Yes
ProcessInstance processInstance = ksession.startProcess("com.sample.test");
assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
receiveTaskHandler.setKnowledgeRuntime(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
receiveTaskHandler.messageReceived("YesMessage", "YesValue");
assertProcessInstanceCompleted(processInstance.getId(), ksession);
receiveTaskHandler.messageReceived("NoMessage", "NoValue");
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
receiveTaskHandler.setKnowledgeRuntime(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
// No
processInstance = ksession.startProcess("com.sample.test");
receiveTaskHandler.messageReceived("NoMessage", "NoValue");
assertProcessInstanceCompleted(processInstance.getId(), ksession);
receiveTaskHandler.messageReceived("YesMessage", "YesValue");
}
use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.
the class StandaloneBPMNProcessTest method testEvaluationProcess2.
@Test
public void testEvaluationProcess2() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-EvaluationProcess2.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
Map<String, Object> params = new HashMap<String, Object>();
params.put("employee", "UserId-12345");
ProcessInstance processInstance = ksession.startProcess("com.sample.evaluation", params);
assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.
the class BPMN2DataServicesReferencesTest method testGlobal.
@Test
public void testGlobal() throws IOException {
Assume.assumeTrue("Skip import/global tests", loadGlobalImportProcesses);
String processId = PROC_ID_GLOBAL;
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentId, processId);
assertNotNull(procDef);
// check that process runs
Person person = new Person();
person.setName("Max Rockatansky");
person.setId(1979l);
person.setTime(3l);
KieSession ksession = deploymentService.getRuntimeManager(deploymentId).getRuntimeEngine(null).getKieSession();
ksession.setGlobal("person", person);
ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new SystemOutWorkItemHandler());
Long procId = startProcess(deploymentId, processId);
ProcessInstance procInst = processService.getProcessInstance(procId);
assertNull(procInst);
String log = person.getLog();
assertFalse("Empty log", log == null || log.trim().isEmpty());
assertEquals("Empty log", log.split(":").length, 4);
// verify process information
Collection<String> refClasses = bpmn2Service.getJavaClasses(deploymentId, processId);
assertNotNull("Null set of referenced classes", refClasses);
assertFalse("Empty set of referenced classes", refClasses.isEmpty());
assertEquals("Number referenced classes", 1, refClasses.size());
assertEquals("Imported class in process", refClasses.iterator().next(), Person.class.getName());
}
use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.
the class PersistentStatefulSessionTest method testIntegrationWithEventManager3.
@Test
public void testIntegrationWithEventManager3() {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(new ClassPathResource("WorkItemsProcess.rf"), ResourceType.DRF);
InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addPackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
ksession.getWorkItemManager().registerWorkItemHandler("MyWork", new SystemOutWorkItemHandler());
ProcessInstance processInstance = ksession.startProcess("org.drools.test.TestProcess");
ksession.insert("TestString");
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
List<InstanceView<?>> events = TestEventEmitter.getEvents();
assertNotNull(events);
assertEquals(1, events.size());
}
Aggregations