use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class JbpmJUnitBaseTestCase method assertProcessInstanceState.
private void assertProcessInstanceState(long processInstanceId, Integer expectedState, String message) {
if (logService == null) {
throw new IllegalStateException("Audit service has not been initialized. Session persistence is probably " + "not enabled or you are not getting runtime engine using methods from JbpmJUnitBaseTestCase");
}
ProcessInstanceLog log = logService.findProcessInstance(processInstanceId);
assertNotNull("Process instance has not been found", log);
assertEquals(message, expectedState, log.getStatus());
}
use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class MultipleInstancesSubprocessTest method testEntryAndExitScript.
@Test
@BZ("1123789")
public void testEntryAndExitScript() {
createRuntimeManager(ENTRY_AND_EXIT_SCRIPT_PARENT, ENTRY_AND_EXIT_SCRIPT_SUBPROCESS);
KieSession ksession = getRuntimeEngine().getKieSession();
ProcessInstance pi = ksession.startProcess(ENTRY_AND_EXIT_SCRIPT_PARENT_ID);
logger.debug("Process with id = " + pi.getId() + " has just been started.");
List<? extends VariableInstanceLog> varList = getLogService().findVariableInstancesByName("onEntryScriptTriggered", false);
Assertions.assertThat(varList).hasSize(1);
Assertions.assertThat(Boolean.valueOf(varList.get(0).getValue())).isTrue();
varList = getLogService().findVariableInstancesByName("onExitScriptTriggered", false);
Assertions.assertThat(varList).hasSize(1);
Assertions.assertThat(Boolean.valueOf(varList.get(0).getValue())).isTrue();
List<? extends ProcessInstanceLog> processList = getLogService().findProcessInstances(ENTRY_AND_EXIT_SCRIPT_PARENT_ID);
Assertions.assertThat(processList).hasSize(1);
Assertions.assertThat(processList.get(0).getStatus()).isEqualTo(ProcessInstance.STATE_COMPLETED);
processList = getLogService().findProcessInstances(ENTRY_AND_EXIT_SCRIPT_SUBPROCESS_ID);
Assertions.assertThat(processList).hasSize(2);
for (ProcessInstanceLog pil : processList) {
Assertions.assertThat(pil.getStatus()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
}
use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class MultiInstanceCallActivityRuntimeManagerTest method testMultiInstanceCallactivityCompleteAtTheSameTime.
public void testMultiInstanceCallactivityCompleteAtTheSameTime(Context<?> startContext) {
// start first process instance with first manager
RuntimeEngine runtime1 = manager.getRuntimeEngine(startContext);
KieSession ksession1 = runtime1.getKieSession();
assertNotNull(ksession1);
List<String> items = new ArrayList<String>();
for (int i = 0; i < numberOfChildProcesses; i++) {
items.add(i + "");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("items", items);
ProcessInstance processInstance = ksession1.startProcess("test.Parent", params);
manager.disposeRuntimeEngine(runtime1);
countDownListener.waitTillCompleted();
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());
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 PerProcessInstanceRuntimeManagerTest 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().newPerProcessInstanceRuntimeManager(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 MigrationManagerTest method assertMigratedProcessInstance.
protected void assertMigratedProcessInstance(String processId, long processInstanceId, int status) {
ProcessInstanceLog instance = auditService.findProcessInstance(processInstanceId);
assertNotNull(instance);
assertEquals(processId, instance.getProcessId());
assertEquals(DEPLOYMENT_ID_V2, instance.getExternalId());
assertEquals(status, instance.getStatus().intValue());
}
Aggregations