-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#651] Annotations: Add evaluation for TRuleAnnotations
- Loading branch information
1 parent
95491aa
commit 508f17e
Showing
15 changed files
with
590 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ed/other/decision_table_with_annotations/HandWrittenDecisionTableWithAnnotationsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.gs.dmn.generated.other.decision_table_with_annotations; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@javax.annotation.Generated(value = {"junit.ftl", "decision-table-with-annotations.dmn"}) | ||
public class HandWrittenDecisionTableWithAnnotationsTest extends com.gs.dmn.runtime.DefaultDMNBaseDecision { | ||
@org.junit.Test | ||
public void testCase001() { | ||
com.gs.dmn.runtime.ExecutionContext context_ = new com.gs.dmn.runtime.ExecutionContext(); | ||
com.gs.dmn.runtime.cache.Cache cache_ = context_.getCache(); | ||
// Initialize input data | ||
com.gs.dmn.generated.other.decision_table_with_annotations.type.TA structA = new com.gs.dmn.generated.other.decision_table_with_annotations.type.TAImpl("A", number("5")); | ||
|
||
// Check 'priceGt10' | ||
checkValues(Boolean.FALSE, new PriceGt10().apply(structA, context_)); | ||
List<String> actualAnnotations = context_.getAnnotations().stream().map(a -> a.toString()).collect(Collectors.toList()); | ||
List<String> expectedAnnotations = Arrays.asList( | ||
"Annotation('priceGt10', 2, 'Price 5 is <= 0')", | ||
"Annotation('priceGt10', 2, 'Since this is a CDATA section I can use all sorts of reserved characters like > < \" and & or write things like <foo></bar> but my document is still well formed!')" | ||
); | ||
assertEquals(expectedAnnotations, actualAnnotations); | ||
} | ||
|
||
@org.junit.Test | ||
public void testCase002() { | ||
com.gs.dmn.runtime.ExecutionContext context_ = new com.gs.dmn.runtime.ExecutionContext(); | ||
com.gs.dmn.runtime.cache.Cache cache_ = context_.getCache(); | ||
// Initialize input data | ||
com.gs.dmn.generated.other.decision_table_with_annotations.type.TA structA = new com.gs.dmn.generated.other.decision_table_with_annotations.type.TAImpl("A", number("11")); | ||
|
||
// Check 'priceGt10' | ||
checkValues(Boolean.TRUE, new PriceGt10().apply(structA, context_)); | ||
List<String> actualAnnotations = context_.getAnnotations().stream().map(a -> a.toString()).collect(Collectors.toList()); | ||
List<String> expectedAnnotations = Arrays.asList( | ||
"Annotation('priceGt10', 1, 'Logging')", | ||
"Annotation('priceGt10', 1, 'Price 11 is >= 0')" | ||
); | ||
assertEquals(expectedAnnotations, actualAnnotations); | ||
} | ||
|
||
private void checkValues(Object expected, Object actual) { | ||
com.gs.dmn.runtime.Assert.assertEquals(expected, actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
....4/decision-table-with-annotations/translator/decision-table-with-annotations-test-01.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<testCases xmlns="http://www.omg.org/spec/DMN/20160719/testcase" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<modelName>decision-table-with-annotations.dmn</modelName> | ||
<testCase id="001"> | ||
<inputNode name="structA"> | ||
<component name="name"> | ||
<value xsi:type="xsd:string">A</value> | ||
</component> | ||
<component name="price"> | ||
<value xsi:type="xsd:decimal">5</value> | ||
</component> | ||
</inputNode> | ||
<resultNode name="priceGt10" type="decision"> | ||
<expected> | ||
<value xsi:type="xsd:boolean">false</value> | ||
</expected> | ||
</resultNode> | ||
</testCase> | ||
|
||
<testCase id="002"> | ||
<inputNode name="structA"> | ||
<component name="name"> | ||
<value xsi:type="xsd:string">A</value> | ||
</component> | ||
<component name="price"> | ||
<value xsi:type="xsd:decimal">11</value> | ||
</component> | ||
</inputNode> | ||
<resultNode name="priceGt10" type="decision"> | ||
<expected> | ||
<value xsi:type="xsd:boolean">true</value> | ||
</expected> | ||
</resultNode> | ||
</testCase> | ||
</testCases> |
62 changes: 62 additions & 0 deletions
62
.../other/1.4/decision-table-with-annotations/translator/decision-table-with-annotations.dmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<definitions exporter="DMN Modeler; Method and Style trisofix.xslt" exporterVersion="5.0.35; 1.0" | ||
namespace="http://www.trisotech.com/definitions/_92a0c25f-707e-4fc8-ae2d-2ab51ebe6bb6" name="tableTest" | ||
triso:logoChoice="Default" id="_92a0c25f-707e-4fc8-ae2d-2ab51ebe6bb6" | ||
xmlns="https://www.omg.org/spec/DMN/20211108/MODEL/" | ||
xmlns:triso="http://www.trisotech.com/2015/triso/modeling"> | ||
<itemDefinition name="tA" id="tA"> | ||
<itemComponent name="name" id="_adf6f96a-c574-4ba7-a305-ea14ad9852b1"> | ||
<typeRef>string</typeRef> | ||
</itemComponent> | ||
<itemComponent name="price" id="_d297adac-f086-42a0-989e-04c431270f77"> | ||
<typeRef>number</typeRef> | ||
</itemComponent> | ||
</itemDefinition> | ||
<inputData name="structA" id="_18b9d486-1ec0-436d-af4b-3e4567e8bca9"> | ||
<variable typeRef="tA" name="structA"/> | ||
</inputData> | ||
<decision name="priceGt10" id="_2683ec7f-fa17-4a1e-9151-8077a10c561f"> | ||
<variable typeRef="boolean" name="priceGt10"/> | ||
<informationRequirement id="_1a34b197-0218-447f-8fa4-204517c0f851"> | ||
<requiredInput href="#_18b9d486-1ec0-436d-af4b-3e4567e8bca9"/> | ||
</informationRequirement> | ||
<decisionTable hitPolicy="UNIQUE" outputLabel="priceGt10"> | ||
<input id="_bfb04e56-12dc-461f-a341-f5522efc7388" label="structA.price"> | ||
<inputExpression typeRef="number"> | ||
<text>structA.price</text> | ||
</inputExpression> | ||
</input> | ||
<output id="_89841156-1ca0-4704-9551-39205fdb7ae2"/> | ||
<rule id="_543c9e93-e815-41df-8884-b40f726a847e"> | ||
<inputEntry id="_543c9e93-e815-41df-8884-b40f726a847e-0"> | ||
<text>>10</text> | ||
</inputEntry> | ||
<outputEntry id="_543c9e93-e815-41df-8884-b40f726a847e-1"> | ||
<text>true</text> | ||
</outputEntry> | ||
<annotationEntry> | ||
<text>"Logging"</text> | ||
</annotationEntry> | ||
<annotationEntry> | ||
<text>string join(["Price ", string(structA.price), " is >= 0"], " ")</text> | ||
</annotationEntry> | ||
</rule> | ||
<rule id="_41adf645-547d-4c65-97c1-355c297d02d6"> | ||
<inputEntry id="_41adf645-547d-4c65-97c1-355c297d02d6-0"> | ||
<text><=10</text> | ||
</inputEntry> | ||
<outputEntry id="_41adf645-547d-4c65-97c1-355c297d02d6-1"> | ||
<text>false</text> | ||
</outputEntry> | ||
<annotationEntry> | ||
<text>"Price " + string(structA.price) + " is <= 0"</text> | ||
</annotationEntry> | ||
<annotationEntry> | ||
<text><![CDATA[ | ||
"Since this is a CDATA section I can use all sorts of reserved characters like > < \" and & or write things like <foo></bar> but my document is still well formed!" | ||
]]></text> | ||
</annotationEntry> | ||
</rule> | ||
</decisionTable> | ||
</decision> | ||
</definitions> |
7 changes: 7 additions & 0 deletions
7
....4/decision-table-with-annotations/translator/expected/java/dmn/ModelElementRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
public class ModelElementRegistry extends com.gs.dmn.runtime.discovery.ModelElementRegistry { | ||
public ModelElementRegistry() { | ||
// Register elements from model 'tableTest' | ||
register("priceGt10", "PriceGt10"); | ||
} | ||
} |
Oops, something went wrong.