use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.
the class EndEventTest method testImplicitEndParallel.
@Test
public void testImplicitEndParallel() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-ParallelSplit.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
ProcessInstance processInstance = ksession.startProcess("com.sample.test");
assertProcessInstanceCompleted(processInstance);
}
use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.
the class EndEventTest method testEscalationEndEventProcess.
@Test
public void testEscalationEndEventProcess() throws Exception {
KieBase kbase = createKnowledgeBase("escalation/BPMN2-EscalationEndEvent.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
ProcessInstance processInstance = ksession.startProcess("EscalationEndEvent");
assertProcessInstanceAborted(processInstance);
}
use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.
the class EndEventTest method testSignalEnd.
@Test
public void testSignalEnd() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-SignalEndEvent.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "MyValue");
ksession.startProcess("SignalEndEvent", params);
}
use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.
the class ActivityTest method testProcesWithHumanTaskWithTimer.
@Test(timeout = 10000)
@RequirePersistence
public void testProcesWithHumanTaskWithTimer() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer", 1);
KieBase kbase = createKnowledgeBase("BPMN2-SubProcessWithTimer.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance processInstance = ksession.startProcess("subproc", params);
ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), null);
long sessionId = ksession.getIdentifier();
Environment env = ksession.getEnvironment();
ksession.dispose();
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null, env);
ksession.addEventListener(countDownListener);
countDownListener.waitTillCompleted();
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.
the class TimerCycleOnBinaryPackageTest method testStartTimerCycleFromClassPath.
@Test(timeout = 20000)
public void testStartTimerCycleFromClassPath() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("start", 2);
KieBase kbase = createKnowledgeBase("BPMN2-StartTimerCycle.bpmn2");
try {
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
assertEquals(0, getNumberOfProcessInstances("defaultPackage.TimerProcess"));
long sessionId = ksession.getIdentifier();
Environment env = ksession.getEnvironment();
final List<Long> list = new ArrayList<Long>();
ksession.addEventListener(new DefaultProcessEventListener() {
public void beforeProcessStarted(ProcessStartedEvent event) {
list.add(event.getProcessInstance().getId());
}
});
((SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner()).getKieSession().addEventListener(new TriggerRulesEventListener(ksession));
countDownListener.waitTillCompleted();
assertEquals(2, getNumberOfProcessInstances("defaultPackage.TimerProcess"));
logger.info("dispose");
ksession.dispose();
countDownListener = new NodeLeftCountDownProcessEventListener("start", 2);
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null, env);
ksession.addEventListener(countDownListener);
AuditLoggerFactory.newInstance(Type.JPA, ksession, null);
final List<Long> list2 = new ArrayList<Long>();
ksession.addEventListener(new DefaultProcessEventListener() {
public void beforeProcessStarted(ProcessStartedEvent event) {
list2.add(event.getProcessInstance().getId());
}
});
((SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner()).getKieSession().addEventListener(new TriggerRulesEventListener(ksession));
countDownListener.waitTillCompleted();
ksession.dispose();
assertEquals(4, getNumberOfProcessInstances("defaultPackage.TimerProcess"));
} finally {
ksession = createKnowledgeSession(kbase);
abortProcessInstances(ksession);
ksession.dispose();
}
}
Aggregations