Search in sources :

Example 26 with AuditService

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

the class PerProcessInstanceRuntimeManagerTest method testEventSignalingBetweenProcessesWithPeristence.

@Test
public void testEventSignalingBetweenProcessesWithPeristence() {
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("events/throw-an-event.bpmn"), ResourceType.BPMN2).addAsset(ResourceFactory.newClassPathResource("events/start-on-event.bpmn"), ResourceType.BPMN2).get();
    manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
    assertNotNull(manager);
    RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
    KieSession ksession = runtime.getKieSession();
    assertNotNull(ksession);
    ksession.startProcess("com.sample.bpmn.hello");
    AuditService auditService = runtime.getAuditService();
    List<? extends ProcessInstanceLog> throwProcessLogs = auditService.findProcessInstances("com.sample.bpmn.hello");
    List<? extends ProcessInstanceLog> catchProcessLogs = auditService.findProcessInstances("com.sample.bpmn.Second");
    assertNotNull(throwProcessLogs);
    assertEquals(1, throwProcessLogs.size());
    assertEquals(ProcessInstance.STATE_COMPLETED, throwProcessLogs.get(0).getStatus().intValue());
    assertNotNull(catchProcessLogs);
    assertEquals(1, catchProcessLogs.size());
    assertEquals(ProcessInstance.STATE_COMPLETED, catchProcessLogs.get(0).getStatus().intValue());
    manager.disposeRuntimeEngine(runtime);
    manager.close();
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) KieSession(org.kie.api.runtime.KieSession) AuditService(org.kie.api.runtime.manager.audit.AuditService) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest) Test(org.junit.Test)

Example 27 with AuditService

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

the class PerProcessInstanceRuntimeManagerTest method testIndependentSubprocessAbort.

@Test
public void testIndependentSubprocessAbort() {
    // independent = true
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2-CallActivity.bpmn2"), ResourceType.BPMN2).addAsset(ResourceFactory.newClassPathResource("BPMN2-CallActivitySubProcess.bpmn2"), ResourceType.BPMN2).get();
    manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
    assertNotNull(manager);
    // since there is no process instance yet we need to get new session
    RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
    KieSession ksession = runtime.getKieSession();
    assertNotNull(ksession);
    long ksession1Id = ksession.getIdentifier();
    assertTrue(ksession1Id == 2);
    ProcessInstance pi1 = ksession.startProcess("ParentProcess");
    assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState());
    // Aborting the parent process
    ksession.abortProcessInstance(pi1.getId());
    AuditService logService = runtime.getAuditService();
    List<? extends ProcessInstanceLog> logs = logService.findActiveProcessInstances("ParentProcess");
    assertNotNull(logs);
    assertEquals(0, logs.size());
    logs = logService.findActiveProcessInstances("SubProcess");
    assertNotNull(logs);
    assertEquals(1, logs.size());
    logs = logService.findProcessInstances("ParentProcess");
    assertNotNull(logs);
    assertEquals(1, logs.size());
    assertEquals(ProcessInstance.STATE_ABORTED, (int) logs.get(0).getStatus());
    logs = logService.findProcessInstances("SubProcess");
    assertNotNull(logs);
    assertEquals(1, logs.size());
    assertEquals(ProcessInstance.STATE_ACTIVE, (int) logs.get(0).getStatus());
    manager.close();
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) AuditService(org.kie.api.runtime.manager.audit.AuditService) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest) Test(org.junit.Test)

Example 28 with AuditService

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

the class PerRequestRuntimeManagerTest method testEventSignalingBetweenProcessesWithPeristence.

@Test
public void testEventSignalingBetweenProcessesWithPeristence() {
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("events/throw-an-event.bpmn"), ResourceType.BPMN2).addAsset(ResourceFactory.newClassPathResource("events/start-on-event.bpmn"), ResourceType.BPMN2).get();
    manager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment);
    assertNotNull(manager);
    RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
    KieSession ksession = runtime.getKieSession();
    assertNotNull(ksession);
    ksession.startProcess("com.sample.bpmn.hello");
    AuditService auditService = runtime.getAuditService();
    List<? extends ProcessInstanceLog> throwProcessLogs = auditService.findProcessInstances("com.sample.bpmn.hello");
    List<? extends ProcessInstanceLog> catchProcessLogs = auditService.findProcessInstances("com.sample.bpmn.Second");
    assertNotNull(throwProcessLogs);
    assertEquals(1, throwProcessLogs.size());
    assertEquals(ProcessInstance.STATE_COMPLETED, throwProcessLogs.get(0).getStatus().intValue());
    assertNotNull(catchProcessLogs);
    assertEquals(1, catchProcessLogs.size());
    assertEquals(ProcessInstance.STATE_COMPLETED, catchProcessLogs.get(0).getStatus().intValue());
    manager.disposeRuntimeEngine(runtime);
    manager.close();
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) KieSession(org.kie.api.runtime.KieSession) AuditService(org.kie.api.runtime.manager.audit.AuditService) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 29 with AuditService

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

the class SingletonRuntimeManagerTest method testEventSignalingBetweenProcessesWithPeristence.

@Test
public void testEventSignalingBetweenProcessesWithPeristence() {
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("events/throw-an-event.bpmn"), ResourceType.BPMN2).addAsset(ResourceFactory.newClassPathResource("events/start-on-event.bpmn"), ResourceType.BPMN2).get();
    manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
    assertNotNull(manager);
    RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
    KieSession ksession = runtime.getKieSession();
    assertNotNull(ksession);
    ksession.startProcess("com.sample.bpmn.hello");
    AuditService auditService = runtime.getAuditService();
    List<? extends ProcessInstanceLog> throwProcessLogs = auditService.findProcessInstances("com.sample.bpmn.hello");
    List<? extends ProcessInstanceLog> catchProcessLogs = auditService.findProcessInstances("com.sample.bpmn.Second");
    assertNotNull(throwProcessLogs);
    assertEquals(1, throwProcessLogs.size());
    assertEquals(ProcessInstance.STATE_COMPLETED, throwProcessLogs.get(0).getStatus().intValue());
    assertNotNull(catchProcessLogs);
    assertEquals(1, catchProcessLogs.size());
    assertEquals(ProcessInstance.STATE_COMPLETED, catchProcessLogs.get(0).getStatus().intValue());
    manager.disposeRuntimeEngine(runtime);
    manager.close();
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) KieSession(org.kie.api.runtime.KieSession) AuditService(org.kie.api.runtime.manager.audit.AuditService) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Aggregations

AuditService (org.kie.api.runtime.manager.audit.AuditService)29 Test (org.junit.Test)28 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)26 KieSession (org.kie.api.runtime.KieSession)25 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)21 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)20 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)19 HashMap (java.util.HashMap)7 TaskService (org.kie.api.task.TaskService)6 TaskSummary (org.kie.api.task.model.TaskSummary)6 ProcessInstanceLog (org.kie.api.runtime.manager.audit.ProcessInstanceLog)5 InternalTaskService (org.kie.internal.task.api.InternalTaskService)4 ArrayList (java.util.ArrayList)3 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)3 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)3 HashSet (java.util.HashSet)2 EntityManager (javax.persistence.EntityManager)2 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)2 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)2 TaskCleanUpProcessEventListener (org.jbpm.services.task.admin.listener.TaskCleanUpProcessEventListener)2