Search in sources :

Example 21 with JPAAuditLogService

use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.

the class SLATrackingCommandTest method testSLATrackingOnUserTask.

@Test
public void testSLATrackingOnUserTask() throws Exception {
    CountDownAsyncJobListener countDownListener = configureListener(1);
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).entityManagerFactory(emf).addAsset(ResourceFactory.newClassPathResource("BPMN2-UserTaskWithSLAOnTask.bpmn2"), ResourceType.BPMN2).addEnvironmentEntry("SLATimerMode", "false").get();
    manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
    assertNotNull(manager);
    RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
    KieSession ksession = runtime.getKieSession();
    assertNotNull(ksession);
    ProcessInstance processInstance = ksession.startProcess("UserTask");
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    List<TaskSummary> tasks = runtime.getTaskService().getTasksAssignedAsPotentialOwner("john", "en-UK");
    assertEquals(1, tasks.size());
    JPAAuditLogService logService = new JPAAuditLogService(emf);
    assertNodeInstanceSLACompliance(logService, processInstance.getId(), "Hello", ProcessInstance.SLA_PENDING);
    scheduleSLATracking(manager.getIdentifier());
    countDownListener.waitTillCompleted();
    assertNodeInstanceSLACompliance(logService, processInstance.getId(), "Hello", ProcessInstance.SLA_PENDING);
    // wait for due date of SLA to pass
    Thread.sleep(3000);
    countDownListener.reset(1);
    scheduleSLATracking(manager.getIdentifier());
    countDownListener.waitTillCompleted();
    runtime.getTaskService().start(tasks.get(0).getId(), "john");
    runtime.getTaskService().complete(tasks.get(0).getId(), "john", null);
    assertNodeInstanceSLACompliance(logService, processInstance.getId(), "Hello", ProcessInstance.SLA_VIOLATED);
}
Also used : CountDownAsyncJobListener(org.jbpm.executor.test.CountDownAsyncJobListener) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) 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) Test(org.junit.Test) AbstractExecutorBaseTest(org.jbpm.test.util.AbstractExecutorBaseTest)

Example 22 with JPAAuditLogService

use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.

the class SLATrackingCommandTest method testSLATrackingOnProcessInstanceSLAMet.

@Test
public void testSLATrackingOnProcessInstanceSLAMet() throws Exception {
    CountDownAsyncJobListener countDownListener = configureListener(1);
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).entityManagerFactory(emf).addAsset(ResourceFactory.newClassPathResource("BPMN2-UserTaskWithSLA.bpmn2"), ResourceType.BPMN2).addEnvironmentEntry("SLATimerMode", "false").get();
    manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
    assertNotNull(manager);
    RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
    KieSession ksession = runtime.getKieSession();
    assertNotNull(ksession);
    ProcessInstance processInstance = ksession.startProcess("UserTask");
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    List<TaskSummary> tasks = runtime.getTaskService().getTasksAssignedAsPotentialOwner("john", "en-UK");
    assertEquals(1, tasks.size());
    JPAAuditLogService logService = new JPAAuditLogService(emf);
    assertProcessInstanceSLACompliance(logService, processInstance.getId(), ProcessInstance.SLA_PENDING);
    scheduleSLATracking(manager.getIdentifier());
    countDownListener.waitTillCompleted();
    assertProcessInstanceSLACompliance(logService, processInstance.getId(), ProcessInstance.SLA_PENDING);
    runtime.getTaskService().start(tasks.get(0).getId(), "john");
    runtime.getTaskService().complete(tasks.get(0).getId(), "john", null);
    assertProcessInstanceSLACompliance(logService, processInstance.getId(), ProcessInstance.SLA_MET);
}
Also used : CountDownAsyncJobListener(org.jbpm.executor.test.CountDownAsyncJobListener) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) 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) Test(org.junit.Test) AbstractExecutorBaseTest(org.jbpm.test.util.AbstractExecutorBaseTest)

Example 23 with JPAAuditLogService

use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.

the class LogCleanupCommandTest method setUp.

// ------------------------ Test Methods ------------------------
@Override
public void setUp() throws Exception {
    super.setUp();
    taskAuditService = new TaskJPAAuditService(getEmf());
    taskAuditService.clear();
    auditLogService = new JPAAuditLogService(getEmf());
    auditLogService.clear();
    emfErrors = EntityManagerFactoryManager.get().getOrCreate("org.jbpm.persistence.complete");
}
Also used : JPAAuditLogService(org.jbpm.process.audit.JPAAuditLogService) TaskJPAAuditService(org.jbpm.services.task.audit.service.TaskJPAAuditService)

Example 24 with JPAAuditLogService

use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.

the class VariableInstanceLogCleanTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    auditService = new JPAAuditLogService(getEmf());
    auditService.clear();
}
Also used : JPAAuditLogService(org.jbpm.process.audit.JPAAuditLogService)

Example 25 with JPAAuditLogService

use of org.jbpm.process.audit.JPAAuditLogService 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

JPAAuditLogService (org.jbpm.process.audit.JPAAuditLogService)35 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)20 KieSession (org.kie.api.runtime.KieSession)19 Test (org.junit.Test)18 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)15 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)11 ProcessInstanceLog (org.kie.api.runtime.manager.audit.ProcessInstanceLog)11 AuditLogService (org.jbpm.process.audit.AuditLogService)8 ProcessInstanceLog (org.jbpm.process.audit.ProcessInstanceLog)7 NodeInstanceLog (org.jbpm.process.audit.NodeInstanceLog)6 KieBase (org.kie.api.KieBase)6 HashMap (java.util.HashMap)5 EntityManagerFactory (javax.persistence.EntityManagerFactory)5 Environment (org.kie.api.runtime.Environment)5 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)5 TaskSummary (org.kie.api.task.model.TaskSummary)5 CountDownAsyncJobListener (org.jbpm.executor.test.CountDownAsyncJobListener)4 PersistenceUtil.createEnvironment (org.jbpm.persistence.util.PersistenceUtil.createEnvironment)4 AbstractAuditLogServiceTest.createKieSession (org.jbpm.process.audit.AbstractAuditLogServiceTest.createKieSession)4 AbstractAuditLogger (org.jbpm.process.audit.AbstractAuditLogger)4