Search in sources :

Example 11 with ProcessInstanceLog

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

the class ProcessInstanceLogCleanTest method deleteLogsByDate.

@Test
@BZ("1188702")
public void deleteLogsByDate() {
    Date testStartDate = new Date();
    KieSession kieSession = createKSession(HELLO_WORLD_PROCESS);
    startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 4);
    List<ProcessInstanceLog> resultList = auditService.processInstanceLogQuery().startDateRangeStart(testStartDate).build().getResultList();
    Assertions.assertThat(resultList).hasSize(4).extracting("processId").containsExactly(HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID);
    // Delete the last 3 logs in the list
    for (int i = resultList.size() - 1; i > 0; i--) {
        int resultCount = auditService.processInstanceLogDelete().startDate(resultList.get(i).getStart()).build().execute();
        Assertions.assertThat(resultCount).isEqualTo(1);
    }
    // Attempt to delete with a date later than end of all the instances
    int resultCount = auditService.processInstanceLogDelete().startDate(new Date()).build().execute();
    Assertions.assertThat(resultCount).isEqualTo(0);
    // Check the last instance
    List<ProcessInstanceLog> resultList2 = auditService.processInstanceLogQuery().startDateRangeStart(testStartDate).build().getResultList();
    Assertions.assertThat(resultList2).hasSize(1);
    Assertions.assertThat(resultList2.get(0)).isEqualTo(resultList.get(0));
}
Also used : KieSession(org.kie.api.runtime.KieSession) Date(java.util.Date) ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 12 with ProcessInstanceLog

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

the class ProcessInstanceLogCleanTest method deleteLogsByProcessId.

@Test
public void deleteLogsByProcessId() {
    KieSession kieSession = createKSession(HELLO_WORLD_PROCESS);
    startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 3);
    // Check that all records are created.
    List<ProcessInstanceLog> resultList = auditService.processInstanceLogQuery().processName(HELLO_WORLD_P1NAME).processVersion("1.0").build().getResultList();
    Assertions.assertThat(resultList).hasSize(3);
    Assertions.assertThat(resultList).extracting("processId").containsExactly(HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID);
    // Perform delete
    int resultCount = auditService.processInstanceLogDelete().processId(HELLO_WORLD_PROCESS_ID).build().execute();
    Assertions.assertThat(resultCount).isEqualTo(3);
    // Check that all records are gone
    resultList = auditService.processInstanceLogQuery().processName(HELLO_WORLD_P1NAME).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 13 with ProcessInstanceLog

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

the class AsyncThreadContinuationTest method testRepeatIntermediateTimerAfterException.

@Test(timeout = 10000)
public void testRepeatIntermediateTimerAfterException() {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("MySignal", 1, true);
    KieSession ksession = createKSession(BPMN_IT);
    ksession.addEventListener(countDownListener);
    ProcessInstance pi = ksession.startProcess(PROCESS_IT);
    long pid = pi.getId();
    countDownListener.waitTillCompleted();
    pi = ksession.getProcessInstance(pid);
    Assertions.assertThat(pi).isNotNull();
    ksession.abortProcessInstance(pid);
    pi = ksession.getProcessInstance(pid);
    Assertions.assertThat(pi).isNull();
    ProcessInstanceLog log = getLogService().findProcessInstance(pid);
    Assertions.assertThat(log.getStatus()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
Also used : NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) 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)

Example 14 with ProcessInstanceLog

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

the class ConcurrentGlobalTimerServiceTest method testSessionPerProcessInstance.

@Test
public void testSessionPerProcessInstance() throws Exception {
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().entityManagerFactory(emf).userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("org/jbpm/test/functional/timer/IntermediateCatchEventTimerCycleWithHT.bpmn2"), ResourceType.BPMN2).schedulerService(globalScheduler).get();
    long startTimeStamp = System.currentTimeMillis();
    long maxEndTime = startTimeStamp + maxWaitTime;
    manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
    // prepare task service with users and groups
    RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
    TaskService taskService = engine.getTaskService();
    Group grouphr = TaskModelProvider.getFactory().newGroup();
    ((InternalOrganizationalEntity) grouphr).setId("HR");
    User mary = TaskModelProvider.getFactory().newUser();
    ((InternalOrganizationalEntity) mary).setId("mary");
    User john = TaskModelProvider.getFactory().newUser();
    ((InternalOrganizationalEntity) john).setId("john");
    ((InternalTaskService) taskService).addGroup(grouphr);
    ((InternalTaskService) taskService).addUser(mary);
    ((InternalTaskService) taskService).addUser(john);
    manager.disposeRuntimeEngine(engine);
    completedStart = 0;
    for (int i = 0; i < nbThreadsProcess; i++) {
        new StartProcessPerProcessInstanceRunnable(manager, i).run();
    }
    completedTask = 0;
    for (int i = 0; i < nbThreadsTask; i++) {
        new Thread(new CompleteTaskPerProcessInstanceRunnable(manager, i)).start();
    }
    while (completedStart < nbThreadsProcess || completedTask < nbThreadsTask) {
        Thread.sleep(100);
        if (System.currentTimeMillis() > maxEndTime) {
            fail("Failure, did not finish in time most likely hanging");
        }
    }
    // make sure all process instance were completed
    engine = manager.getRuntimeEngine(EmptyContext.get());
    AuditService logService = engine.getAuditService();
    // active
    List<? extends ProcessInstanceLog> logs = logService.findActiveProcessInstances("IntermediateCatchEvent");
    assertNotNull(logs);
    for (ProcessInstanceLog log : logs) {
        logger.debug("Left over {}", log.getProcessInstanceId());
    }
    assertEquals(0, logs.size());
    // completed
    logs = logService.findProcessInstances("IntermediateCatchEvent");
    assertNotNull(logs);
    assertEquals(nbThreadsProcess, logs.size());
    manager.disposeRuntimeEngine(engine);
    logger.debug("Done");
}
Also used : Group(org.kie.api.task.model.Group) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) User(org.kie.api.task.model.User) InternalTaskService(org.kie.internal.task.api.InternalTaskService) TaskService(org.kie.api.task.TaskService) InternalTaskService(org.kie.internal.task.api.InternalTaskService) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) AuditService(org.kie.api.runtime.manager.audit.AuditService) ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog) Test(org.junit.Test)

Example 15 with ProcessInstanceLog

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

the class SLATrackingCommandTest method assertProcessInstanceSLACompliance.

private void assertProcessInstanceSLACompliance(JPAAuditLogService logService, Long processInstanceId, int slaCompliance) {
    List<ProcessInstanceLog> logs = logService.processInstanceLogQuery().processInstanceId(processInstanceId).build().getResultList();
    assertEquals(1, logs.size());
    ProcessInstanceLog log = logs.get(0);
    assertEquals(processInstanceId, log.getProcessInstanceId());
    assertEquals(slaCompliance, ((org.jbpm.process.audit.ProcessInstanceLog) log).getSlaCompliance().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