use of org.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.
the class ActivityTest method testCallActivityWithHistoryLog.
@Test
@RequirePersistence
public void testCallActivityWithHistoryLog() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-CallActivity.bpmn2", "BPMN2-CallActivitySubProcess.bpmn2");
ksession = createKnowledgeSession(kbase);
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "oldValue");
ProcessInstance processInstance = ksession.startProcess("ParentProcess", params);
assertProcessInstanceCompleted(processInstance);
assertEquals("new value", ((WorkflowProcessInstance) processInstance).getVariable("y"));
AuditLogService logService = new JPAAuditLogService(ksession.getEnvironment());
List<ProcessInstanceLog> subprocesses = logService.findSubProcessInstances(processInstance.getId());
assertNotNull(subprocesses);
assertEquals(1, subprocesses.size());
logService.dispose();
}
use of org.jbpm.bpmn2.test.RequirePersistence 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.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.
the class IntermediateEventTest method testEventSubprocessTimerCycle.
@Test(timeout = 10000)
@RequirePersistence
public void testEventSubprocessTimerCycle() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Script Task 1", 4);
KieBase kbase = createKnowledgeBase("BPMN2-EventSubprocessTimerCycle.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ProcessInstance processInstance = ksession.startProcess("BPMN2-EventSubprocessTimer");
assertProcessInstanceActive(processInstance);
countDownListener.waitTillCompleted();
WorkItem workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertProcessInstanceFinished(processInstance, ksession);
assertNodeTriggered(processInstance.getId(), "start", "User Task 1", "end", "start-sub", "Script Task 1", "end-sub");
}
use of org.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.
the class IntermediateEventTest method testTimerBoundaryEventCycleISO.
@Test(timeout = 10000)
@RequirePersistence(false)
public void testTimerBoundaryEventCycleISO() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 2);
KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventCycleISO.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent");
assertProcessInstanceActive(processInstance);
countDownListener.waitTillCompleted();
assertProcessInstanceActive(processInstance);
ksession.abortProcessInstance(processInstance.getId());
}
use of org.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.
the class IntermediateEventTest method testIntermediateCatchEventTimerCycleWithErrorWithPersistence.
@Test(timeout = 10000)
@RequirePersistence
public void testIntermediateCatchEventTimerCycleWithErrorWithPersistence() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 2);
KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerCycleWithError.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
ksession.addEventListener(countDownListener);
ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
assertProcessInstanceActive(processInstance);
final long piId = processInstance.getId();
ksession.execute(new ExecutableCommand<Void>() {
public Void execute(Context context) {
StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) ((RegistryContext) context).lookup(KieSession.class);
WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.getProcessInstance(piId);
processInstance.setVariable("x", 0);
return null;
}
});
// now wait for 1 second for timer to trigger
countDownListener.waitTillCompleted();
assertProcessInstanceActive(processInstance);
Integer xValue = ksession.execute(new ExecutableCommand<Integer>() {
public Integer execute(Context context) {
StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) ((RegistryContext) context).lookup(KieSession.class);
WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.getProcessInstance(piId);
return (Integer) processInstance.getVariable("x");
}
});
assertThat(xValue).isEqualTo(2);
ksession.abortProcessInstance(processInstance.getId());
assertProcessInstanceFinished(processInstance, ksession);
}
Aggregations