use of org.kie.api.runtime.manager.audit.NodeInstanceLog in project jbpm by kiegroup.
the class NodeInstanceLogCleanTest method deleteLogsByNodeNameAndInstanceId.
@Test
public void deleteLogsByNodeNameAndInstanceId() {
KieSession kieSession = createKSession(HELLO_WORLD_PROCESS);
List<ProcessInstance> instanceList = startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 2);
// Delete one node named "Hello world"
int resultCount = auditService.nodeInstanceLogDelete().nodeName("Hello world").processInstanceId(instanceList.get(0).getId()).build().execute();
// There are two node types in the log (value NodeInstanceLog.TYPE_ENTER and NodeInstanceLog.TYPE_EXIT)
Assertions.assertThat(resultCount).isEqualTo(2);
// Now check that all other node records are still present
List<NodeInstanceLog> nodeList = auditService.nodeInstanceLogQuery().nodeName("Start", "End", "Hello world").build().getResultList();
Assertions.assertThat(nodeList).hasSize(10).extracting("nodeName").containsOnly("Start", "End", "Hello world");
}
use of org.kie.api.runtime.manager.audit.NodeInstanceLog in project jbpm by kiegroup.
the class JbpmJUnitBaseTestCase method assertNodeTriggered.
public void assertNodeTriggered(long processInstanceId, String... nodeNames) {
List<String> names = new ArrayList<String>();
for (String nodeName : nodeNames) {
names.add(nodeName);
}
if (sessionPersistence) {
List<? extends NodeInstanceLog> logs = logService.findNodeInstances(processInstanceId);
if (logs != null) {
for (NodeInstanceLog l : logs) {
String nodeName = l.getNodeName();
if ((l.getType() == NodeInstanceLog.TYPE_ENTER || l.getType() == NodeInstanceLog.TYPE_EXIT) && names.contains(nodeName)) {
names.remove(nodeName);
}
}
}
} else {
for (LogEvent event : inMemoryLogger.getLogEvents()) {
if (event instanceof RuleFlowNodeLogEvent) {
String nodeName = ((RuleFlowNodeLogEvent) event).getNodeName();
if (names.contains(nodeName)) {
names.remove(nodeName);
}
}
}
}
if (!names.isEmpty()) {
String s = names.get(0);
for (int i = 1; i < names.size(); i++) {
s += ", " + names.get(i);
}
fail("Node(s) not executed: " + s);
}
}
use of org.kie.api.runtime.manager.audit.NodeInstanceLog in project jbpm by kiegroup.
the class ChecklistItemFactory method getLoggedChecklistItems.
public static Collection<ChecklistItem> getLoggedChecklistItems(WorkflowProcess process, List<NodeInstanceLog> nodeInstances) {
Map<String, ChecklistItem> result = new HashMap<String, ChecklistItem>();
Map<String, String> relevantNodes = new HashMap<String, String>();
getRelevantNodes(process, relevantNodes);
for (NodeInstanceLog log : nodeInstances) {
String orderingNb = relevantNodes.get(log.getNodeId());
if (orderingNb != null) {
if (log.getType() == NodeInstanceLog.TYPE_EXIT) {
result.put(orderingNb, createChecklistItem(log.getNodeName(), log.getNodeType(), "", orderingNb, 0, log.getProcessId(), Status.Completed));
} else {
if (result.get(orderingNb) == null) {
result.put(orderingNb, createChecklistItem(log.getNodeName(), log.getNodeType(), "", orderingNb, 0, log.getProcessId(), Status.InProgress));
}
}
}
}
return result.values();
}
use of org.kie.api.runtime.manager.audit.NodeInstanceLog in project jbpm by kiegroup.
the class SLATrackingCommandTest method assertNodeInstanceSLACompliance.
private void assertNodeInstanceSLACompliance(JPAAuditLogService logService, Long processInstanceId, String name, int slaCompliance) {
List<NodeInstanceLog> logs = logService.nodeInstanceLogQuery().processInstanceId(processInstanceId).and().nodeName(name).build().getResultList();
NodeInstanceLog log = logs.get(logs.size() - 1);
assertEquals(processInstanceId, log.getProcessInstanceId());
assertEquals(slaCompliance, ((org.jbpm.process.audit.NodeInstanceLog) log).getSlaCompliance().intValue());
}
use of org.kie.api.runtime.manager.audit.NodeInstanceLog in project jbpm by kiegroup.
the class NodeInstanceLogCleanTest method deleteLogsByNodeInstanceId.
@Test
public void deleteLogsByNodeInstanceId() {
KieSession kieSession = null;
List<ProcessInstance> processInstanceList = null;
try {
kieSession = createKSession(HUMAN_TASK_LOCALE);
processInstanceList = startProcess(kieSession, HUMAN_TASK_LOCALE_ID, 1);
// Let's see how the code will manage Japan characters.
List<NodeInstanceLog> nodeInstanceList = auditService.nodeInstanceLogQuery().nodeName("空手").build().getResultList();
// We are expecting only NodeInstanceLog.TYPE_ENTERED as execution will be paused on the human task
Assertions.assertThat(nodeInstanceList).hasSize(1);
// Delete node named "空手" based on it's id.
int resultCount = auditService.nodeInstanceLogDelete().nodeInstanceId(nodeInstanceList.get(0).getNodeId()).build().execute();
Assertions.assertThat(resultCount).isEqualTo(0);
} finally {
if (processInstanceList != null) {
abortProcess(kieSession, processInstanceList);
}
if (kieSession != null) {
kieSession.dispose();
}
}
}
Aggregations