use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class ProcessInstanceLogCleanTest method deleteLogsByDate.
@Test
@BZ("1188702")
public void deleteLogsByDate() {
Date testStartDate = new Date();
KieSession kieSession = createKSession(HELLO_WORLD_PROCESS);
startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 4);
List<ProcessInstanceLog> resultList = auditService.processInstanceLogQuery().startDateRangeStart(testStartDate).build().getResultList();
Assertions.assertThat(resultList).hasSize(4).extracting("processId").containsExactly(HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID);
// Delete the last 3 logs in the list
for (int i = resultList.size() - 1; i > 0; i--) {
int resultCount = auditService.processInstanceLogDelete().startDate(resultList.get(i).getStart()).build().execute();
Assertions.assertThat(resultCount).isEqualTo(1);
}
// Attempt to delete with a date later than end of all the instances
int resultCount = auditService.processInstanceLogDelete().startDate(new Date()).build().execute();
Assertions.assertThat(resultCount).isEqualTo(0);
// Check the last instance
List<ProcessInstanceLog> resultList2 = auditService.processInstanceLogQuery().startDateRangeStart(testStartDate).build().getResultList();
Assertions.assertThat(resultList2).hasSize(1);
Assertions.assertThat(resultList2.get(0)).isEqualTo(resultList.get(0));
}
use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class ProcessInstanceLogCleanTest method deleteLogsByProcessId.
@Test
public void deleteLogsByProcessId() {
KieSession kieSession = createKSession(HELLO_WORLD_PROCESS);
startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 3);
// Check that all records are created.
List<ProcessInstanceLog> resultList = auditService.processInstanceLogQuery().processName(HELLO_WORLD_P1NAME).processVersion("1.0").build().getResultList();
Assertions.assertThat(resultList).hasSize(3);
Assertions.assertThat(resultList).extracting("processId").containsExactly(HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID);
// Perform delete
int resultCount = auditService.processInstanceLogDelete().processId(HELLO_WORLD_PROCESS_ID).build().execute();
Assertions.assertThat(resultCount).isEqualTo(3);
// Check that all records are gone
resultList = auditService.processInstanceLogQuery().processName(HELLO_WORLD_P1NAME).processVersion("1.0").build().getResultList();
Assertions.assertThat(resultList).hasSize(0);
}
use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class AsyncThreadContinuationTest method testRepeatIntermediateTimerAfterException.
@Test(timeout = 10000)
public void testRepeatIntermediateTimerAfterException() {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("MySignal", 1, true);
KieSession ksession = createKSession(BPMN_IT);
ksession.addEventListener(countDownListener);
ProcessInstance pi = ksession.startProcess(PROCESS_IT);
long pid = pi.getId();
countDownListener.waitTillCompleted();
pi = ksession.getProcessInstance(pid);
Assertions.assertThat(pi).isNotNull();
ksession.abortProcessInstance(pid);
pi = ksession.getProcessInstance(pid);
Assertions.assertThat(pi).isNull();
ProcessInstanceLog log = getLogService().findProcessInstance(pid);
Assertions.assertThat(log.getStatus()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class ConcurrentGlobalTimerServiceTest method testSessionPerProcessInstance.
@Test
public void testSessionPerProcessInstance() throws Exception {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().entityManagerFactory(emf).userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("org/jbpm/test/functional/timer/IntermediateCatchEventTimerCycleWithHT.bpmn2"), ResourceType.BPMN2).schedulerService(globalScheduler).get();
long startTimeStamp = System.currentTimeMillis();
long maxEndTime = startTimeStamp + maxWaitTime;
manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
// prepare task service with users and groups
RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
TaskService taskService = engine.getTaskService();
Group grouphr = TaskModelProvider.getFactory().newGroup();
((InternalOrganizationalEntity) grouphr).setId("HR");
User mary = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) mary).setId("mary");
User john = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) john).setId("john");
((InternalTaskService) taskService).addGroup(grouphr);
((InternalTaskService) taskService).addUser(mary);
((InternalTaskService) taskService).addUser(john);
manager.disposeRuntimeEngine(engine);
completedStart = 0;
for (int i = 0; i < nbThreadsProcess; i++) {
new StartProcessPerProcessInstanceRunnable(manager, i).run();
}
completedTask = 0;
for (int i = 0; i < nbThreadsTask; i++) {
new Thread(new CompleteTaskPerProcessInstanceRunnable(manager, i)).start();
}
while (completedStart < nbThreadsProcess || completedTask < nbThreadsTask) {
Thread.sleep(100);
if (System.currentTimeMillis() > maxEndTime) {
fail("Failure, did not finish in time most likely hanging");
}
}
// make sure all process instance were completed
engine = manager.getRuntimeEngine(EmptyContext.get());
AuditService logService = engine.getAuditService();
// active
List<? extends ProcessInstanceLog> logs = logService.findActiveProcessInstances("IntermediateCatchEvent");
assertNotNull(logs);
for (ProcessInstanceLog log : logs) {
logger.debug("Left over {}", log.getProcessInstanceId());
}
assertEquals(0, logs.size());
// completed
logs = logService.findProcessInstances("IntermediateCatchEvent");
assertNotNull(logs);
assertEquals(nbThreadsProcess, logs.size());
manager.disposeRuntimeEngine(engine);
logger.debug("Done");
}
use of org.kie.api.runtime.manager.audit.ProcessInstanceLog in project jbpm by kiegroup.
the class SLATrackingCommandTest method assertProcessInstanceSLACompliance.
private void assertProcessInstanceSLACompliance(JPAAuditLogService logService, Long processInstanceId, int slaCompliance) {
List<ProcessInstanceLog> logs = logService.processInstanceLogQuery().processInstanceId(processInstanceId).build().getResultList();
assertEquals(1, logs.size());
ProcessInstanceLog log = logs.get(0);
assertEquals(processInstanceId, log.getProcessInstanceId());
assertEquals(slaCompliance, ((org.jbpm.process.audit.ProcessInstanceLog) log).getSlaCompliance().intValue());
}
Aggregations