Skip to content

Commit

Permalink
RHPAM-4779: SLA due date value in ProcessInstanceLog table is not upd…
Browse files Browse the repository at this point in the history
…ated after updating process SLA
  • Loading branch information
nmirasch committed Apr 26, 2024
1 parent 1829d1e commit b19df69
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void testSLAonUserTaskViolated() throws Exception {
activeNodes = processClient.findActiveNodeInstances(CONTAINER_ID, pid, 0, 10);
assertThat(activeNodes).hasSize(1);
taskNode = activeNodes.get(0);
assertNodeInstance(taskNode, "Hello", SLA_VIOLATED);
assertNodeInstance(taskNode, "Hello", SLA_VIOLATED, -1);

taskClient.completeAutoProgress(CONTAINER_ID, task.getId(), USER_YODA, null);
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
Expand Down Expand Up @@ -240,11 +240,15 @@ private void assertProcessInstance(Long pid, int processState, int slaStatus, lo
}
}

private void assertNodeInstance(NodeInstance ni, String nodeName, int slaStatus) {
private void assertNodeInstance(NodeInstance ni, String nodeName, int slaStatus) {
assertNodeInstance(ni, nodeName, slaStatus, 30000);
}

private void assertNodeInstance(NodeInstance ni, String nodeName, int slaStatus, long deltaTime) {
assertThat(ni.getName()).isEqualTo(nodeName);
assertThat(ni.getSlaCompliance()).isEqualTo(slaStatus);
if (slaStatus != SLA_NA) {
assertThat(ni.getSlaDueDate()).isCloseTo(new Date(), 30000);
if (slaStatus != SLA_NA && deltaTime > 0) {
assertThat(ni.getSlaDueDate()).isCloseTo(new Date(), deltaTime);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,11 @@
import org.jbpm.process.audit.AbstractAuditLoggerAdapter;
import org.jbpm.process.audit.NodeInstanceLog;
import org.jbpm.process.audit.ProcessInstanceLog;
import org.kie.api.event.process.ProcessAsyncNodeScheduledEvent;
import org.kie.api.event.process.ProcessCompletedEvent;
import org.kie.api.event.process.ProcessNodeLeftEvent;
import org.kie.api.event.process.ProcessNodeTriggeredEvent;
import org.kie.api.event.process.ProcessStartedEvent;
import org.kie.api.event.process.ProcessVariableChangedEvent;
import org.kie.api.event.process.SLAViolatedEvent;
import org.kie.api.event.process.*;
import org.kie.api.runtime.manager.audit.VariableInstanceLog;
import org.springframework.beans.factory.annotation.Autowired;

import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_ENTER_EVENT_TYPE;
import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_LEFT_EVENT_TYPE;
import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_SCHEDULED_EVENT_TYPE;
import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_SLA_VIOLATED;
import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.PROCESS_COMPLETED_EVENT_TYPE;
import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.PROCESS_SLA_VIOLATED;
import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.PROCESS_START_EVENT_TYPE;
import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.VAR_CHANGE_EVENT_TYPE;
import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.*;


/**
Expand Down Expand Up @@ -124,4 +111,11 @@ protected void nodeScheduled(ProcessAsyncNodeScheduledEvent event) {
}
}

@Override
public void processDataChanged(ProcessDataChangedEvent event) {
ProcessInstanceLog log = (ProcessInstanceLog) getProcessInstanceMetadata(event.getProcessInstance(), METADATA_PROCESSINTANCE_LOG);
if (log != null) {
jmsSender.sendMessage(log, PROCESS_DATA_CHANGED_EVENT_TYPE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private MessageType() {
public static final int VAR_CHANGE_EVENT_TYPE = 104;
public static final int NODE_SLA_VIOLATED = 105;
public static final int PROCESS_SLA_VIOLATED = 106;
public static final int PROCESS_DATA_CHANGED_EVENT_TYPE = 108;

public static final int TASK_STARTED = 201;
public static final int TASK_ACTIVATED = 202;
Expand Down

0 comments on commit b19df69

Please sign in to comment.