use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class PerProcessInstanceRuntimeManagerTest method testErrorThrowOfChildProcessOnParent.
@Test
public void testErrorThrowOfChildProcessOnParent() {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("reusable-subprocess/ParentError.bpmn2"), ResourceType.BPMN2).addAsset(ResourceFactory.newClassPathResource("reusable-subprocess/ChildError.bpmn2"), ResourceType.BPMN2).get();
manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
ksession.startProcess("ParentError");
List<? extends ProcessInstanceLog> processInstanceLogs = runtime.getAuditService().findProcessInstances();
assertEquals(2, processInstanceLogs.size());
for (ProcessInstanceLog log : processInstanceLogs) {
if (log.getProcessId().equals("ParentError")) {
assertEquals(ProcessInstance.STATE_COMPLETED, log.getStatus().intValue());
} else if (log.getProcessId().equals("ChildError")) {
assertEquals(ProcessInstance.STATE_ABORTED, log.getStatus().intValue());
}
}
manager.disposeRuntimeEngine(runtime);
manager.close();
}
use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class PerRequestRuntimeManagerTest method testSignalEventViaRuntimeManager.
@Test
public void testSignalEventViaRuntimeManager() {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2IntermediateThrowEventScope.bpmn2"), ResourceType.BPMN2).get();
manager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
KieSession ksession1 = runtime1.getKieSession();
assertNotNull(ksession1);
ProcessInstance processInstance = ksession1.startProcess("intermediate-event-scope");
manager.disposeRuntimeEngine(runtime1);
RuntimeEngine runtime2 = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
KieSession ksession2 = runtime2.getKieSession();
assertNotNull(ksession2);
ProcessInstance processInstance2 = ksession2.startProcess("intermediate-event-scope");
manager.disposeRuntimeEngine(runtime2);
runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstance.getId()));
List<Long> tasks1 = runtime1.getTaskService().getTasksByProcessInstanceId(processInstance.getId());
assertNotNull(tasks1);
assertEquals(1, tasks1.size());
runtime2 = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstance2.getId()));
List<Long> tasks2 = runtime1.getTaskService().getTasksByProcessInstanceId(processInstance2.getId());
assertNotNull(tasks2);
assertEquals(1, tasks2.size());
Object data = "some data";
runtime1.getTaskService().claim(tasks1.get(0), "john");
runtime1.getTaskService().start(tasks1.get(0), "john");
runtime1.getTaskService().complete(tasks1.get(0), "john", Collections.singletonMap("_output", data));
manager.disposeRuntimeEngine(runtime1);
manager.disposeRuntimeEngine(runtime2);
runtime2 = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstance2.getId()));
AuditService auditService = runtime2.getAuditService();
ProcessInstanceLog pi1Log = auditService.findProcessInstance(processInstance.getId());
assertNotNull(pi1Log);
assertEquals(ProcessInstance.STATE_COMPLETED, pi1Log.getStatus().intValue());
ProcessInstanceLog pi2Log = auditService.findProcessInstance(processInstance2.getId());
assertNotNull(pi2Log);
assertEquals(ProcessInstance.STATE_ACTIVE, pi2Log.getStatus().intValue());
List<? extends NodeInstanceLog> nLogs = auditService.findNodeInstances(processInstance2.getId(), "_527AF0A7-D741-4062-9953-A05E51479C80");
assertNotNull(nLogs);
assertEquals(2, nLogs.size());
auditService.dispose();
// dispose session that should not have affect on the session at all
manager.disposeRuntimeEngine(runtime1);
manager.disposeRuntimeEngine(runtime2);
// close manager which will close session maintained by the manager
manager.close();
}
use of org.kie.api.runtime.manager.audit.ProcessInstanceLog 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();
}
use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class SingletonRuntimeManagerTest method testSignalEventViaRuntimeManager.
@Test
public void testSignalEventViaRuntimeManager() {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2IntermediateThrowEventScope.bpmn2"), ResourceType.BPMN2).get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime1 = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession1 = runtime1.getKieSession();
assertNotNull(ksession1);
ProcessInstance processInstance = ksession1.startProcess("intermediate-event-scope");
RuntimeEngine runtime2 = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession2 = runtime2.getKieSession();
assertNotNull(ksession2);
ProcessInstance processInstance2 = ksession2.startProcess("intermediate-event-scope");
List<Long> tasks1 = runtime1.getTaskService().getTasksByProcessInstanceId(processInstance.getId());
assertNotNull(tasks1);
assertEquals(1, tasks1.size());
List<Long> tasks2 = runtime1.getTaskService().getTasksByProcessInstanceId(processInstance2.getId());
assertNotNull(tasks2);
assertEquals(1, tasks2.size());
Object data = "some data";
runtime1.getTaskService().claim(tasks1.get(0), "john");
runtime1.getTaskService().start(tasks1.get(0), "john");
runtime1.getTaskService().complete(tasks1.get(0), "john", Collections.singletonMap("_output", data));
AuditService auditService = runtime1.getAuditService();
ProcessInstanceLog pi1Log = auditService.findProcessInstance(processInstance.getId());
assertNotNull(pi1Log);
assertEquals(ProcessInstance.STATE_COMPLETED, pi1Log.getStatus().intValue());
ProcessInstanceLog pi2Log = auditService.findProcessInstance(processInstance2.getId());
assertNotNull(pi2Log);
assertEquals(ProcessInstance.STATE_ACTIVE, pi2Log.getStatus().intValue());
List<? extends NodeInstanceLog> nLogs = auditService.findNodeInstances(processInstance2.getId(), "_527AF0A7-D741-4062-9953-A05E51479C80");
assertNotNull(nLogs);
assertEquals(2, nLogs.size());
auditService.dispose();
// dispose session that should not have affect on the session at all
manager.disposeRuntimeEngine(runtime1);
manager.disposeRuntimeEngine(runtime2);
// close manager which will close session maintained by the manager
manager.close();
}
use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class TimerInitFailureRuntimeManagerTest method testPerCaseRuntimeManager.
@Test(timeout = 10000)
@BMScript(value = "byteman-scripts/failOnRuntimeManagerInitRules.btm")
public void testPerCaseRuntimeManager() throws Exception {
final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Intermediate Catch Event 1", 1);
RuntimeEnvironment environment = createEnvironment(countDownListener);
manager = RuntimeManagerFactory.Factory.get().newPerCaseRuntimeManager(environment, "first");
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(CaseContext.get("CASE-001"));
KieSession ksession = runtime.getKieSession();
// start a new process instance
Map<String, Object> params = new HashMap<>();
ProcessInstance pi = ksession.startProcess("TimerInitFailure", params);
assertEquals(ProcessInstance.STATE_ACTIVE, pi.getState());
manager.disposeRuntimeEngine(runtime);
countDownListener.waitTillCompleted();
// User access
runtime = manager.getRuntimeEngine(CaseContext.get("CASE-001"));
runtime.getKieSession();
TaskService taskService = runtime.getTaskService();
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
assertEquals(1, list.size());
long taskId = list.get(0).getId();
taskService.start(taskId, "john");
taskService.complete(taskId, "john", null);
manager.disposeRuntimeEngine(runtime);
runtime = manager.getRuntimeEngine(CaseContext.get("CASE-001"));
AuditService auditService = runtime.getAuditService();
ProcessInstanceLog log = auditService.findProcessInstance(pi.getId());
assertEquals(ProcessInstance.STATE_COMPLETED, log.getStatus().intValue());
auditService.dispose();
manager.disposeRuntimeEngine(runtime);
}
Aggregations