Skip to content

Commit

Permalink
Merge branch 'apache:main' into upgrade-quarkus-3.15
Browse files Browse the repository at this point in the history
  • Loading branch information
RishiRajAnand authored Jan 2, 2025
2 parents ac69881 + 3ecc10d commit 35702e6
Show file tree
Hide file tree
Showing 15 changed files with 192 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.kie.kogito.usertask;

import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -65,6 +66,8 @@ public interface UserTaskInstance {

Map<String, Object> getInputs();

Date getSlaDueDate();

void setInput(String key, Object value);

void setOutput(String key, Object value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class UserTaskInstanceStateEventBody {

private String externalReferenceId;

private Date slaDueDate;

public Date getEventDate() {
return eventDate;
}
Expand Down Expand Up @@ -101,6 +103,10 @@ public String getExternalReferenceId() {
return externalReferenceId;
}

public Date getSlaDueDate() {
return slaDueDate;
}

public Map<String, Object> metaData() {
Map<String, Object> metadata = new HashMap<>();
metadata.put(UserTaskInstanceEventMetadata.USER_TASK_INSTANCE_ID_META_DATA, userTaskInstanceId);
Expand All @@ -114,7 +120,7 @@ public String toString() {
return "UserTaskInstanceStateEventBody [eventDate=" + eventDate + ", eventUser=" + eventUser + ", userTaskDefinitionId=" + userTaskDefinitionId + ", userTaskInstanceId=" + userTaskInstanceId
+ ", userTaskName=" + userTaskName + ", userTaskDescription=" + userTaskDescription + ", userTaskPriority=" + userTaskPriority + ", userTaskReferenceName="
+ userTaskReferenceName
+ ", state=" + state + ", actualOwner=" + actualOwner + ", processInstanceId=" + processInstanceId + "]";
+ ", state=" + state + ", actualOwner=" + actualOwner + ", processInstanceId=" + processInstanceId + ", slaDueDate=" + slaDueDate + "]";
}

public Builder update() {
Expand Down Expand Up @@ -215,6 +221,11 @@ public Builder processInstanceId(String processInstanceId) {
return this;
}

public Builder slaDueDate(Date slaDueDate) {
this.instance.slaDueDate = slaDueDate;
return this;
}

public UserTaskInstanceStateEventBody build() {
return this.instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public boolean accept(Object payload) {
public DataEvent<?> adapt(Object payload) {
UserTaskStateEvent event = (UserTaskStateEvent) payload;
Map<String, Object> metadata = AdapterHelper.buildUserTaskMetadata(event.getUserTaskInstance());

UserTaskInstanceStateEventBody.Builder builder = UserTaskInstanceStateEventBody.create()
.eventDate(new Date())
.eventUser(event.getEventUser())
Expand All @@ -56,7 +55,8 @@ public DataEvent<?> adapt(Object payload) {
.state(event.getNewStatus().getName())
.actualOwner(event.getUserTaskInstance().getActualOwner())
.eventType(isTransition(event) ? event.getNewStatus().getName() : "Modify")
.processInstanceId((String) event.getUserTaskInstance().getMetadata().get("ProcessInstanceId"));
.processInstanceId((String) event.getUserTaskInstance().getMetadata().get("ProcessInstanceId"))
.slaDueDate(event.getUserTaskInstance().getSlaDueDate());

UserTaskInstanceStateEventBody body = builder.build();
UserTaskInstanceStateDataEvent utEvent =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected <U extends Node> void visitNodes(String factoryField, U[] nodes, Block
if (visitor == null) {
continue;
}
visitor.visitNode(factoryField, node, body, variableScope, metadata);
visitor.visitNodeEntryPoint(factoryField, node, body, variableScope, metadata);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public ReturnValueEvaluatorBuilderService getReturnValueEvaluatorBuilderService(
return returnValueEvaluatorBuilderService;
}

public void visitNode(T node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
visitNode(FACTORY_FIELD_NAME, node, body, variableScope, metadata);
public void visitNodeEntryPoint(String factoryName, T node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
visitNode((factoryName != null ? factoryName : FACTORY_FIELD_NAME), node, body, variableScope, metadata);
if (isAdHocNode(node)) {
metadata.addSignal(node.getName(), null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private <U extends org.kie.api.definition.process.Node> void visitNodes(List<U>
if (visitor == null) {
throw new IllegalStateException("No visitor found for node " + node.getClass().getName());
}
visitor.visitNode(node, body, variableScope, metadata);
visitor.visitNodeEntryPoint(null, node, body, variableScope, metadata);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<itemDefinition id="_xItem" structureRef="String" />
<itemDefinition id="_yItem" structureRef="String" />
<itemDefinition id="_nameItem" structureRef="String" />
<itemDefinition id="_surnameItem" structureRef="String" />
<itemDefinition id="_personItem" structureRef="org.jbpm.bpmn2.objects.Person" />

<process processType="Private" isExecutable="true" id="ScriptTaskFEEL" name="ScriptTask Process" tns:packageName="org.jbpm.bpmn2.activity" >
Expand All @@ -41,6 +42,7 @@
<property id="x" itemSubjectRef="_xItem"/>
<property id="y" itemSubjectRef="_yItem"/>
<property id="name" itemSubjectRef="_nameItem"/>
<property id="surname" itemSubjectRef="_surnameItem"/>
<property id="person" itemSubjectRef="_personItem"/>

<!-- nodes -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
<startEvent id="_1" name="StartProcess" />
<userTask id="_2" name="Hello" tns:taskName="Human Task">
<extensionElements>
<tns:onEntry-script>
<tns:script>System.out.println("Hello");context.setVariable("itemOut", "test");</tns:script>
<tns:onEntry-script scriptFormat="http://www.java.com/java">
<tns:script>System.out.println("Hello");kcontext.setVariable("itemOut", "test");</tns:script>
</tns:onEntry-script>
</extensionElements>
<ioSpecification>
Expand Down Expand Up @@ -122,4 +122,4 @@
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>

</definitions>
</definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.omg.org/bpmn20" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:bpsim="http://www.bpsim.org/schemas/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:drools="http://www.jboss.org/drools" id="_RSWy4J-HEei4M9OEIzmf1w" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd" exporter="jBPM Designer" exporterVersion="1.0" expressionLanguage="http://www.mvel.org/2.0" targetNamespace="http://www.omg.org/bpmn20" typeLanguage="http://www.java.com/javaTypes">
<bpmn2:itemDefinition id="_childsItem" structureRef="java.util.List"/>
<bpmn2:itemDefinition id="_fatherIdItem" structureRef="java.lang.Long"/>
<bpmn2:itemDefinition id="_fatherIdItem" structureRef="java.lang.String"/>
<bpmn2:signal id="_ab06284f-eb30-3d3b-80aa-c35195ce2096" name="stopChild:#{fatherId}"/>
<bpmn2:itemDefinition id="_5A8FEA7B-2888-4ECE-B6FD-119A3EB5C708_multiInstanceItemType"/>
<bpmn2:itemDefinition id="__47B12FBC-C42B-4ADB-A359-5FC0C36BF7E8_SkippableInputXItem" structureRef="Object"/>
Expand Down
41 changes: 21 additions & 20 deletions jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.util.stream.Collectors;

import org.drools.compiler.rule.builder.PackageBuildContext;
import org.jbpm.bpmn2.activity.ScriptTaskFEELModel;
import org.jbpm.bpmn2.activity.ScriptTaskFEELProcess;
import org.jbpm.bpmn2.activity.ScriptTaskModel;
import org.jbpm.bpmn2.activity.ScriptTaskProcess;
import org.jbpm.bpmn2.activity.ScriptTaskWithIOModel;
Expand Down Expand Up @@ -1815,28 +1817,27 @@ public void testBusinessRuleTaskFireLimitAsParameter() throws Exception {
}

@Test
@Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067")
public void testScriptTaskFEEL() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-ScriptTaskFEEL.bpmn2");

TestWorkItemHandler handler = new TestWorkItemHandler();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler);

Map<String, Object> params = new HashMap<>();
params.put("name", "krisv");
public void testScriptTaskFEEL() {
Application app = ProcessTestHelper.newApplication();
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
EventTrackerProcessListener tracker = new EventTrackerProcessListener();
ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler);
ProcessTestHelper.registerProcessEventListener(app, tracker);
org.kie.kogito.process.Process<ScriptTaskFEELModel> processDefinition = ScriptTaskFEELProcess.newProcess(app);
ScriptTaskFEELModel model = processDefinition.createModel();
model.setName("krisv");
Person person = new Person();
person.setName("krisv");
params.put("person", person);

KogitoProcessInstance processInstance = kruntime.startProcess("ScriptTask", params);
assertThat(((org.jbpm.workflow.instance.WorkflowProcessInstance) processInstance).getVariable("x")).isEqualTo("Entry");
assertThat(((org.jbpm.workflow.instance.WorkflowProcessInstance) processInstance).getVariable("y")).isNull();

kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null);
assertThat(getProcessVarValue(processInstance, "y")).isEqualTo("Exit");
assertThat(((org.jbpm.workflow.instance.WorkflowProcessInstance) processInstance).getVariable("surname")).isEqualTo("tester");

assertNodeTriggered(processInstance.getStringId(), "Script1");
model.setPerson(person);
ProcessInstance<ScriptTaskFEELModel> processInstance = processDefinition.createInstance(model);
processInstance.start();
assertThat(processInstance.variables().getX()).isEqualTo("Entry");
assertThat(processInstance.variables().getY()).isNull();
ProcessTestHelper.completeWorkItem(processInstance, Collections.emptyMap());
assertThat(processInstance.variables().getY()).isEqualTo("Exit");
assertThat(processInstance.variables().getSurname()).isEqualTo("tester");
Set<String> nodes = tracker.tracked().stream().map(event -> event.getNodeInstance().getNodeName()).collect(Collectors.toSet());
assertThat(nodes.contains("Script1")).isTrue();
}

@Test
Expand Down
49 changes: 26 additions & 23 deletions jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
import java.util.Map;
import java.util.Optional;

import org.jbpm.bpmn2.error.BoundaryErrorEventCatchingOnEntryExceptionModel;
import org.jbpm.bpmn2.error.BoundaryErrorEventCatchingOnEntryExceptionProcess;
import org.jbpm.bpmn2.error.BoundaryErrorEventCatchingOnExitExceptionModel;
import org.jbpm.bpmn2.error.BoundaryErrorEventCatchingOnExitExceptionProcess;
import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerByErrorCodeModel;
import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerByErrorCodeProcess;
import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerWithErrorCodeWithStructureRefModel;
Expand Down Expand Up @@ -71,7 +75,6 @@
import org.jbpm.process.workitem.builtin.SystemOutWorkItemHandler;
import org.jbpm.test.utils.EventTrackerProcessListener;
import org.jbpm.test.utils.ProcessTestHelper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.kie.api.event.process.DefaultProcessEventListener;
import org.kie.api.event.process.ProcessNodeLeftEvent;
Expand Down Expand Up @@ -445,31 +448,31 @@ public void testEventSubProcessErrorWithScript() throws Exception {
}

@Test
@Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067")
public void testErrorBoundaryEventOnEntry() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-BoundaryErrorEventCatchingOnEntryException.bpmn2");
TestWorkItemHandler handler = new TestWorkItemHandler();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler);

KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryErrorEventOnEntry");

assertProcessInstanceActive(processInstance.getStringId(), kruntime);
assertThat(handler.getWorkItems()).hasSize(1);
public void testErrorBoundaryEventOnEntry() {
Application app = ProcessTestHelper.newApplication();
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler);
org.kie.kogito.process.Process<BoundaryErrorEventCatchingOnEntryExceptionModel> processDefinition = BoundaryErrorEventCatchingOnEntryExceptionProcess.newProcess(app);
BoundaryErrorEventCatchingOnEntryExceptionModel model = processDefinition.createModel();
ProcessInstance<BoundaryErrorEventCatchingOnEntryExceptionModel> processInstance = processDefinition.createInstance(model);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
assertThat(workItemHandler.getWorkItems()).hasSize(1);
}

@Test
@Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067")
public void testErrorBoundaryEventOnExit() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-BoundaryErrorEventCatchingOnExitException.bpmn2");
TestWorkItemHandler handler = new TestWorkItemHandler();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler);

KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryErrorEventOnExit");

assertProcessInstanceActive(processInstance.getStringId(), kruntime);
KogitoWorkItem workItem = handler.getWorkItem();
kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null);
assertThat(handler.getWorkItems()).hasSize(1);
public void testErrorBoundaryEventOnExit() {
Application app = ProcessTestHelper.newApplication();
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler);
org.kie.kogito.process.Process<BoundaryErrorEventCatchingOnExitExceptionModel> processDefinition = BoundaryErrorEventCatchingOnExitExceptionProcess.newProcess(app);
BoundaryErrorEventCatchingOnExitExceptionModel model = processDefinition.createModel();
ProcessInstance<BoundaryErrorEventCatchingOnExitExceptionModel> processInstance = processDefinition.createInstance(model);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
KogitoWorkItem workItem = workItemHandler.getWorkItem();
processInstance.completeWorkItem(workItem.getStringId(), Collections.emptyMap());
assertThat(workItemHandler.getWorkItems()).hasSize(1);
}

@Test
Expand Down
Loading

0 comments on commit 35702e6

Please sign in to comment.