use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.
the class SLATrackingCommandTest method testSLATrackingOnUserTaskSLAMet.
@Test
public void testSLATrackingOnUserTaskSLAMet() throws Exception {
CountDownAsyncJobListener countDownListener = configureListener(1);
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).entityManagerFactory(emf).addAsset(ResourceFactory.newClassPathResource("BPMN2-UserTaskWithSLAOnTask.bpmn2"), ResourceType.BPMN2).addEnvironmentEntry("SLATimerMode", "false").get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
ProcessInstance processInstance = ksession.startProcess("UserTask");
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
List<TaskSummary> tasks = runtime.getTaskService().getTasksAssignedAsPotentialOwner("john", "en-UK");
assertEquals(1, tasks.size());
JPAAuditLogService logService = new JPAAuditLogService(emf);
assertNodeInstanceSLACompliance(logService, processInstance.getId(), "Hello", ProcessInstance.SLA_PENDING);
scheduleSLATracking(manager.getIdentifier());
countDownListener.waitTillCompleted();
assertNodeInstanceSLACompliance(logService, processInstance.getId(), "Hello", ProcessInstance.SLA_PENDING);
runtime.getTaskService().start(tasks.get(0).getId(), "john");
runtime.getTaskService().complete(tasks.get(0).getId(), "john", null);
assertNodeInstanceSLACompliance(logService, processInstance.getId(), "Hello", ProcessInstance.SLA_MET);
}
use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.
the class SLATrackingCommandTest method testSLATrackingOnProcessInstance.
@Test
public void testSLATrackingOnProcessInstance() throws Exception {
CountDownAsyncJobListener countDownListener = configureListener(1);
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).entityManagerFactory(emf).addAsset(ResourceFactory.newClassPathResource("BPMN2-UserTaskWithSLA.bpmn2"), ResourceType.BPMN2).addEnvironmentEntry("SLATimerMode", "false").get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
ProcessInstance processInstance = ksession.startProcess("UserTask");
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
JPAAuditLogService logService = new JPAAuditLogService(emf);
assertProcessInstanceSLACompliance(logService, processInstance.getId(), ProcessInstance.SLA_PENDING);
scheduleSLATracking(manager.getIdentifier());
countDownListener.waitTillCompleted();
assertProcessInstanceSLACompliance(logService, processInstance.getId(), ProcessInstance.SLA_PENDING);
// wait for due date of SLA to pass
Thread.sleep(3000);
countDownListener.reset(1);
scheduleSLATracking(manager.getIdentifier());
countDownListener.waitTillCompleted();
assertProcessInstanceSLACompliance(logService, processInstance.getId(), ProcessInstance.SLA_VIOLATED);
}
use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.
the class ActivityTest method testScriptTaskWithHistoryLog.
@Test
@RequirePersistence
public void testScriptTaskWithHistoryLog() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-ScriptTask.bpmn2");
ksession = createKnowledgeSession(kbase);
ProcessInstance processInstance = ksession.startProcess("ScriptTask");
assertProcessInstanceCompleted(processInstance);
AuditLogService logService = new JPAAuditLogService(ksession.getEnvironment());
List<NodeInstanceLog> logs = logService.findNodeInstances(processInstance.getId());
assertNotNull(logs);
assertEquals(6, logs.size());
for (NodeInstanceLog log : logs) {
assertNotNull(log.getDate());
}
ProcessInstanceLog pilog = logService.findProcessInstance(processInstance.getId());
assertNotNull(pilog);
assertNotNull(pilog.getEnd());
List<ProcessInstanceLog> pilogs = logService.findActiveProcessInstances(processInstance.getProcessId());
assertNotNull(pilogs);
assertEquals(0, pilogs.size());
logService.dispose();
}
use of org.jbpm.process.audit.JPAAuditLogService 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.process.audit.JPAAuditLogService in project jbpm by kiegroup.
the class SignalScopedToRuntimeManagerTest method testSignalEventScopedToOwningRuntimeManager.
private void testSignalEventScopedToOwningRuntimeManager() {
// start first process instance with first manager
RuntimeEngine runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
KieSession ksession1 = runtime1.getKieSession();
assertNotNull(ksession1);
ProcessInstance processInstance = ksession1.startProcess("IntermediateCatchEventWithRef");
manager.disposeRuntimeEngine(runtime1);
// start another process instance of the same process just owned by another manager
RuntimeEngine runtime2 = manager2.getRuntimeEngine(ProcessInstanceIdContext.get());
KieSession ksession2 = runtime2.getKieSession();
assertNotNull(ksession2);
ProcessInstance processInstance2 = ksession2.startProcess("IntermediateCatchEventWithRef");
manager2.disposeRuntimeEngine(runtime2);
// then signal via first manager, should only signal instances owned by that manager
runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstance.getId()));
ksession1 = runtime1.getKieSession();
ksession1.signalEvent("Signal1", "first");
manager.disposeRuntimeEngine(runtime1);
JPAAuditLogService auditService = new JPAAuditLogService(emf);
// process instance 1 should be completed by signal
ProcessInstanceLog pi1Log = auditService.findProcessInstance(processInstance.getId());
assertNotNull(pi1Log);
assertEquals(ProcessInstance.STATE_COMPLETED, pi1Log.getStatus().intValue());
// process instance 2 should still be active
ProcessInstanceLog pi2Log = auditService.findProcessInstance(processInstance2.getId());
assertNotNull(pi2Log);
assertEquals(ProcessInstance.STATE_ACTIVE, pi2Log.getStatus().intValue());
// then signal via second manager, should only signal instances owned by that manager
runtime2 = manager2.getRuntimeEngine(ProcessInstanceIdContext.get(processInstance2.getId()));
ksession2 = runtime2.getKieSession();
ksession2.signalEvent("Signal1", "second");
manager2.disposeRuntimeEngine(runtime2);
pi2Log = auditService.findProcessInstance(processInstance2.getId());
assertNotNull(pi2Log);
assertEquals(ProcessInstance.STATE_COMPLETED, pi2Log.getStatus().intValue());
auditService.dispose();
// close manager which will close session maintained by the manager
manager.close();
}
Aggregations