Skip to content

Commit

Permalink
[incubator-kie-issues-1131] v7 migration to code generation (#3626)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhitocode authored Aug 29, 2024
1 parent 5c62c82 commit 8064dd7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.org/bpmn20">
<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">
Expand Down
76 changes: 48 additions & 28 deletions jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FEELTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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'");

}

}

0 comments on commit 8064dd7

Please sign in to comment.