Search in sources :

Example 21 with ProcessInstanceLog

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());
}
Also used : ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog)

Example 22 with ProcessInstanceLog

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);
    }
}
Also used : KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 23 with ProcessInstanceLog

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();
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JPAAuditLogService(org.jbpm.process.audit.JPAAuditLogService) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog)

Example 24 with ProcessInstanceLog

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();
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) AuditService(org.kie.api.runtime.manager.audit.AuditService) ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest) Test(org.junit.Test)

Example 25 with ProcessInstanceLog

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());
}
Also used : ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog)

Aggregations

ProcessInstanceLog (org.kie.api.runtime.manager.audit.ProcessInstanceLog)30 Test (org.junit.Test)24 KieSession (org.kie.api.runtime.KieSession)23 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)19 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)16 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)12 JPAAuditLogService (org.jbpm.process.audit.JPAAuditLogService)11 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)7 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)6 AuditService (org.kie.api.runtime.manager.audit.AuditService)5 TaskSummary (org.kie.api.task.model.TaskSummary)5 TaskService (org.kie.api.task.TaskService)4 BZ (qa.tools.ikeeper.annotation.BZ)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Task (org.kie.api.task.model.Task)2 ProcessInstanceLogDeleteBuilder (org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogDeleteBuilder)2 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1