Search in sources :

Example 6 with ProcessInstanceLogQueryBuilder

use of org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder in project jbpm by kiegroup.

the class AuditQueryTest method intersectQueryBuilderTest.

@Test
public void intersectQueryBuilderTest() {
    ProcessInstanceLogQueryBuilder builder = this.processInstanceLogQuery();
    builder.intersect();
    builder.duration(pilTestData[4].getDuration());
    List<org.kie.api.runtime.manager.audit.ProcessInstanceLog> resultList = builder.build().getResultList();
    assertEquals("duration result", 1, resultList.size());
    builder.endDate(pilTestData[5].getEnd());
    resultList = builder.build().getResultList();
    assertEquals("intersect: duration AND end result", 0, resultList.size());
    builder.identity(pilTestData[6].getIdentity());
    resultList = builder.build().getResultList();
    assertEquals("intersect: duration AND end AND identity result", 0, resultList.size());
}
Also used : ProcessInstanceLogQueryBuilder(org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder) ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog) AuditLogServiceTest(org.jbpm.process.audit.AuditLogServiceTest) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 7 with ProcessInstanceLogQueryBuilder

use of org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder in project jbpm by kiegroup.

the class AuditQueryTest method unionQueryBuilderTest.

@Test
public void unionQueryBuilderTest() {
    ProcessInstanceLogQueryBuilder builder = this.processInstanceLogQuery();
    builder.duration(pilTestData[4].getDuration());
    List<org.kie.api.runtime.manager.audit.ProcessInstanceLog> resultList = builder.build().getResultList();
    assertEquals("duration result", 1, resultList.size());
    builder.endDate(pilTestData[5].getEnd(), pilTestData[6].getEnd());
    resultList = builder.build().getResultList();
    assertEquals("union: duration OR end result", 3, resultList.size());
    builder.identity(pilTestData[7].getIdentity(), pilTestData[8].getIdentity());
    resultList = builder.build().getResultList();
    assertEquals("union: duration OR end OR identity result", 5, resultList.size());
}
Also used : ProcessInstanceLogQueryBuilder(org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder) ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog) AuditLogServiceTest(org.jbpm.process.audit.AuditLogServiceTest) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 8 with ProcessInstanceLogQueryBuilder

use of org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder in project jbpm by kiegroup.

the class AuditQueryTest method intersectUnionQueryBuilderTest.

@Test
public void intersectUnionQueryBuilderTest() {
    ProcessInstanceLogQueryBuilder builder = this.processInstanceLogQuery();
    builder.duration(pilTestData[0].getDuration(), pilTestData[2].getDuration());
    List<org.kie.api.runtime.manager.audit.ProcessInstanceLog> resultList = builder.build().getResultList();
    assertEquals("duration result", 3, resultList.size());
    builder.intersect().endDate(pilTestData[0].getEnd());
    resultList = builder.build().getResultList();
    assertEquals("intersect: duration AND end result", 1, resultList.size());
    builder.union().processId(pilTestData[10].getProcessId());
    resultList = builder.build().getResultList();
    assertEquals("intersect/union: duration AND end OR processId result", 1 + 1, resultList.size());
}
Also used : ProcessInstanceLogQueryBuilder(org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder) ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog) AuditLogServiceTest(org.jbpm.process.audit.AuditLogServiceTest) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 9 with ProcessInstanceLogQueryBuilder

use of org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder in project jbpm by kiegroup.

the class ProcessInstanceLogCleanTest method deleteLogsWithStatusActive.

@Test
public void deleteLogsWithStatusActive() {
    KieSession kieSession = null;
    List<ProcessInstance> instanceList1 = null;
    List<ProcessInstance> instanceList2 = null;
    try {
        kieSession = createKSession(HELLO_WORLD_PROCESS, HUMAN_TASK);
        instanceList1 = startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 3);
        instanceList2 = startProcess(kieSession, HUMAN_TASK_ID, 5);
        ProcessInstanceLogDeleteBuilder deleteBuilder = auditService.processInstanceLogDelete().status(ProcessInstance.STATE_ACTIVE);
        int deleteResult = deleteBuilder.build().execute();
        Assertions.assertThat(deleteResult).isEqualTo(5);
        ProcessInstanceLogQueryBuilder queryBuilder = auditService.processInstanceLogQuery().status(ProcessInstance.STATE_COMPLETED);
        List<ProcessInstanceLog> queryList = queryBuilder.build().getResultList();
        Assertions.assertThat(queryList).hasSize(3);
        Assertions.assertThat(queryList).extracting("processId").containsExactly(HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID);
        Assertions.assertThat(queryList).extracting("processVersion").containsExactly("1.0", "1.0", "1.0");
        Assertions.assertThat(queryList).extracting("status").containsExactly(ProcessInstance.STATE_COMPLETED, ProcessInstance.STATE_COMPLETED, ProcessInstance.STATE_COMPLETED);
    } finally {
        if (instanceList2 != null) {
            abortProcess(kieSession, instanceList2);
        }
        if (kieSession != null) {
            kieSession.dispose();
        }
    }
}
Also used : ProcessInstanceLogDeleteBuilder(org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogDeleteBuilder) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) ProcessInstanceLogQueryBuilder(org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder) ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 ProcessInstanceLogQueryBuilder (org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder)9 AuditLogServiceTest (org.jbpm.process.audit.AuditLogServiceTest)7 ProcessInstanceLog (org.jbpm.process.audit.ProcessInstanceLog)7 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)7 Date (java.util.Date)1 QueryBuilderCoverageTestUtil.afterClass (org.jbpm.query.QueryBuilderCoverageTestUtil.afterClass)1 QueryBuilderCoverageTestUtil.beforeClass (org.jbpm.query.QueryBuilderCoverageTestUtil.beforeClass)1 QueryBuilderCoverageTestUtil.queryBuilderCoverageTest (org.jbpm.query.QueryBuilderCoverageTestUtil.queryBuilderCoverageTest)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1 KieSession (org.kie.api.runtime.KieSession)1 ProcessInstanceLog (org.kie.api.runtime.manager.audit.ProcessInstanceLog)1 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)1 CorrelationKey (org.kie.internal.process.CorrelationKey)1 ProcessInstanceLogDeleteBuilder (org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogDeleteBuilder)1