@Test public void testDeleteProcessInstanceInfoLogByProcessId() { int p = 0; String processId = pilTestData[p++].getProcessId(); String processId2 = pilTestData[p++].getProcessId(); ProcessInstanceLogDeleteBuilder updateBuilder = this.processInstanceLogDelete().processId(processId, processId2); int result = updateBuilder.build().execute(); assertEquals(2, result); }
public static void runTestLogger3(KieSession session, AuditLogService auditLogService) { session.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); // record the initial count to compare to later List<ProcessInstanceLog> processInstances = auditLogService.findProcessInstances("com.sample.ruleflow"); int initialProcessInstanceSize = processInstances.size(); // start process instance long processInstanceId = session.startProcess("com.sample.ruleflow2").getId(); logger.debug("Checking process instances for process 'com.sample.ruleflow2'"); processInstances = auditLogService.findProcessInstances("com.sample.ruleflow2"); Assertions.assertThat(processInstances.size()).isEqualTo(initialProcessInstanceSize + 1); ProcessInstanceLog processInstance = processInstances.get(initialProcessInstanceSize); logger.debug("{} -> {} - {}", processInstance.toString(), processInstance.getStart(), processInstance.getEnd()); Assertions.assertThat(processInstance.getStart()).isNotNull(); Assertions.assertThat(processInstance.getEnd()).isNotNull().withFailMessage("ProcessInstanceLog does not contain end date."); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow2"); List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstanceId); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug("{} -> {}", nodeInstance.toString(), nodeInstance.getDate()); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow2"); Assertions.assertThat(nodeInstance.getDate()).isNotNull(); } Assertions.assertThat(nodeInstances.size()).isEqualTo(14); auditLogService.clear(); }
Assertions.assertThat(processInstance.getEnd()).isNotNull(); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow"); Assertions.assertThat(processInstance.getStatus().intValue()).isEqualTo(ProcessInstance.STATE_COMPLETED); List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstanceId); logger.debug(nodeInstance.toString()); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow"); Assertions.assertThat(nodeInstance.getDate()).isNotNull();
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); 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);
Assertions.assertThat(processInstance.getEnd()).isNotNull().withFailMessage("ProcessInstanceLog does not contain end date."); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow"); List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstanceId); Assertions.assertThat(nodeInstances.size()).isEqualTo(6); logger.debug(nodeInstance.toString()); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow"); Assertions.assertThat(nodeInstance.getDate()).isNotNull();
Assertions.assertThat(processInstance.getEnd()).isNotNull().withFailMessage("ProcessInstanceLog does not contain end date."); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow3"); List<VariableInstanceLog> variableInstances = auditLogService.findVariableInstances(processInstanceId); Assertions.assertThat(variableInstances.size()).isEqualTo(8); logger.debug(variableInstance.toString()); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow3"); Assertions.assertThat(variableInstance.getDate()).isNotNull();
Assertions.assertThat(processInstance.getEnd()).isNotNull().withFailMessage("ProcessInstanceLog does not contain end date."); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow3"); List<VariableInstanceLog> variableInstances = auditLogService.findVariableInstances(processInstanceId); Assertions.assertThat(variableInstances.size()).isEqualTo(11); logger.debug(variableInstance.toString()); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow3"); Assertions.assertThat(variableInstance.getDate()).isNotNull();
Assertions.assertThat(processInstance.getEnd()).isNotNull().withFailMessage("ProcessInstanceLog does not contain end date."); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow3"); List<VariableInstanceLog> variableInstances = auditLogService.findVariableInstances(processInstanceId); Assertions.assertThat(variableInstances.size()).isEqualTo(12); logger.debug(variableInstance.toString()); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow3"); Assertions.assertThat(variableInstance.getDate()).isNotNull();
Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow3"); List<VariableInstanceLog> variableInstances = auditLogService.findVariableInstances(processInstanceId); Assertions.assertThat(variableInstances.size()).isEqualTo(13); logger.debug(variableInstance.toString()); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow3"); Assertions.assertThat(variableInstance.getDate()).isNotNull(); Assertions.assertThat(var.getProcessId()).isEqualTo(processInstance.getProcessId()); Assertions.assertThat(var.getVariableInstanceId()).isEqualTo("list");
@Test public void testLogger3() { long processInstanceId = startProcess("com.sample.ruleflow2").getId(); logger.debug("Checking process instances for process 'com.sample.ruleflow2'"); List<ProcessInstanceLog> processInstances = logService.findProcessInstances("com.sample.ruleflow2"); assertEquals(1, processInstances.size()); ProcessInstanceLog processInstance = processInstances.get(0); logger.debug("{}", processInstance); logger.debug(" -> {} - {} ", processInstance.getStart(), processInstance.getEnd()); assertNotNull(processInstance.getStart()); assertNotNull(processInstance.getEnd()); assertEquals(processInstanceId, processInstance.getProcessInstanceId().longValue()); assertEquals("com.sample.ruleflow2", processInstance.getProcessId()); List<NodeInstanceLog> nodeInstances = logService.findNodeInstances(processInstanceId); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug("{}", nodeInstance); logger.debug(" -> {}", nodeInstance.getDate()); assertEquals(processInstanceId, processInstance.getProcessInstanceId().longValue()); assertEquals("com.sample.ruleflow2", processInstance.getProcessId()); assertNotNull(nodeInstance.getDate()); } assertEquals(14, nodeInstances.size()); logService.clear(); }
@Test public void testLogger1() { // start process instance long processInstanceId = startProcess("com.sample.ruleflow").getId(); logger.debug("Checking process instances for process 'com.sample.ruleflow'"); List<ProcessInstanceLog> processInstances = logService.findProcessInstances("com.sample.ruleflow"); assertEquals(1, processInstances.size()); ProcessInstanceLog processInstance = processInstances.get(0); logger.debug("{}", processInstance); assertNotNull(processInstance.getStart()); assertNotNull(processInstance.getEnd()); assertEquals(processInstanceId, processInstance.getProcessInstanceId().longValue()); assertEquals("com.sample.ruleflow", processInstance.getProcessId()); List<NodeInstanceLog> nodeInstances = logService.findNodeInstances(processInstanceId); assertEquals(6, nodeInstances.size()); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug("{}", nodeInstance); assertEquals(processInstanceId, processInstance.getProcessInstanceId().longValue()); assertEquals("com.sample.ruleflow", processInstance.getProcessId()); assertNotNull(nodeInstance.getDate()); } assertRuleFlowSampleLogsSorting(nodeInstances, processInstanceId); logService.clear(); }
@Test public void testDeleteProcessInstanceInfoLogByProcessIdAndDate() { int p = 0; String processId = pilTestData[p].getProcessId(); Date endDate = pilTestData[p].getEnd(); ProcessInstanceLogDeleteBuilder updateBuilder = this.processInstanceLogDelete().endDate(endDate).processId(processId); int result = updateBuilder.build().execute(); assertEquals(1, result); }
@Test public void testDeleteProcessInstanceInfoLogByProcessIdAndNotMatchingDate() { int p = 0; String processId = pilTestData[p++].getProcessId(); Date endDate = pilTestData[p++].getEnd(); ProcessInstanceLogDeleteBuilder updateBuilder = this.processInstanceLogDelete().endDate(endDate).processId(processId); int result = updateBuilder.build().execute(); assertEquals(0, result); }
assertNotNull("ProcessInstanceLog does not contain end date.", processInstance.getEnd()); assertEquals(processInstanceId, processInstance.getProcessInstanceId().longValue()); assertEquals(PROCESS_ID, processInstance.getProcessId()); List<NodeInstanceLog> nodeInstances = setAuditLogServiceAndExecute(new FindNodeInstancesCommand(processInstanceId)); assertEquals(6, nodeInstances.size());
@Test public void intersectUnionQueryBuilderTest() { ProcessInstanceLogQueryBuilder builder = this.processInstanceLogQuery(); builder.duration(pilTestData[0].getDuration(), pilTestData[2].getDuration()); List<org.kie.api.runtime.manager.audit.ProcessInstanceLog> resultList = builder.build().getResultList(); assertEquals( "duration result", 3, resultList.size()); builder.intersect().endDate(pilTestData[0].getEnd()); resultList = builder.build().getResultList(); assertEquals( "intersect: duration AND end result", 1, resultList.size()); builder.union().processId(pilTestData[10].getProcessId()); resultList = builder.build().getResultList(); assertEquals( "intersect/union: duration AND end OR processId result", 1 + 1, resultList.size()); }
ProcessInstanceLog log = logList.get(0); assertEquals(log.getProcessInstanceId().longValue(), processInstance.getId()); assertEquals(log.getProcessId(), processInstance.getProcessId()); log = logList.get(0); assertEquals("Process instance id", log.getProcessInstanceId().longValue(), processInstance.getId()); assertEquals("Process id", log.getProcessId(), processInstance.getProcessId()); assertEquals("Status", log.getStatus().intValue(), ProcessInstance.STATE_ACTIVE ); log = (ProcessInstanceLog) result; assertEquals(log.getProcessInstanceId().longValue(), processInstance.getId()); assertEquals(log.getProcessId(), processInstance.getProcessId());
break; case 4: testData[i-1].setProcessId(testData[i].getProcessId()); break; case 5:
String processId = pilTestData[p++].getProcessId(); builder = this.processInstanceLogQuery().processId(processId); resultList = builder.build().getResultList();
break; case 4: testData[i-1].setProcessId(testData[i].getProcessId()); break; case 5:
@Test public void testDeleteProcessInstanceInfoLogByProcessIdAndNotMatchingDate() { int p = 0; String processId = pilTestData[p++].getProcessId(); Date endDate = pilTestData[p++].getEnd(); ProcessInstanceLogDeleteBuilder updateBuilder = this.processInstanceLogDelete().endDate(endDate).processId(processId); int result = updateBuilder.build().execute(); assertEquals(0, result); }