Search in sources :

Example 6 with NodeInstanceLog

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

the class NodeInstanceLogCleanTest method deleteLogsByNodeId.

@Test
public void deleteLogsByNodeId() {
    KieSession kieSession = createKSession(HELLO_WORLD_PROCESS);
    startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 2);
    // Delete one node named "Hello world"
    int resultCount = auditService.nodeInstanceLogDelete().nodeId("_3").build().execute();
    Assertions.assertThat(resultCount).isEqualTo(4);
    // Now check that all other node records are still present
    List<NodeInstanceLog> nodeList = auditService.nodeInstanceLogQuery().nodeId("_1", "_2", "_3").build().getResultList();
    Assertions.assertThat(nodeList).hasSize(8).extracting("nodeName").containsOnly("Start", "Hello world");
}
Also used : NodeInstanceLog(org.kie.api.runtime.manager.audit.NodeInstanceLog) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test)

Example 7 with NodeInstanceLog

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

the class JbpmJUnitBaseTestCase method assertNodeActive.

public void assertNodeActive(long processInstanceId, KieSession ksession, String... name) {
    List<String> names = new ArrayList<String>();
    for (String n : name) {
        names.add(n);
    }
    ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
    if (processInstance instanceof WorkflowProcessInstance) {
        if (sessionPersistence) {
            // ENTER -> EXIT is correctly ordered
            List<? extends NodeInstanceLog> logs = logService.findNodeInstances(processInstanceId);
            if (logs != null) {
                List<String> activeNodes = new ArrayList<String>();
                for (NodeInstanceLog l : logs) {
                    String nodeName = l.getNodeName();
                    if (l.getType() == NodeInstanceLog.TYPE_ENTER && names.contains(nodeName)) {
                        activeNodes.add(nodeName);
                    }
                    if (l.getType() == NodeInstanceLog.TYPE_EXIT && names.contains(nodeName)) {
                        activeNodes.remove(nodeName);
                    }
                }
                names.removeAll(activeNodes);
            }
        } else {
            assertNodeActive((WorkflowProcessInstance) processInstance, names);
        }
    }
    if (!names.isEmpty()) {
        String s = names.get(0);
        for (int i = 1; i < names.size(); i++) {
            s += ", " + names.get(i);
        }
        fail("Node(s) not active: " + s);
    }
}
Also used : NodeInstanceLog(org.kie.api.runtime.manager.audit.NodeInstanceLog) ArrayList(java.util.ArrayList) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance)

Aggregations

NodeInstanceLog (org.kie.api.runtime.manager.audit.NodeInstanceLog)7 Test (org.junit.Test)3 KieSession (org.kie.api.runtime.KieSession)3 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 LogEvent (org.drools.core.audit.event.LogEvent)1 RuleFlowNodeLogEvent (org.drools.core.audit.event.RuleFlowNodeLogEvent)1 ChecklistItem (org.jbpm.examples.checklist.ChecklistItem)1 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)1