Search in sources :

Example 6 with ProcessInstanceLog

use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.

the class MigrationManagerTest method testMigrateUserTaskProcessInstance.

@Test
public void testMigrateUserTaskProcessInstance() {
    createRuntimeManagers("migration/v1/BPMN2-UserTask-v1.bpmn2", "migration/v2/BPMN2-UserTask-v2.bpmn2");
    assertNotNull(managerV1);
    assertNotNull(managerV2);
    RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get());
    KieSession ksession = runtime.getKieSession();
    assertNotNull(ksession);
    ProcessInstance pi1 = ksession.startProcess(PROCESS_ID_V1);
    assertNotNull(pi1);
    assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState());
    JPAAuditLogService auditService = new JPAAuditLogService(emf);
    ProcessInstanceLog log = auditService.findProcessInstance(pi1.getId());
    assertNotNull(log);
    assertEquals(PROCESS_ID_V1, log.getProcessId());
    assertEquals(PROCESS_NAME_V1, log.getProcessName());
    assertEquals(DEPLOYMENT_ID_V1, log.getExternalId());
    TaskService taskService = runtime.getTaskService();
    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK");
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    TaskSummary task = tasks.get(0);
    assertNotNull(task);
    assertEquals(PROCESS_ID_V1, task.getProcessId());
    assertEquals(DEPLOYMENT_ID_V1, task.getDeploymentId());
    assertEquals(TASK_NAME_V1, task.getName());
    managerV1.disposeRuntimeEngine(runtime);
    MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, PROCESS_ID_V2);
    MigrationManager migrationManager = new MigrationManager(migrationSpec);
    MigrationReport report = migrationManager.migrate();
    assertNotNull(report);
    assertTrue(report.isSuccessful());
    log = auditService.findProcessInstance(pi1.getId());
    assertNotNull(log);
    assertEquals(PROCESS_ID_V2, log.getProcessId());
    assertEquals(PROCESS_NAME_V2, log.getProcessName());
    assertEquals(DEPLOYMENT_ID_V2, log.getExternalId());
    auditService.dispose();
    runtime = managerV2.getRuntimeEngine(EmptyContext.get());
    taskService = runtime.getTaskService();
    tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK");
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    task = tasks.get(0);
    assertNotNull(task);
    assertEquals(PROCESS_ID_V2, task.getProcessId());
    assertEquals(DEPLOYMENT_ID_V2, task.getDeploymentId());
    // same name as the node mapping was not given
    assertEquals(TASK_NAME_V2, task.getName());
    managerV2.disposeRuntimeEngine(runtime);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) TaskService(org.kie.api.task.TaskService) TaskSummary(org.kie.api.task.model.TaskSummary) 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) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 7 with ProcessInstanceLog

use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.

the class TimerMigrationManagerTest method testMigrateBoundaryTimerProcessInstance.

@Test(timeout = 10000)
public void testMigrateBoundaryTimerProcessInstance() throws Exception {
    NodeLeftCountDownProcessEventListener countdownListener = new NodeLeftCountDownProcessEventListener("GoodbyeV2", 1);
    createRuntimeManagers("migration/v1/BPMN2-TimerBoundary-v1.bpmn2", "migration/v2/BPMN2-TimerBoundary-v2.bpmn2", countdownListener);
    assertNotNull(managerV1);
    assertNotNull(managerV2);
    RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get());
    KieSession ksession = runtime.getKieSession();
    assertNotNull(ksession);
    ProcessInstance pi1 = ksession.startProcess(BOUNDARY_TIMER_ID_V1);
    assertNotNull(pi1);
    assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState());
    JPAAuditLogService auditService = new JPAAuditLogService(emf);
    ProcessInstanceLog log = auditService.findProcessInstance(pi1.getId());
    assertNotNull(log);
    assertEquals(BOUNDARY_TIMER_ID_V1, log.getProcessId());
    assertEquals(DEPLOYMENT_ID_V1, log.getExternalId());
    managerV1.disposeRuntimeEngine(runtime);
    MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, BOUNDARY_TIMER_ID_V2);
    MigrationManager migrationManager = new MigrationManager(migrationSpec);
    MigrationReport report = migrationManager.migrate();
    assertNotNull(report);
    assertTrue(report.isSuccessful());
    log = auditService.findProcessInstance(pi1.getId());
    assertNotNull(log);
    assertEquals(BOUNDARY_TIMER_ID_V2, log.getProcessId());
    assertEquals(DEPLOYMENT_ID_V2, log.getExternalId());
    assertEquals(ProcessInstance.STATE_ACTIVE, log.getStatus().intValue());
    // wait till timer fires
    countdownListener.waitTillCompleted();
    log = auditService.findProcessInstance(pi1.getId());
    auditService.dispose();
    assertNotNull(log);
    assertEquals(BOUNDARY_TIMER_ID_V2, log.getProcessId());
    assertEquals(DEPLOYMENT_ID_V2, log.getExternalId());
    assertEquals(ProcessInstance.STATE_COMPLETED, log.getStatus().intValue());
}
Also used : NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) 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) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 8 with ProcessInstanceLog

use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.

the class AdHocSubprocessAbortRuntimeManagerTest method testAdHocSubprocess.

private void testAdHocSubprocess() {
    RuntimeEngine runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
    KieSession ksession1 = runtime1.getKieSession();
    assertNotNull(ksession1);
    ProcessInstance processInstance = ksession1.startProcess("jbpm-abort-ht-issue.ad-hoc-abort-ht");
    manager.disposeRuntimeEngine(runtime1);
    // then signal via first manager, should only signal instances owned by that manager
    runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstance.getId()));
    ksession1 = runtime1.getKieSession();
    ksession1.addEventListener(new TaskCleanUpProcessEventListener(runtime1.getTaskService()));
    ksession1.signalEvent("Milestone", null, processInstance.getId());
    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());
    auditService.dispose();
    // close manager which will close session maintained by the manager
    manager.close();
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) TaskCleanUpProcessEventListener(org.jbpm.services.task.admin.listener.TaskCleanUpProcessEventListener) 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 9 with ProcessInstanceLog

use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.

the class ProcessInstanceLogCleanTest method deleteLogsByProcessName.

@Test
public void deleteLogsByProcessName() {
    KieSession kieSession = createKSession(HELLO_WORLD_PROCESS);
    startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 2);
    // Check that all records are created.
    List<ProcessInstanceLog> resultList = auditService.processInstanceLogQuery().processId(HELLO_WORLD_PROCESS_ID).processVersion("1.0").build().getResultList();
    Assertions.assertThat(resultList).hasSize(2);
    Assertions.assertThat(resultList).extracting("processName").containsExactly(HELLO_WORLD_P1NAME, HELLO_WORLD_P1NAME);
    // Perform delete
    int resultCount = auditService.processInstanceLogDelete().processName(HELLO_WORLD_P1NAME).build().execute();
    Assertions.assertThat(resultCount).isEqualTo(2);
    // Check that all records are gone
    resultList = auditService.processInstanceLogQuery().processId(HELLO_WORLD_PROCESS_ID).processVersion("1.0").build().getResultList();
    Assertions.assertThat(resultList).hasSize(0);
}
Also used : KieSession(org.kie.api.runtime.KieSession) ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog) Test(org.junit.Test)

Example 10 with ProcessInstanceLog

use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.

the class ProcessInstanceLogCleanTest method deleteLogsByVersion.

@Test
public void deleteLogsByVersion() {
    KieSession kieSession = createKSession(HELLO_WORLD_PROCESS);
    startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 7);
    disposeRuntimeManager();
    kieSession = createKSession(HELLO_WORLD_PROCESS2);
    startProcess(kieSession, HELLO_WORLD_PROCESS2_ID, 2);
    // Delete all logs of version 1.1
    ProcessInstanceLogDeleteBuilder deleteBuilder = auditService.processInstanceLogDelete().processVersion("1.0");
    int deleteResult = deleteBuilder.build().execute();
    Assertions.assertThat(deleteResult).isEqualTo(7);
    // Make sure that the 1.1 version logs are gone
    List<ProcessInstanceLog> resultList = auditService.processInstanceLogQuery().processVersion("1.0").build().getResultList();
    Assertions.assertThat(resultList).hasSize(0);
    // Now check that 1.0 version logs are present
    resultList = auditService.processInstanceLogQuery().processVersion("1.1").build().getResultList();
    Assertions.assertThat(resultList).hasSize(2);
    Assertions.assertThat(resultList).extracting("processVersion").containsExactly("1.1", "1.1");
}
Also used : ProcessInstanceLogDeleteBuilder(org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogDeleteBuilder) KieSession(org.kie.api.runtime.KieSession) ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog) Test(org.junit.Test)

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