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
#3048)

* RHPAM-4779: SLA due date value in ProcessInstanceLog table is not updated after updating process SLA

* Removed * from imports
  • Loading branch information
nmirasch authored Aug 7, 2024
1 parent 7275e37 commit b2c1cec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 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 @@ -27,6 +27,7 @@
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.ProcessDataChangedEvent;
import org.kie.api.event.process.SLAViolatedEvent;
import org.kie.api.runtime.manager.audit.VariableInstanceLog;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -39,7 +40,7 @@
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.PROCESS_DATA_CHANGED_EVENT_TYPE;

/**
* AuditListener
Expand Down Expand Up @@ -124,4 +125,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 b2c1cec

Please sign in to comment.