Skip to content

Commit

Permalink
Merge branch 'kiegroup:main' into kie-roadmap-119
Browse files Browse the repository at this point in the history
  • Loading branch information
martinweiler committed Jul 26, 2023
2 parents d230dfe + 4757def commit d599071
Show file tree
Hide file tree
Showing 88 changed files with 367 additions and 163 deletions.
2 changes: 1 addition & 1 deletion jbpm-audit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-audit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public AuditEvent buildEvent(ProcessCompletedEvent pce, Object log) {
logEvent.setDuration(logEvent.getEnd().getTime() - logEvent.getStart().getTime());
logEvent.setProcessInstanceDescription( pi.getDescription() );
logEvent.setSlaCompliance(pi.getSlaCompliance());
logEvent.setSlaDueDate(pi.getSlaDueDate());
return logEvent;
}

Expand Down
2 changes: 1 addition & 1 deletion jbpm-bpmn2-emfextmodel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-bpmn2-emfextmodel</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jbpm-bpmn2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-bpmn2</artifactId>
Expand Down
79 changes: 78 additions & 1 deletion jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/SLAComplianceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.jbpm.bpmn2;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
Expand All @@ -31,11 +32,17 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.drools.core.command.SingleSessionCommandService;
import org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession;
import org.drools.core.impl.StatefulKnowledgeSessionImpl;
import org.jbpm.bpmn2.objects.TestWorkItemHandler;
import org.jbpm.process.audit.NodeInstanceLog;
import org.jbpm.process.audit.ProcessInstanceLog;
import org.jbpm.process.instance.InternalProcessRuntime;
import org.jbpm.process.instance.command.UpdateTimerCommand;
import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler;
import org.jbpm.process.instance.timer.TimerInstance;
import org.jbpm.process.instance.timer.TimerManager;
import org.jbpm.workflow.instance.node.HumanTaskNodeInstance;
import org.junit.After;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -126,6 +133,49 @@ public void afterSLAViolated(SLAViolatedEvent event) {
ksession.dispose();
}

@Test
public void testSLAonProcessUpdated() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
KieBase kbase = createKnowledgeBase("BPMN2-UserTaskWithSLA.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);

ProcessInstance processInstance = ksession.startProcess("UserTask");
assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);

Date firstSlaDueDate = getSLADueDateForProcessInstance(processInstance.getId(),
(org.jbpm.workflow.instance.WorkflowProcessInstance) processInstance);

Collection<TimerInstance> timers = getTimerManager(ksession).getTimers();
assertThat(timers.size()).isEqualTo(1);

ksession.execute(new UpdateTimerCommand(processInstance.getId(), timers.iterator().next().getId(), 7));

boolean slaViolated = latch.await(5, TimeUnit.SECONDS);
assertFalse("Process SLA was violated while it is not expected after update SLA", slaViolated);

processInstance = ksession.getProcessInstance(processInstance.getId());
assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);

int slaCompliance = getSLAComplianceForProcessInstance(processInstance);
assertEquals(ProcessInstance.SLA_PENDING, slaCompliance);

slaViolated = latch.await(5, TimeUnit.SECONDS);
assertFalse("Process SLA was not violated while it is expected after 10s", slaViolated);

slaCompliance = getSLAComplianceForProcessInstance(processInstance);
assertEquals(ProcessInstance.SLA_VIOLATED, slaCompliance);

ksession.abortProcessInstance(processInstance.getId());
Date updatedSlaDueDate = getSLADueDateForProcessInstance(processInstance.getId(),
(org.jbpm.workflow.instance.WorkflowProcessInstance) processInstance);

assertTrue(String.format("updatedSlaDueDate '%tc' should be around 4-5 seconds after firstSlaDueDate '%tc'",
updatedSlaDueDate, firstSlaDueDate),
updatedSlaDueDate.after(firstSlaDueDate));

ksession.dispose();
}

@Test
public void testSLAonProcessMet() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-UserTaskWithSLA.bpmn2");
Expand Down Expand Up @@ -306,7 +356,7 @@ class TimerIdListener extends DefaultProcessEventListener {
public TimerIdListener(CountDownLatch latch) {
this.latch = latch;
}

@Override
public void afterNodeTriggered(ProcessNodeTriggeredEvent event) {
if (event.getNodeInstance() instanceof HumanTaskNodeInstance) {
Expand Down Expand Up @@ -664,4 +714,31 @@ private Date getSLADueDateForNodeInstance(long processInstanceId, org.jbpm.workf

throw new RuntimeException("NodeInstanceLog not found for id "+nodeInstance.getId()+" and type "+logType);
}

private Date getSLADueDateForProcessInstance(long processInstanceId, org.jbpm.workflow.instance.WorkflowProcessInstance processInstance) {
if (!sessionPersistence) {
return processInstance.getSlaDueDate();
}

List<ProcessInstanceLog> logs = logService.findProcessInstances();
if (logs == null)
throw new RuntimeException("ProcessInstanceLog not found");

for (ProcessInstanceLog log : logs) {
if (log.getId() == processInstanceId) {
return log.getSlaDueDate();
}
}

throw new RuntimeException("ProcessInstanceLog not found for id "+processInstanceId);
}

private TimerManager getTimerManager(KieSession ksession) {
KieSession internal = ksession;
if (ksession instanceof CommandBasedStatefulKnowledgeSession) {
internal = ( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession();;
}

return ((InternalProcessRuntime)((StatefulKnowledgeSessionImpl)internal).getProcessRuntime()).getTimerManager();
}
}
2 changes: 1 addition & 1 deletion jbpm-case-mgmt/jbpm-case-mgmt-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-case-mgmt</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>
<artifactId>jbpm-case-mgmt-api</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion jbpm-case-mgmt/jbpm-case-mgmt-cmmn/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-case-mgmt</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>
<artifactId>jbpm-case-mgmt-cmmn</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion jbpm-case-mgmt/jbpm-case-mgmt-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-case-mgmt</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>
<artifactId>jbpm-case-mgmt-impl</artifactId>
<name>jBPM :: Case Management Impl</name>
Expand Down
2 changes: 1 addition & 1 deletion jbpm-case-mgmt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-case-mgmt</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-container-integration-deps</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>idep-hibernate-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-container-integration-deps</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>idep-jbpm-ejb-services</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-container-integration-deps</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>idep-jbpm-persistence</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-container-integration-deps</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>idep-jbpm</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-in-container-test</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-container-integration-deps</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-container-integration-deps</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>idep-rest</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-in-container-test</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-container-test-suite</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jbpm-container-test/jbpm-in-container-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-container-test</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-in-container-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-in-container-test</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>shrinkwrap-war-profiles</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>jbpm-remote-ejb-test</artifactId>
<groupId>org.jbpm</groupId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-remote-ejb-test-app</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-remote-ejb-test</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-remote-ejb-test-domain</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-remote-ejb-test</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-remote-ejb-test-suite</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jbpm-container-test/jbpm-remote-ejb-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-container-test</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-remote-ejb-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>jbpm-remote-ejb-test</artifactId>
<groupId>org.jbpm</groupId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>test-kjar-parent</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>test-kjar-parent</artifactId>
<groupId>org.jbpm</groupId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>test-kjar-bpmn-build</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>test-kjar-parent</artifactId>
<groupId>org.jbpm</groupId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>test-kjar-evaluation</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>test-kjar-parent</artifactId>
<groupId>org.jbpm</groupId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion jbpm-container-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-container-test</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jbpm-db-scripts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-db-scripts</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jbpm-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-distribution</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jbpm-document/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>jbpm</artifactId>
<groupId>org.jbpm</groupId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>

<artifactId>jbpm-document</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-event-emitters</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>
<artifactId>jbpm-event-emitters-elasticsearch</artifactId>
<name>jBPM :: Event Emitters :: ElasticSearch</name>
Expand Down
2 changes: 1 addition & 1 deletion jbpm-event-emitters/jbpm-event-emitters-kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-event-emitters</artifactId>
<version>7.74.0-SNAPSHOT</version>
<version>7.75.0-SNAPSHOT</version>
</parent>
<artifactId>jbpm-event-emitters-kafka</artifactId>
<name>jBPM :: Event Emitters :: Kafka</name>
Expand Down
Loading

0 comments on commit d599071

Please sign in to comment.