Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[incubator-kie-issues#1023] DMN - move significant models to test-resources module #5796

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ public void testImport() {

@Test
public void testEmptyNamedModelImport() {
final DMNRuntime runtime = createRuntimeWithAdditionalResources("Importing_EmptyNamed_Model.dmn",
final DMNRuntime runtime = createRuntimeWithAdditionalResources("valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
this.getClass(),
"Imported_Model_Unamed.dmn");
"valid_models/DMNv1_5/Imported_Model_Unamed.dmn");

final DMNModel importedModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_f27bb64b-6fc7-4e1f-9848-11ba35e0df44",
"Imported Model");
Expand Down Expand Up @@ -320,9 +320,9 @@ public void testEmptyNamedModelImport() {

@Test
public void testOverridingEmptyNamedModelImport() {
final DMNRuntime runtime = createRuntimeWithAdditionalResources("Importing_OverridingEmptyNamed_Model.dmn",
final DMNRuntime runtime = createRuntimeWithAdditionalResources("valid_models/DMNv1_5/Importing_OverridingEmptyNamed_Model.dmn",
this.getClass(),
"Imported_Model_Unamed.dmn");
"valid_models/DMNv1_5/Imported_Model_Unamed.dmn");

final DMNModel importedModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_f27bb64b-6fc7-4e1f-9848-11ba35e0df44",
"Imported Model");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public void testAllowedValuesChecksInsideCollectionElement() {

@Test
public void testAllowedValuesChecksInsideCollection() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "AllowedValuesChecksInsideCollection.dmn", this.getClass() );
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn", this.getClass() );
final DMNModel dmnModel = runtime.getModel(
"http://www.trisotech.com/definitions/_238bd96d-47cd-4746-831b-504f3e77b442",
"AllowedValuesChecksInsideCollection" );
Expand Down Expand Up @@ -325,7 +325,7 @@ public void testAllowedValuesChecksInsideCollection() {

@Test
public void testTypeConstraintsChecks() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "TypeConstraintsChecks.dmn", this.getClass() );
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("valid_models/DMNv1_5/TypeConstraintsChecks.dmn", this.getClass() );
final DMNModel dmnModel = runtime.getModel(
"http://www.trisotech.com/definitions/_238bd96d-47cd-4746-831b-504f3e77b442",
"TypeConstraintsChecks" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.time.LocalTime;
import java.time.OffsetTime;
import java.time.Period;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.chrono.ChronoPeriod;
Expand Down Expand Up @@ -662,7 +661,7 @@ public void testDateAndTime() {

@Test
public void testDateToDateTimeFunction() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DateToDateTimeFunction.dmn", this.getClass());
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("valid_models/DMNv1_5/DateToDateTimeFunction.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_A7F17D7B-F0AB-4C0B-B521-02EA26C2FBEE",
"new-file");
assertThat(dmnModel).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public class UnnamedImportUtilsTest {

@Test
public void isInUnnamedImportTrue() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Importing_EmptyNamed_Model" +
final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("valid_models/DMNv1_5/Importing_EmptyNamed_Model" +
".dmn",
this.getClass(),
"Imported_Model_Unamed.dmn");
"valid_models/DMNv1_5/Imported_Model_Unamed.dmn");

final DMNModel importedModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_f27bb64b-6fc7-4e1f-9848-11ba35e0df44",
"Imported Model");
Expand All @@ -47,9 +47,9 @@ public void isInUnnamedImportTrue() {

@Test
public void isInUnnamedImportFalse() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Importing_Named_Model.dmn",
final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("valid_models/DMNv1_5/Importing_Named_Model.dmn",
this.getClass(),
"Imported_Model_Unamed.dmn");
"valid_models/DMNv1_5/Imported_Model_Unamed.dmn");

final DMNModel importedModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_f27bb64b-6fc7-4e1f-9848-11ba35e0df44",
"Imported Model");
Expand All @@ -67,7 +67,7 @@ public void isInUnnamedImportFalse() {
@Test
public void addIfNotPresentTrue() throws IOException {
URL importedModelFileResource = Thread.currentThread().getContextClassLoader().getResource(
"Imported_Model_Unamed.dmn");
"valid_models/DMNv1_5/Imported_Model_Unamed.dmn");
assertNotNull(importedModelFileResource);
try (InputStream is = importedModelFileResource.openStream()) {
String xml = new String(is.readAllBytes(), StandardCharsets.UTF_8);
Expand All @@ -82,16 +82,16 @@ public void addIfNotPresentTrue() throws IOException {

@Test
public void addIfNotPresentFalse() throws IOException {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Importing_EmptyNamed_Model.dmn",
final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
this.getClass(),
"Imported_Model_Unamed.dmn");
"valid_models/DMNv1_5/Imported_Model_Unamed.dmn");
final DMNModelImpl importingModel = (DMNModelImpl)runtime.getModel("http://www.trisotech.com/dmn/definitions/_f79aa7a4-f9a3-410a-ac95-bea496edabgc",
"Importing empty-named Model");
assertThat(importingModel).isNotNull();

Definitions importingDefinitions = importingModel.getDefinitions();
URL importedModelFileResource = Thread.currentThread().getContextClassLoader().getResource(
"Imported_Model_Unamed.dmn");
"valid_models/DMNv1_5/Imported_Model_Unamed.dmn");
assertNotNull(importedModelFileResource);
try (InputStream is = importedModelFileResource.openStream()) {
String importedXml = new String(is.readAllBytes(), StandardCharsets.UTF_8);
Expand Down
26 changes: 26 additions & 0 deletions kie-dmn/kie-dmn-test-resources/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
DMN Test Resources
==================

This module is meant to be the ultimate single-source-of truth about DMN models used for testing purposes.

The models are stored under `src/test/resources`, so the module has to be imported has

```xml
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-dmn-test-resources</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
```

to have them available.

Models are split in two categories: _valid_models_ and __invalid_models_.
The former are valid models, expected to succeed the DMN validation.
The latter are invalid ones, expected to have some errors, and used to check that such errors are detected by validation.

For both categories, there is a subdivision: _DMNv1_x_ and _DMNV1_5_.
The former are all the models created before the 1.5 implementation, that are hard to sort based on the version relates to.
The latter contains models with 1.5. specific feature.
In the future, for each new DMN release there will be a specific folder.
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<dmn:definitions xmlns:dmn="http://www.omg.org/spec/DMN/20180521/MODEL/" xmlns="https://kiegroup.org/dmn/_79B69A7F-5A25-4B53-BD6A-3216EDC246ED" xmlns:feel="http://www.omg.org/spec/DMN/20180521/FEEL/" xmlns:kie="http://www.drools.org/kie/dmn/1.2" xmlns:dmndi="http://www.omg.org/spec/DMN/20180521/DMNDI/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" id="_E01B9C96-BCD5-4618-AC02-35F77D1065E2" name="loan" typeLanguage="http://www.omg.org/spec/DMN/20180521/FEEL/" namespace="https://kiegroup.org/dmn/_79B69A7F-5A25-4B53-BD6A-3216EDC246ED">
<dmn:extensionElements/>
<dmn:itemDefinition id="_94619DCD-2602-4A43-97E9-9809D76F15A5" name="tLoan" isCollection="false">
<dmn:itemComponent id="_3C8953D0-F1AD-40F6-BC5E-813F3185F3F1" name="amount" isCollection="false">
<dmn:typeRef>number</dmn:typeRef>
</dmn:itemComponent>
<dmn:itemComponent id="_1CF9A4C0-9218-4F96-AB1A-66570002B7C5" name="years" isCollection="false">
<dmn:typeRef>number</dmn:typeRef>
</dmn:itemComponent>
</dmn:itemDefinition>
<dmn:inputData id="_058269A1-A5AC-44CB-9479-16A04DC19D77" name="Credit score">
<dmn:extensionElements/>
<dmn:variable id="_BA408840-4504-44EB-BD7F-6261F787E342" name="Credit score" typeRef="number"/>
</dmn:inputData>
<dmn:inputData id="_65226EA1-EE4A-41F1-91A2-B2A940A75982" name="Salary">
<dmn:extensionElements/>
<dmn:variable id="_204FE05E-BCF8-4AF5-AD36-B5A04E0EB929" name="Salary" typeRef="number"/>
</dmn:inputData>
<dmn:inputData id="_516E0AEC-03F3-43F4-B886-C489CA82A1C9" name="Loan">
<dmn:extensionElements/>
<dmn:variable id="_90456001-E9FA-4DDC-B2BA-DF1B62A25AAA" name="Loan" typeRef="tLoan"/>
</dmn:inputData>
<dmn:decision id="_6A3FDF72-7F17-4DC5-AC1D-1DCC972C0146" name="Preapproval">
<dmn:extensionElements/>
<dmn:variable id="_2C06D150-7AB2-48C9-BFC6-F48884FD96EF" name="Preapproval" typeRef="boolean"/>
<dmn:informationRequirement id="_9BFEFD1E-9830-4630-8171-B6F1D3100308">
<dmn:requiredInput href="#_058269A1-A5AC-44CB-9479-16A04DC19D77"/>
</dmn:informationRequirement>
<dmn:informationRequirement id="_4736D6D5-5A61-4C0E-ADBA-5AAD99221445">
<dmn:requiredDecision href="#_50635164-1A27-4B84-AE16-639A118CE44C"/>
</dmn:informationRequirement>
<dmn:decisionTable id="_E7994A2B-1189-4BE5-9382-891D48E87D47" hitPolicy="UNIQUE" preferredOrientation="Rule-as-Row">
<dmn:input id="_9CCC5EBB-BC59-4397-B478-BB434279EBF8">
<dmn:inputExpression id="_85A80C30-68FA-405F-BE6D-D1B6C484CD81" typeRef="number">
<dmn:text>Credit score</dmn:text>
</dmn:inputExpression>
</dmn:input>
<dmn:input id="_D160037A-3B50-44FE-BC28-700F750D1A3A">
<dmn:inputExpression id="_2774CDB9-0B9D-4B89-9639-5D1FD7D6D61B" typeRef="number">
<dmn:text>DTI</dmn:text>
</dmn:inputExpression>
</dmn:input>
<dmn:output id="_8220E87A-3913-4FC5-9926-4A9FD28F82EA"/>
<dmn:annotation name="annotation-1"/>
<dmn:rule id="_C09BF27F-E03C-4390-8719-E7411784ABCB">
<dmn:inputEntry id="_C02D6987-5B78-42ED-B48D-E3CE5844C22B">
<dmn:text>&lt;700</dmn:text>
</dmn:inputEntry>
<dmn:inputEntry id="_922FFAE0-9635-420B-8002-4583065E6710">
<dmn:text>&lt;=.28</dmn:text>
</dmn:inputEntry>
<dmn:outputEntry id="_75A30858-95A6-46F4-89D5-BFFF8B3739AD">
<dmn:text>true</dmn:text>
</dmn:outputEntry>
<dmn:annotationEntry>
<dmn:text/>
</dmn:annotationEntry>
</dmn:rule>
<dmn:rule id="_5CE22529-735A-43D8-9043-E342F58D1CDD">
<dmn:inputEntry id="_14C78BCF-736B-4032-8AB8-B73967479EEF">
<dmn:text>&gt;=700</dmn:text>
</dmn:inputEntry>
<dmn:inputEntry id="_6AA1D822-C08E-4B4E-BE8B-4C3587E6F034">
<dmn:text>-</dmn:text>
</dmn:inputEntry>
<dmn:outputEntry id="_CD1AFB69-DDC6-416E-B780-FE2FB3AAC6C1">
<dmn:text>true</dmn:text>
</dmn:outputEntry>
<dmn:annotationEntry>
<dmn:text/>
</dmn:annotationEntry>
</dmn:rule>
<dmn:rule id="_5EB4DDC3-CE49-419A-B7C8-7A6916D6334F">
<dmn:inputEntry id="_2F5D6384-4AE6-4408-88F4-4D3C86F26649">
<dmn:text>&lt;700</dmn:text>
</dmn:inputEntry>
<dmn:inputEntry id="_5CA8DA56-07BE-4410-85DD-800508300DB8">
<dmn:text>&gt;=.28</dmn:text>
</dmn:inputEntry>
<dmn:outputEntry id="_8B85A627-73DD-46E7-99DA-26499B3DD9BD">
<dmn:text>false</dmn:text>
</dmn:outputEntry>
<dmn:annotationEntry>
<dmn:text/>
</dmn:annotationEntry>
</dmn:rule>
</dmn:decisionTable>
</dmn:decision>
<dmn:decision id="_50635164-1A27-4B84-AE16-639A118CE44C" name="DTI">
<dmn:extensionElements/>
<dmn:variable id="_7FF18790-80C8-4124-9BFB-93383CE6A50F" name="DTI"/>
<dmn:informationRequirement id="_7A538A2F-562E-4E49-B5F0-572FFCFEF4CB">
<dmn:requiredInput href="#_516E0AEC-03F3-43F4-B886-C489CA82A1C9"/>
</dmn:informationRequirement>
<dmn:informationRequirement id="_E508941C-2DE2-41DD-8406-EA8AD646DB7F">
<dmn:requiredInput href="#_65226EA1-EE4A-41F1-91A2-B2A940A75982"/>
</dmn:informationRequirement>
<dmn:literalExpression id="_60A349DD-1F30-488B-BA65-74160F6496F3">
<dmn:text>(Loan.amount / Loan.years)/Salary</dmn:text>
</dmn:literalExpression>
</dmn:decision>
<dmndi:DMNDI>
<dmndi:DMNDiagram id="_E8F34173-5A17-4B9E-936F-72CFCF1210C4" name="DRG">
<di:extension>
<kie:ComponentsWidthsExtension>
<kie:ComponentWidths dmnElementRef="_E7994A2B-1189-4BE5-9382-891D48E87D47">
<kie:width>50</kie:width>
<kie:width>100</kie:width>
<kie:width>100</kie:width>
<kie:width>100</kie:width>
<kie:width>100</kie:width>
</kie:ComponentWidths>
<kie:ComponentWidths dmnElementRef="_60A349DD-1F30-488B-BA65-74160F6496F3">
<kie:width>300</kie:width>
</kie:ComponentWidths>
</kie:ComponentsWidthsExtension>
</di:extension>
<dmndi:DMNShape id="dmnshape-drg-_058269A1-A5AC-44CB-9479-16A04DC19D77" dmnElementRef="_058269A1-A5AC-44CB-9479-16A04DC19D77" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
</dmndi:DMNStyle>
<dc:Bounds x="181" y="119" width="100" height="50"/>
<dmndi:DMNLabel/>
</dmndi:DMNShape>
<dmndi:DMNShape id="dmnshape-drg-_65226EA1-EE4A-41F1-91A2-B2A940A75982" dmnElementRef="_65226EA1-EE4A-41F1-91A2-B2A940A75982" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
</dmndi:DMNStyle>
<dc:Bounds x="181" y="219" width="100" height="50"/>
<dmndi:DMNLabel/>
</dmndi:DMNShape>
<dmndi:DMNShape id="dmnshape-drg-_516E0AEC-03F3-43F4-B886-C489CA82A1C9" dmnElementRef="_516E0AEC-03F3-43F4-B886-C489CA82A1C9" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
</dmndi:DMNStyle>
<dc:Bounds x="181" y="319" width="100" height="50"/>
<dmndi:DMNLabel/>
</dmndi:DMNShape>
<dmndi:DMNShape id="dmnshape-drg-_6A3FDF72-7F17-4DC5-AC1D-1DCC972C0146" dmnElementRef="_6A3FDF72-7F17-4DC5-AC1D-1DCC972C0146" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
</dmndi:DMNStyle>
<dc:Bounds x="361" y="119" width="100" height="50"/>
<dmndi:DMNLabel/>
</dmndi:DMNShape>
<dmndi:DMNShape id="dmnshape-drg-_50635164-1A27-4B84-AE16-639A118CE44C" dmnElementRef="_50635164-1A27-4B84-AE16-639A118CE44C" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
</dmndi:DMNStyle>
<dc:Bounds x="361" y="270" width="100" height="50"/>
<dmndi:DMNLabel/>
</dmndi:DMNShape>
<dmndi:DMNEdge id="dmnedge-drg-_9BFEFD1E-9830-4630-8171-B6F1D3100308" dmnElementRef="_9BFEFD1E-9830-4630-8171-B6F1D3100308">
<di:waypoint x="281" y="144"/>
<di:waypoint x="361" y="144"/>
</dmndi:DMNEdge>
<dmndi:DMNEdge id="dmnedge-drg-_4736D6D5-5A61-4C0E-ADBA-5AAD99221445" dmnElementRef="_4736D6D5-5A61-4C0E-ADBA-5AAD99221445">
<di:waypoint x="411" y="295"/>
<di:waypoint x="411" y="144"/>
</dmndi:DMNEdge>
<dmndi:DMNEdge id="dmnedge-drg-_7A538A2F-562E-4E49-B5F0-572FFCFEF4CB" dmnElementRef="_7A538A2F-562E-4E49-B5F0-572FFCFEF4CB">
<di:waypoint x="231" y="344"/>
<di:waypoint x="411" y="295"/>
</dmndi:DMNEdge>
<dmndi:DMNEdge id="dmnedge-drg-_E508941C-2DE2-41DD-8406-EA8AD646DB7F" dmnElementRef="_E508941C-2DE2-41DD-8406-EA8AD646DB7F">
<di:waypoint x="231" y="244"/>
<di:waypoint x="411" y="295"/>
</dmndi:DMNEdge>
</dmndi:DMNDiagram>
</dmndi:DMNDI>
</dmn:definitions>
Loading
Loading