Skip to content

Commit 8064dd7

Browse files
authored
[incubator-kie-issues-1131] v7 migration to code generation (#3626)
1 parent 5c62c82 commit 8064dd7

File tree

2 files changed

+55
-28
lines changed

2 files changed

+55
-28
lines changed

jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/feel/BPMN2-GatewayFEEL.bpmn2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@
2020
<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.org/bpmn20">
2121
<bpmn2:itemDefinition id="_VAItem" structureRef="Boolean"/>
2222
<bpmn2:itemDefinition id="_VBItem" structureRef="Boolean"/>
23+
<bpmn2:itemDefinition id="_Task1" structureRef="String"/>
24+
<bpmn2:itemDefinition id="_Task2" structureRef="String"/>
25+
<bpmn2:itemDefinition id="_Task3" structureRef="String"/>
2326
<bpmn2:process id="GatewayFEEL" drools:packageName="org.jbpm.bpmn2.feel" drools:version="1.0" drools:adHoc="false" name="BPMN2-GatewayFEEL" isExecutable="true" processType="Public">
2427
<bpmn2:property id="VA" itemSubjectRef="_VAItem" name="VA"/>
2528
<bpmn2:property id="VB" itemSubjectRef="_VBItem" name="VB"/>
29+
<bpmn2:property id="Task1" itemSubjectRef="_Task1" name="Task1"/>
30+
<bpmn2:property id="Task2" itemSubjectRef="_Task2" name="Task2"/>
31+
<bpmn2:property id="Task3" itemSubjectRef="_Task3" name="Task3"/>
32+
2633
<bpmn2:sequenceFlow id="_E1B7054B-A29B-4004-9358-4D924010200B" sourceRef="_D01D9CA2-D9F4-4761-89AA-E6D8F824F03C" targetRef="_3D4EC1AC-4EDC-43D0-A408-837B0695CB8A"/>
2734
<bpmn2:sequenceFlow id="_66CF5A6C-015A-4BDB-AEA9-4D9F0CAC4B7E" sourceRef="_B0265896-960C-4217-8F36-7F2FF511C0FC" targetRef="_F8B24DAF-040D-4F22-9944-694910B0F3AD"/>
2835
<bpmn2:sequenceFlow id="_F2F5F573-A9B1-4FF8-A331-4980B4D773B8" sourceRef="_D4EDE70E-D26F-4B74-BFBE-1371286E11EE" targetRef="_D01D9CA2-D9F4-4761-89AA-E6D8F824F03C">

jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FEELTest.java

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,65 @@
1818
*/
1919
package org.jbpm.bpmn2;
2020

21-
import java.util.HashMap;
22-
import java.util.Map;
23-
21+
import org.jbpm.bpmn2.feel.GatewayFEELModel;
22+
import org.jbpm.bpmn2.feel.GatewayFEELProcess;
23+
import org.jbpm.test.utils.EventTrackerProcessListener;
24+
import org.jbpm.test.utils.ProcessTestHelper;
2425
import org.junit.jupiter.api.Test;
26+
import org.kie.kogito.Application;
27+
import org.kie.kogito.process.ProcessInstance;
28+
import org.kie.kogito.process.ProcessInstanceExecutionException;
2529

2630
import static org.assertj.core.api.Assertions.assertThat;
2731
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
2832

2933
public class FEELTest extends JbpmBpmn2TestCase {
30-
3134
@Test
32-
public void testGatewayFEEL() throws Exception {
33-
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/feel/BPMN2-GatewayFEEL.bpmn2");
34-
35-
Map<String, Object> params1 = new HashMap<String, Object>();
36-
params1.put("VA", Boolean.TRUE);
37-
params1.put("VB", Boolean.FALSE);
38-
org.jbpm.workflow.instance.WorkflowProcessInstance procInstance1 = (org.jbpm.workflow.instance.WorkflowProcessInstance) kruntime.startProcess("GatewayFEEL", params1);
39-
assertThat(procInstance1.getVariable("Task1")).isEqualTo("ok");
40-
assertThat(procInstance1.getVariable("Task2")).isEqualTo("ok");
41-
assertThat(procInstance1.getVariable("Task3")).isNull();
42-
assertNodeTriggered(procInstance1.getStringId(), "Task2", "VA and not(VB)");
43-
44-
Map<String, Object> params2 = new HashMap<String, Object>();
45-
params2.put("VA", Boolean.FALSE);
46-
params2.put("VB", Boolean.TRUE);
47-
org.jbpm.workflow.instance.WorkflowProcessInstance procInstance2 = (org.jbpm.workflow.instance.WorkflowProcessInstance) kruntime.startProcess("GatewayFEEL", params2);
48-
assertThat(procInstance2.getVariable("Task1")).isEqualTo("ok");
49-
assertThat(procInstance2.getVariable("Task2")).isNull();
50-
assertThat(procInstance2.getVariable("Task3")).isEqualTo("ok");
51-
assertNodeTriggered(procInstance2.getStringId(), "Task3", "VB or not(VA)");
35+
public void testGatewayFEEL() {
36+
Application app = ProcessTestHelper.newApplication();
37+
EventTrackerProcessListener eventTrackerProcessListener = new EventTrackerProcessListener();
38+
39+
ProcessTestHelper.registerProcessEventListener(app, eventTrackerProcessListener);
40+
org.kie.kogito.process.Process<GatewayFEELModel> process = GatewayFEELProcess.newProcess(app);
41+
GatewayFEELModel model = process.createModel();
42+
model.setVA(Boolean.TRUE);
43+
model.setVB(Boolean.FALSE);
44+
ProcessInstance<GatewayFEELModel> procInstance1 = process.createInstance(model);
45+
procInstance1.start();
46+
47+
assertThat(procInstance1.variables().getTask1()).isEqualTo("ok");
48+
assertThat(procInstance1.variables().getTask2()).isEqualTo("ok");
49+
assertThat(procInstance1.variables().getTask3()).isNull();
50+
51+
assertThat(eventTrackerProcessListener.tracked()).anyMatch(ProcessTestHelper.triggered("Task2"))
52+
.anyMatch(ProcessTestHelper.triggered("VA and not(VB)"));
53+
54+
model.setVA(Boolean.FALSE);
55+
model.setVB(Boolean.TRUE);
56+
57+
ProcessInstance<GatewayFEELModel> procInstance2 = process.createInstance(model);
58+
procInstance2.start();
59+
60+
assertThat(procInstance2.variables().getTask1()).isEqualTo("ok");
61+
assertThat(procInstance2.variables().getTask2()).isNull();
62+
assertThat(procInstance2.variables().getTask3()).isEqualTo("ok");
63+
assertThat(eventTrackerProcessListener.tracked()).anyMatch(ProcessTestHelper.triggered("Task3"))
64+
.anyMatch(ProcessTestHelper.triggered("VB or not(VA)"));
5265
}
5366

5467
@Test
5568
public void testGatewayFEELWrong() {
56-
assertThatExceptionOfType(RuntimeException.class)
57-
.isThrownBy(() -> createKogitoProcessRuntime("BPMN2-GatewayFEEL-wrong.bpmn2"))
58-
.withMessageContaining("Invalid FEEL expression: 'VA and Not(VB)'")
59-
.withMessageContaining("Invalid FEEL expression: 'VB or nOt(VA)'");
69+
Application app = ProcessTestHelper.newApplication();
70+
org.kie.kogito.process.Process<GatewayFEELModel> process = GatewayFEELProcess.newProcess(app);
71+
ProcessInstance<GatewayFEELModel> instance = process.createInstance(process.createModel());
72+
instance.start();
73+
assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_ERROR);
74+
assertThat(instance.error().isPresent()).isTrue();
75+
assertThatExceptionOfType(ProcessInstanceExecutionException.class)
76+
.isThrownBy(instance::checkError).withMessageContaining("org.jbpm.process.instance.impl.FeelReturnValueEvaluatorException")
77+
.withMessageContaining("ERROR Unknown variable 'VA'")
78+
.withMessageContaining("ERROR Unknown variable name 'VB'");
79+
6080
}
6181

6282
}

0 commit comments

Comments
 (0)