Skip to content

Commit 0bd2407

Browse files
Add support for rule expressions with expression logic not being at the beginning of the output rule
1 parent 9c97268 commit 0bd2407

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/ELOutputEntryExpressionPreParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class ELOutputEntryExpressionPreParser {
2020

2121
public static String parse(String expression) {
2222

23-
if (expression.startsWith("#{") || expression.startsWith("${")) {
23+
if ((expression.contains("#{") || expression.contains("${")) && expression.contains("}")) {
2424
return expression;
2525
}
2626

modules/flowable-dmn-engine/src/test/java/org/flowable/dmn/engine/test/runtime/RuntimeTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,4 +416,21 @@ public void testJsonNumbers1() {
416416

417417
assertThat(result).containsEntry("outputVariable1", "result2");
418418
}
419+
420+
@Test
421+
@DmnDeployment(resources = "org/flowable/dmn/engine/test/runtime/decisionExpressionNotAtBeginning.dmn")
422+
public void testDecisionExpressionNotAtBeginning() {
423+
Map<String, Object> processVariablesInput = new HashMap<>();
424+
processVariablesInput.put("selectedValue", "type2");
425+
426+
Map<String, Object> result = ruleService.createExecuteDecisionBuilder()
427+
.decisionKey("dmnExpression")
428+
.variables(processVariablesInput)
429+
.executeWithSingleResult();
430+
431+
assertThat(result)
432+
.containsOnly(
433+
entry("outputValue", ": this does not work : type2")
434+
);
435+
}
419436
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:flowable="http://flowable.org/dmn" xmlns:design="http://flowable.org/design" id="definition_dMNExample" name="DMN Example" namespace="http://www.flowable.org/dmn">
2+
<decision id="dmnExpression" name="DMN Example">
3+
<decisionTable id="decisionTable_dMNExample" hitPolicy="FIRST">
4+
<input label="typeValue">
5+
<inputExpression id="inputExpression_1" typeRef="string">
6+
<text>selectedValue</text>
7+
</inputExpression>
8+
</input>
9+
<output id="outputExpression_2" label="outputValue" name="outputValue" typeRef="string"></output>
10+
<rule>
11+
<inputEntry id="inputEntry_1_1">
12+
<text><![CDATA["type1"]]></text>
13+
</inputEntry>
14+
<outputEntry id="outputEntry_2_1">
15+
<text><![CDATA[${selectedValue} : this works fine]]></text>
16+
</outputEntry>
17+
</rule>
18+
<rule>
19+
<inputEntry id="inputEntry_1_2">
20+
<text><![CDATA["type2"]]></text>
21+
</inputEntry>
22+
<outputEntry id="outputEntry_2_2">
23+
<text><![CDATA[: this does not work : ${selectedValue}]]></text>
24+
</outputEntry>
25+
</rule>
26+
</decisionTable>
27+
</decision>
28+
<dmndi:DMNDI></dmndi:DMNDI>
29+
</definitions>

0 commit comments

Comments
 (0)