Search in sources :

Example 1 with ProcessInstanceLogQueryBuilder

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

the class AuditQueryCoverageTest method processInstanceLogQueryCoverageTest.

@Test
public void processInstanceLogQueryCoverageTest() {
    ProcessInstanceLogQueryBuilder queryBuilder = this.processInstanceLogQuery();
    Class builderClass = ProcessInstanceLogQueryBuilder.class;
    queryBuilderCoverageTest(queryBuilder, builderClass, inputFiller);
}
Also used : BeforeClass(org.junit.BeforeClass) QueryBuilderCoverageTestUtil.afterClass(org.jbpm.query.QueryBuilderCoverageTestUtil.afterClass) AfterClass(org.junit.AfterClass) QueryBuilderCoverageTestUtil.beforeClass(org.jbpm.query.QueryBuilderCoverageTestUtil.beforeClass) ProcessInstanceLogQueryBuilder(org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder) QueryBuilderCoverageTestUtil.queryBuilderCoverageTest(org.jbpm.query.QueryBuilderCoverageTestUtil.queryBuilderCoverageTest) Test(org.junit.Test)

Example 2 with ProcessInstanceLogQueryBuilder

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

the class AuditQueryTest method rangeQueryBuilderTest.

@Test
public void rangeQueryBuilderTest() {
    ProcessInstanceLogQueryBuilder builder = this.processInstanceLogQuery();
    long duration = pilTestData[5].getDuration();
    builder.intersect().durationMin(duration - 1).durationMax(duration + 1);
    List<org.kie.api.runtime.manager.audit.ProcessInstanceLog> resultList = builder.build().getResultList();
    assertEquals("duration min + max result", 1, resultList.size());
    List<org.kie.api.runtime.manager.audit.ProcessInstanceLog> durationOrderedProcInstLogList = this.processInstanceLogQuery().build().getResultList();
    Collections.sort(durationOrderedProcInstLogList, new Comparator<org.kie.api.runtime.manager.audit.ProcessInstanceLog>() {

        @Override
        public int compare(org.kie.api.runtime.manager.audit.ProcessInstanceLog o1, org.kie.api.runtime.manager.audit.ProcessInstanceLog o2) {
            return o1.getDuration().compareTo(o2.getDuration());
        }
    });
    int lastElemIndex = durationOrderedProcInstLogList.size() - 1;
    builder = this.processInstanceLogQuery();
    long max = durationOrderedProcInstLogList.get(0).getDuration();
    builder.durationMax(max);
    resultList = builder.build().getResultList();
    verifyMaxMinDuration(resultList, MAX, max);
    builder = this.processInstanceLogQuery();
    long min = durationOrderedProcInstLogList.get(lastElemIndex).getDuration();
    builder.durationMin(min);
    resultList = builder.build().getResultList();
    verifyMaxMinDuration(resultList, MIN, min);
    // union max and min
    builder = this.processInstanceLogQuery();
    min = durationOrderedProcInstLogList.get(lastElemIndex).getDuration();
    builder.durationMin(min);
    max = durationOrderedProcInstLogList.get(0).getDuration();
    builder.durationMax(max);
    resultList = builder.build().getResultList();
    for (org.kie.api.runtime.manager.audit.ProcessInstanceLog log : resultList) {
        long dur = log.getDuration();
        assertTrue("Duration " + dur + " is neither larger than min + " + min + " nor smaller than max" + max, dur >= min || dur <= max);
    }
    // empty intersection (larger than large min, smaller than small max )
    builder = this.processInstanceLogQuery().intersect();
    min = durationOrderedProcInstLogList.get(lastElemIndex).getDuration();
    builder.durationMin(min);
    max = durationOrderedProcInstLogList.get(0).getDuration();
    builder.durationMax(max);
    resultList = builder.build().getResultList();
    verifyMaxMinDuration(resultList, BOTH, min, max);
    builder = this.processInstanceLogQuery().intersect();
    min = durationOrderedProcInstLogList.get(2).getDuration();
    max = durationOrderedProcInstLogList.get(3).getDuration();
    builder.durationMin(min);
    builder.durationMax(max);
    resultList = builder.build().getResultList();
    // there are 2 ProcessInstanceLog's with the same duration
    verifyMaxMinDuration(resultList, BOTH, min, max);
}
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 3 with ProcessInstanceLogQueryBuilder

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

the class AuditQueryTest method orderByQueryBuilderTest.

@Test
public void orderByQueryBuilderTest() {
    ProcessInstanceLogQueryBuilder builder = this.processInstanceLogQuery();
    builder.ascending(OrderBy.processInstanceId);
    List<org.kie.api.runtime.manager.audit.ProcessInstanceLog> resultList = builder.build().getResultList();
    for (int i = 1; i < resultList.size(); ++i) {
        ProcessInstanceLog pilB = (ProcessInstanceLog) resultList.get(i);
        ProcessInstanceLog pilA = (ProcessInstanceLog) resultList.get(i - 1);
        assertTrue("order by asc process instance id failed: " + pilA.getProcessInstanceId() + " ? " + pilB.getProcessInstanceId(), pilA.getProcessInstanceId() <= pilB.getProcessInstanceId());
    }
    builder.descending(OrderBy.processInstanceId);
    resultList = builder.build().getResultList();
    for (int i = 1; i < resultList.size(); ++i) {
        ProcessInstanceLog pilB = (ProcessInstanceLog) resultList.get(i);
        ProcessInstanceLog pilA = (ProcessInstanceLog) resultList.get(i - 1);
        assertTrue("order by desc process instance id failed: " + pilA.getProcessInstanceId() + " ? " + pilB.getProcessInstanceId(), pilA.getProcessInstanceId() >= pilB.getProcessInstanceId());
    }
    builder.ascending(OrderBy.processId);
    resultList = builder.build().getResultList();
    for (int i = 1; i < resultList.size(); ++i) {
        ProcessInstanceLog pilA = (ProcessInstanceLog) resultList.get(i - 1);
        ProcessInstanceLog pilB = (ProcessInstanceLog) resultList.get(i);
        assertTrue("order by asc process id failed: " + pilA.getProcessId() + " ? " + pilB.getProcessId(), pilA.getProcessId().compareTo(pilB.getProcessId()) <= 0);
    }
    builder.descending(OrderBy.processId);
    resultList = builder.build().getResultList();
    for (int i = 1; i < resultList.size(); ++i) {
        ProcessInstanceLog pilA = (ProcessInstanceLog) resultList.get(i - 1);
        ProcessInstanceLog pilB = (ProcessInstanceLog) resultList.get(i);
        assertTrue("order by desc process id failed: " + pilA.getProcessId() + " ? " + pilB.getProcessId(), pilA.getProcessId().compareTo(pilB.getProcessId()) >= 0);
    }
}
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 4 with ProcessInstanceLogQueryBuilder

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

the class AuditQueryTest method likeRegexQueryBuilderTest.

@Test
public void likeRegexQueryBuilderTest() {
    ProcessInstanceLogQueryBuilder builder = this.processInstanceLogQuery();
    builder.regex();
    boolean parameterFailed = false;
    try {
        builder.duration(pilTestData[0].getDuration(), pilTestData[2].getDuration());
    } catch (Exception e) {
        parameterFailed = true;
    }
    assertTrue("adding critera should have failed because of like()", parameterFailed);
    String regex = pilTestData[0].getIdentity();
    builder.identity(regex);
    List<org.kie.api.runtime.manager.audit.ProcessInstanceLog> resultList = builder.build().getResultList();
    assertEquals("literal regex identity result", 1, resultList.size());
    String externalId = resultList.get(0).getExternalId();
    builder = this.processInstanceLogQuery();
    regex = regex.substring(0, regex.length() - 1) + ".";
    builder.regex().identity(regex);
    resultList = builder.build().getResultList();
    assertEquals("literal regex identity result", 1, resultList.size());
    assertEquals(externalId, resultList.get(0).getExternalId());
    builder = this.processInstanceLogQuery();
    regex = regex.substring(0, 10) + "*";
    builder.regex().identity(regex);
    resultList = builder.build().getResultList();
    assertEquals("literal regex identity result", 1, resultList.size());
    assertEquals(externalId, resultList.get(0).getExternalId());
    builder = this.processInstanceLogQuery();
    String regex2 = "*" + pilTestData[0].getIdentity().substring(10);
    builder.regex().intersect().identity(regex, regex2);
    resultList = builder.build().getResultList();
    assertEquals("literal regex identity result", 1, resultList.size());
    assertEquals(externalId, resultList.get(0).getExternalId());
    builder = this.processInstanceLogQuery();
    regex2 = "*" + pilTestData[5].getIdentity().substring(10);
    builder.regex().intersect().identity(regex, regex2);
    resultList = builder.build().getResultList();
    assertEquals("literal regex identity result", 0, resultList.size());
    builder = this.processInstanceLogQuery();
    builder.regex().union().identity(regex, regex2);
    resultList = builder.build().getResultList();
    assertEquals("literal regex identity result", 2, resultList.size());
    builder = this.processInstanceLogQuery();
    builder.regex().union().identity("*");
    resultList = builder.build().getResultList();
    assertEquals("literal regex identity result", this.processInstanceLogQuery().build().getResultList().size(), 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 5 with ProcessInstanceLogQueryBuilder

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

the class AuditQueryTest method simpleProcessInstanceLogQueryBuilderTest.

@Test
public void simpleProcessInstanceLogQueryBuilderTest() {
    int p = 0;
    long duration = pilTestData[p++].getDuration();
    ProcessInstanceLogQueryBuilder builder = this.processInstanceLogQuery().duration(duration);
    List<org.kie.api.runtime.manager.audit.ProcessInstanceLog> resultList = builder.build().getResultList();
    assertEquals("duration query result", 2, resultList.size());
    {
        Date end = pilTestData[p++].getEnd();
        builder = this.processInstanceLogQuery().endDate(end);
        resultList = builder.build().getResultList();
        assertEquals("end date query result", 2, resultList.size());
    }
    {
        String identity = pilTestData[p++].getIdentity();
        builder = this.processInstanceLogQuery().identity(identity);
        resultList = builder.build().getResultList();
        assertEquals("identity query result", 2, resultList.size());
    }
    {
        String processId = pilTestData[p++].getProcessId();
        builder = this.processInstanceLogQuery().processId(processId);
        resultList = builder.build().getResultList();
        assertEquals("process id query result", 2, resultList.size());
    }
    {
        long processInstanceId = pilTestData[p++].getProcessInstanceId();
        builder = this.processInstanceLogQuery().processInstanceId(processInstanceId);
        resultList = builder.build().getResultList();
        assertEquals("process instance id query result", 2, resultList.size());
    }
    {
        String processName = pilTestData[p++].getProcessName();
        builder = this.processInstanceLogQuery().processName(processName);
        resultList = builder.build().getResultList();
        assertEquals("process name query result", 2, resultList.size());
    }
    {
        String version = pilTestData[p++].getProcessVersion();
        builder = this.processInstanceLogQuery().processVersion(version);
        resultList = builder.build().getResultList();
        assertEquals("process version query result", 2, resultList.size());
    }
    {
        Date start = pilTestData[p++].getStart();
        builder = this.processInstanceLogQuery().startDate(start);
        resultList = builder.build().getResultList();
        assertEquals("start date query result", 2, resultList.size());
    }
    {
        int status = pilTestData[p++].getStatus();
        builder = this.processInstanceLogQuery().status(status);
        resultList = builder.build().getResultList();
        assertEquals("status query result", 2, resultList.size());
    }
    {
        String outcome = pilTestData[p++].getOutcome();
        builder = this.processInstanceLogQuery().outcome(outcome);
        resultList = builder.build().getResultList();
        assertEquals("outcome query result", 2, resultList.size());
    }
    {
        String correlationKey = pilTestData[p++].getCorrelationKey();
        CorrelationKey ck = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey(correlationKey);
        builder = this.processInstanceLogQuery().correlationKey(ck);
        resultList = builder.build().getResultList();
        assertEquals("identity query result", 1, resultList.size());
    }
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) ProcessInstanceLogQueryBuilder(org.kie.internal.runtime.manager.audit.query.ProcessInstanceLogQueryBuilder) ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog) Date(java.util.Date) AuditLogServiceTest(org.jbpm.process.audit.AuditLogServiceTest) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

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