List<ProcessInstanceLog> result = em.createQuery( "from ProcessInstanceLog as log where log.processInstanceId = :piId and log.end is null") .setParameter("piId", processCompletedEvent.getProcessInstanceId()).getResultList();
Assertions.assertThat(processInstance.getStart()).isNotNull(); 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); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug(nodeInstance.toString()); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow"); Assertions.assertThat(nodeInstance.getDate()).isNotNull();
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(); }
ProcessInstanceLog pilB = (ProcessInstanceLog) resultList.get(i); ProcessInstanceLog pilA = (ProcessInstanceLog) resultList.get(i - 1); assertTrue("order by asc process instance id failed: " + pilA.getProcessInstanceId() + " ? " + pilB.getProcessInstanceId(), pilA.getProcessInstanceId() <= pilB.getProcessInstanceId()); ProcessInstanceLog pilB = (ProcessInstanceLog) resultList.get(i); ProcessInstanceLog pilA = (ProcessInstanceLog) resultList.get(i - 1); assertTrue("order by desc process instance id failed: " + pilA.getProcessInstanceId() + " ? " + pilB.getProcessInstanceId(), pilA.getProcessInstanceId() >= pilB.getProcessInstanceId());
Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow"); List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstanceId); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug(nodeInstance.toString()); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow"); Assertions.assertThat(nodeInstance.getDate()).isNotNull();
@Test public void testLogger2() { // start process instance startProcess("com.sample.ruleflow"); startProcess("com.sample.ruleflow"); logger.debug("Checking process instances for process 'com.sample.ruleflow'"); List<ProcessInstanceLog> processInstances = logService.findProcessInstances("com.sample.ruleflow"); assertEquals(2, processInstances.size()); for (ProcessInstanceLog processInstance: processInstances) { logger.debug("{}", processInstance); logger.debug(" -> {} - {}", processInstance.getStart(), processInstance.getEnd()); List<NodeInstanceLog> nodeInstances = logService.findNodeInstances(processInstance.getProcessInstanceId()); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug("{}", nodeInstance); logger.debug(" -> {}", nodeInstance.getDate()); } assertEquals(6, nodeInstances.size()); assertRuleFlowSampleLogsSorting(nodeInstances, processInstance.getProcessInstanceId()); } logService.clear(); }
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.ruleflow3"); List<VariableInstanceLog> variableInstances = auditLogService.findVariableInstances(processInstanceId); for (VariableInstanceLog variableInstance: variableInstances) { logger.debug(variableInstance.toString()); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow3"); Assertions.assertThat(variableInstance.getDate()).isNotNull();
public static void runTestLogger2(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 session.startProcess("com.sample.ruleflow"); session.startProcess("com.sample.ruleflow"); logger.debug("Checking process instances for process 'com.sample.ruleflow'"); processInstances = auditLogService.findProcessInstances("com.sample.ruleflow"); Assertions.assertThat(processInstances.size()).isEqualTo(initialProcessInstanceSize + 2); for (ProcessInstanceLog processInstance: processInstances) { logger.debug("{} -> {} - {}", processInstance.toString(), processInstance.getStart(), processInstance.getEnd()); List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstance.getProcessInstanceId()); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug("{} -> {}",nodeInstance.toString(), nodeInstance.getDate()); } Assertions.assertThat(nodeInstances.size()).isEqualTo(6); } auditLogService.clear(); }
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.ruleflow3"); List<VariableInstanceLog> variableInstances = auditLogService.findVariableInstances(processInstanceId); for (VariableInstanceLog variableInstance: variableInstances) { 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.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.ruleflow3"); List<VariableInstanceLog> variableInstances = auditLogService.findVariableInstances(processInstanceId); for (VariableInstanceLog variableInstance: variableInstances) { 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.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow3"); List<VariableInstanceLog> variableInstances = auditLogService.findVariableInstances(processInstanceId); for (VariableInstanceLog variableInstance: variableInstances) { 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.getProcessInstanceId()).isEqualTo(processInstance.getProcessInstanceId()); 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(); }
assertEquals(processInstanceId, processInstance.getProcessInstanceId().longValue()); assertEquals(PROCESS_ID, processInstance.getProcessId()); List<NodeInstanceLog> nodeInstances = setAuditLogServiceAndExecute(new FindNodeInstancesCommand(processInstanceId));
assertEquals( "Log list size is incorrect.", 1, logList.size() ); ProcessInstanceLog log = logList.get(0); assertEquals(log.getProcessInstanceId().longValue(), processInstance.getId()); assertEquals(log.getProcessId(), processInstance.getProcessId()); assertEquals( "Log list size is incorrect.", 1, logList.size() ); 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 ); assertTrue( result instanceof ProcessInstanceLog ); log = (ProcessInstanceLog) result; assertEquals(log.getProcessInstanceId().longValue(), processInstance.getId()); assertEquals(log.getProcessId(), processInstance.getProcessId());
break; case 5: testData[i-1].setProcessInstanceId(testData[i].getProcessInstanceId()); break; case 6:
long processInstanceId = pilTestData[p++].getProcessInstanceId(); builder = this.processInstanceLogQuery().processInstanceId(processInstanceId); resultList = builder.build().getResultList();
break; case 5: testData[i-1].setProcessInstanceId(testData[i].getProcessInstanceId()); break; case 6:
@Test public void testGetProcessInstanceVariables(){ HashMap<String,Object> variables = new HashMap<String, Object>(); variables.put("key", "value"); ProcessInstanceLog instance = CommandDelegate.startProcess("UserTask", variables); assertEquals(variables, CommandDelegate.getProcessInstanceVariables(instance.getProcessInstanceId() + "")); }
@Test public void testGetProcessInstanceLog() { ProcessInstanceLog instance = CommandDelegate.startProcess("Minimal", null); assertEquals(instance.getId(), CommandDelegate.getProcessInstanceLog(instance.getProcessInstanceId() + "").getId()); }