Search in sources :

Example 16 with ProcessInstanceLog

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

the class TaskSubjectAndDescriptionTest method testSubjectProperty.

@Test
public void testSubjectProperty() {
    ProcessInstance processInstance = kieSession.startProcess(HUMAN_TASK2_ID);
    List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
    TaskSummary task = list.get(0);
    Task t = taskService.getTaskById(task.getId());
    Assertions.assertThat(task.getDescription()).isEqualTo(EXPECTED_SUBJECT);
    Assertions.assertThat(task.getSubject()).isEqualTo(EXPECTED_SUBJECT);
    Assertions.assertThat(t.getSubject()).isEqualTo(EXPECTED_SUBJECT);
    taskService.start(task.getId(), "john");
    taskService.complete(task.getId(), "john", null);
    ProcessInstanceLog plog = getLogService().findProcessInstance(processInstance.getId());
    Assertions.assertThat(plog.getStatus()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : Task(org.kie.api.task.model.Task) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog) Test(org.junit.Test)

Example 17 with ProcessInstanceLog

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

the class TaskSubjectAndDescriptionTest method testSubjectAndDescriptionProperties.

@Test
public void testSubjectAndDescriptionProperties() {
    ProcessInstance processInstance = kieSession.startProcess(HUMAN_TASK_ID);
    List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
    TaskSummary task = list.get(0);
    Task t = taskService.getTaskById(task.getId());
    Assertions.assertThat(task.getDescription()).isEqualTo("This is description of the human task.");
    Assertions.assertThat(task.getSubject()).isEqualTo(EXPECTED_SUBJECT);
    Assertions.assertThat(t.getSubject()).isEqualTo(EXPECTED_SUBJECT);
    taskService.start(task.getId(), "john");
    taskService.complete(task.getId(), "john", null);
    ProcessInstanceLog plog = getLogService().findProcessInstance(processInstance.getId());
    Assertions.assertThat(plog.getStatus()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : Task(org.kie.api.task.model.Task) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog) Test(org.junit.Test)

Example 18 with ProcessInstanceLog

use of org.kie.api.runtime.manager.audit.ProcessInstanceLog 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)

Example 19 with ProcessInstanceLog

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

the class ProcessInstanceLogCleanTest method deleteLogsByDateRange.

@Test
@BZ("1192498")
public void deleteLogsByDateRange() throws InterruptedException {
    KieSession kieSession = createKSession(PARENT_PROCESS_CALLER, PARENT_PROCESS_INFO, HELLO_WORLD_PROCESS);
    Date date1 = new Date();
    startProcess(kieSession, PARENT_PROCESS_CALLER_ID, 4);
    Date date2 = new Date();
    Thread.sleep(1000);
    startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 2);
    Date date3 = new Date();
    int beforeSize = getProcessInstanceLogSize(getYesterday(), getTomorrow());
    Assertions.assertThat(beforeSize).isEqualTo(10);
    int resultCount = auditService.processInstanceLogDelete().startDateRangeStart(date1).startDateRangeEnd(date2).build().execute();
    // 1 for ReussableSubprocess and 1 for ParentProcessInfo called by it
    Assertions.assertThat(resultCount).isEqualTo(8);
    List<ProcessInstanceLog> resultList = auditService.processInstanceLogQuery().startDateRangeEnd(date3).build().getResultList();
    Assertions.assertThat(resultList).hasSize(2).extracting("processId").containsExactly(HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID);
    int afterSize = getProcessInstanceLogSize(date1, date3);
    Assertions.assertThat(afterSize).isEqualTo(2);
}
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 20 with ProcessInstanceLog

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

the class HumanTaskResolver method testConcurrentInvocationsIncludingUserTasks.

@Test(timeout = 10000)
public void testConcurrentInvocationsIncludingUserTasks() throws Exception {
    CountDownLatch latch = new CountDownLatch(THREADS);
    for (int i = 0; i < THREADS; i++) {
        ProcessRunner pr = new ProcessRunner(i, getEmf(), latch);
        Thread t = new Thread(pr, i + "-process-runner");
        t.start();
    }
    latch.await();
    AuditLogService logService = new JPAAuditLogService(getEmf());
    List<? extends ProcessInstanceLog> logs = logService.findProcessInstances("com.sample.humantask.concurrent");
    assertEquals(2, logs.size());
    for (ProcessInstanceLog log : logs) {
        assertEquals(ProcessInstance.STATE_COMPLETED, log.getStatus().intValue());
    }
    logService.dispose();
}
Also used : JPAAuditLogService(org.jbpm.process.audit.JPAAuditLogService) AuditLogService(org.jbpm.process.audit.AuditLogService) JPAAuditLogService(org.jbpm.process.audit.JPAAuditLogService) CountDownLatch(java.util.concurrent.CountDownLatch) 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