This is an automated email from the ASF dual-hosted git repository.
egonzalez pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-runtimes.git
The following commit(s) were added to refs/heads/main by this push:
new 8064dd7731 [incubator-kie-issues-1131] v7 migration to code generation
(#3626)
8064dd7731 is described below
commit 8064dd7731bb27f833febba369a4696fbedef1e6
Author: Abhiram Gundala <[email protected]>
AuthorDate: Thu Aug 29 04:33:50 2024 -0400
[incubator-kie-issues-1131] v7 migration to code generation (#3626)
---
.../org/jbpm/bpmn2/feel/BPMN2-GatewayFEEL.bpmn2 | 7 ++
.../src/test/java/org/jbpm/bpmn2/FEELTest.java | 76 ++++++++++++++--------
2 files changed, 55 insertions(+), 28 deletions(-)
diff --git
a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/feel/BPMN2-GatewayFEEL.bpmn2
b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/feel/BPMN2-GatewayFEEL.bpmn2
index 15cc61e2dd..fac8a9fbba 100644
--- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/feel/BPMN2-GatewayFEEL.bpmn2
+++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/feel/BPMN2-GatewayFEEL.bpmn2
@@ -20,9 +20,16 @@
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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: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="_PLWQUA_VEDmQT-O0r26GEw"
exporter="jBPM Process Modeler" exporterVersion="2.0"
targetNamespace="http://www.omg. [...]
<bpmn2:itemDefinition id="_VAItem" structureRef="Boolean"/>
<bpmn2:itemDefinition id="_VBItem" structureRef="Boolean"/>
+ <bpmn2:itemDefinition id="_Task1" structureRef="String"/>
+ <bpmn2:itemDefinition id="_Task2" structureRef="String"/>
+ <bpmn2:itemDefinition id="_Task3" structureRef="String"/>
<bpmn2:process id="GatewayFEEL" drools:packageName="org.jbpm.bpmn2.feel"
drools:version="1.0" drools:adHoc="false" name="BPMN2-GatewayFEEL"
isExecutable="true" processType="Public">
<bpmn2:property id="VA" itemSubjectRef="_VAItem" name="VA"/>
<bpmn2:property id="VB" itemSubjectRef="_VBItem" name="VB"/>
+ <bpmn2:property id="Task1" itemSubjectRef="_Task1" name="Task1"/>
+ <bpmn2:property id="Task2" itemSubjectRef="_Task2" name="Task2"/>
+ <bpmn2:property id="Task3" itemSubjectRef="_Task3" name="Task3"/>
+
<bpmn2:sequenceFlow id="_E1B7054B-A29B-4004-9358-4D924010200B"
sourceRef="_D01D9CA2-D9F4-4761-89AA-E6D8F824F03C"
targetRef="_3D4EC1AC-4EDC-43D0-A408-837B0695CB8A"/>
<bpmn2:sequenceFlow id="_66CF5A6C-015A-4BDB-AEA9-4D9F0CAC4B7E"
sourceRef="_B0265896-960C-4217-8F36-7F2FF511C0FC"
targetRef="_F8B24DAF-040D-4F22-9944-694910B0F3AD"/>
<bpmn2:sequenceFlow id="_F2F5F573-A9B1-4FF8-A331-4980B4D773B8"
sourceRef="_D4EDE70E-D26F-4B74-BFBE-1371286E11EE"
targetRef="_D01D9CA2-D9F4-4761-89AA-E6D8F824F03C">
diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FEELTest.java
b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FEELTest.java
index a62574b632..3ac6abba78 100644
--- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FEELTest.java
+++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FEELTest.java
@@ -18,45 +18,65 @@
*/
package org.jbpm.bpmn2;
-import java.util.HashMap;
-import java.util.Map;
-
+import org.jbpm.bpmn2.feel.GatewayFEELModel;
+import org.jbpm.bpmn2.feel.GatewayFEELProcess;
+import org.jbpm.test.utils.EventTrackerProcessListener;
+import org.jbpm.test.utils.ProcessTestHelper;
import org.junit.jupiter.api.Test;
+import org.kie.kogito.Application;
+import org.kie.kogito.process.ProcessInstance;
+import org.kie.kogito.process.ProcessInstanceExecutionException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
public class FEELTest extends JbpmBpmn2TestCase {
-
@Test
- public void testGatewayFEEL() throws Exception {
- kruntime =
createKogitoProcessRuntime("org/jbpm/bpmn2/feel/BPMN2-GatewayFEEL.bpmn2");
-
- Map<String, Object> params1 = new HashMap<String, Object>();
- params1.put("VA", Boolean.TRUE);
- params1.put("VB", Boolean.FALSE);
- org.jbpm.workflow.instance.WorkflowProcessInstance procInstance1 =
(org.jbpm.workflow.instance.WorkflowProcessInstance)
kruntime.startProcess("GatewayFEEL", params1);
- assertThat(procInstance1.getVariable("Task1")).isEqualTo("ok");
- assertThat(procInstance1.getVariable("Task2")).isEqualTo("ok");
- assertThat(procInstance1.getVariable("Task3")).isNull();
- assertNodeTriggered(procInstance1.getStringId(), "Task2", "VA and
not(VB)");
-
- Map<String, Object> params2 = new HashMap<String, Object>();
- params2.put("VA", Boolean.FALSE);
- params2.put("VB", Boolean.TRUE);
- org.jbpm.workflow.instance.WorkflowProcessInstance procInstance2 =
(org.jbpm.workflow.instance.WorkflowProcessInstance)
kruntime.startProcess("GatewayFEEL", params2);
- assertThat(procInstance2.getVariable("Task1")).isEqualTo("ok");
- assertThat(procInstance2.getVariable("Task2")).isNull();
- assertThat(procInstance2.getVariable("Task3")).isEqualTo("ok");
- assertNodeTriggered(procInstance2.getStringId(), "Task3", "VB or
not(VA)");
+ public void testGatewayFEEL() {
+ Application app = ProcessTestHelper.newApplication();
+ EventTrackerProcessListener eventTrackerProcessListener = new
EventTrackerProcessListener();
+
+ ProcessTestHelper.registerProcessEventListener(app,
eventTrackerProcessListener);
+ org.kie.kogito.process.Process<GatewayFEELModel> process =
GatewayFEELProcess.newProcess(app);
+ GatewayFEELModel model = process.createModel();
+ model.setVA(Boolean.TRUE);
+ model.setVB(Boolean.FALSE);
+ ProcessInstance<GatewayFEELModel> procInstance1 =
process.createInstance(model);
+ procInstance1.start();
+
+ assertThat(procInstance1.variables().getTask1()).isEqualTo("ok");
+ assertThat(procInstance1.variables().getTask2()).isEqualTo("ok");
+ assertThat(procInstance1.variables().getTask3()).isNull();
+
+
assertThat(eventTrackerProcessListener.tracked()).anyMatch(ProcessTestHelper.triggered("Task2"))
+ .anyMatch(ProcessTestHelper.triggered("VA and not(VB)"));
+
+ model.setVA(Boolean.FALSE);
+ model.setVB(Boolean.TRUE);
+
+ ProcessInstance<GatewayFEELModel> procInstance2 =
process.createInstance(model);
+ procInstance2.start();
+
+ assertThat(procInstance2.variables().getTask1()).isEqualTo("ok");
+ assertThat(procInstance2.variables().getTask2()).isNull();
+ assertThat(procInstance2.variables().getTask3()).isEqualTo("ok");
+
assertThat(eventTrackerProcessListener.tracked()).anyMatch(ProcessTestHelper.triggered("Task3"))
+ .anyMatch(ProcessTestHelper.triggered("VB or not(VA)"));
}
@Test
public void testGatewayFEELWrong() {
- assertThatExceptionOfType(RuntimeException.class)
- .isThrownBy(() ->
createKogitoProcessRuntime("BPMN2-GatewayFEEL-wrong.bpmn2"))
- .withMessageContaining("Invalid FEEL expression: 'VA and
Not(VB)'")
- .withMessageContaining("Invalid FEEL expression: 'VB or
nOt(VA)'");
+ Application app = ProcessTestHelper.newApplication();
+ org.kie.kogito.process.Process<GatewayFEELModel> process =
GatewayFEELProcess.newProcess(app);
+ ProcessInstance<GatewayFEELModel> instance =
process.createInstance(process.createModel());
+ instance.start();
+ assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_ERROR);
+ assertThat(instance.error().isPresent()).isTrue();
+ assertThatExceptionOfType(ProcessInstanceExecutionException.class)
+
.isThrownBy(instance::checkError).withMessageContaining("org.jbpm.process.instance.impl.FeelReturnValueEvaluatorException")
+ .withMessageContaining("ERROR Unknown variable 'VA'")
+ .withMessageContaining("ERROR Unknown variable name 'VB'");
+
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]