You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "gitgabrio (via GitHub)" <gi...@apache.org> on 2024/03/25 13:54:08 UTC

[PR] [incubator-kie-issues#1043] Use shared DMN models for testing purpose [incubator-kie-tools]

gitgabrio opened a new pull request, #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207

   Fixes [https://github.com/apache/incubator-kie-issues/issues/1043]
   
   This PR:
   
   1. import models from `org.kie:kie-dmn-test-resources` in the newly-created package `dmn-testing-models`
   2. refactor idempotency.test.ts to use such models
   3. refactor xsdSequence.test.ts to clearly identify two different kind of tests
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1539219359


##########
packages/dmn-testing-models/pom.xml:
##########
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~ 
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~ 
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.      
+-->
+<project
+        xmlns="http://maven.apache.org/POM/4.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.kie.tools</groupId>
+    <artifactId>dmn-testing-models</artifactId>
+    <version>${revision}</version>
+    <packaging>jar</packaging>
+
+    <name>DMN Testing Models</name>
+    <description>Testing models for DMN editor</description>
+
+    <licenses>
+        <license>
+            <name>Apache Software License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <scm>
+        <connection>scm:git:git@github.com:apache/incubator-kie-tools.git</connection>
+        <developerConnection>scm:git:git@github.com:apache/incubator-kie-tools.git</developerConnection>
+        <url>scm:git:git@github.com:apache/incubator-kie-tools.git</url>
+    </scm>
+
+    <developers>
+        <developer>
+            <name>All developers are listed in the KIE GitHub organization</name>
+            <url>https://github.com/orgs/kiegroup/people</url>
+        </developer>
+    </developers>
+
+    <repositories>
+        <repository>
+            <!-- Duplicating the Maven Central repository here (as it is already coming from Super POM) makes the build much faster,
+                 as the Maven Central is now treated as the first (default) repository (because it is before the Apache Nexus one).
+                 Artifacts with release (fixed) versions are being downloaded primarily from there. Without the central being the
+                 first repository the Apache Nexus would be contacted first and since it is quite slow it slows down the build.
+                 We use Apache repo only to download our SNAPSHOTs. -->
+            <id>central</id>
+            <name>Central Repository</name>
+            <url>https://repo.maven.apache.org/maven2</url>
+            <layout>default</layout>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+        <repository>
+            <id>apache-public-repository-group</id>
+            <name>Apache Public Repository Group</name>
+            <url>https://repository.apache.org/content/groups/public/</url>
+            <releases>
+                <enabled>true</enabled>
+                <updatePolicy>never</updatePolicy>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+                <updatePolicy>daily</updatePolicy>
+            </snapshots>
+        </repository>
+    </repositories>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <dependency-plugin.version>3.6.1</dependency-plugin.version>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.kie</groupId>
+                <artifactId>kie-dmn-test-resources</artifactId>
+                <version>${version.org.kie.kogito}</version>
+                <classifier>tests</classifier>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.kie</groupId>
+            <artifactId>kie-dmn-test-resources</artifactId>
+            <classifier>tests</classifier>
+        </dependency>
+    </dependencies>
+
+    <build>
+<!--        <resources>-->
+<!--            &lt;!&ndash; DMN generated resources unpacked from org.kie:kie-dmn-test-resources &ndash;&gt;-->
+<!--            <resource>-->
+<!--                <directory>${project.build.directory}/generated-resources/valid_models</directory>-->
+<!--            </resource>-->
+<!--        </resources>-->

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [incubator-kie-issues#1043] Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537724355


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];
 
 describe("idempotency", () => {
   for (const file of files) {
-    test(path.basename(file), () => {
-      const xml_original = fs.readFileSync(path.join(__dirname, file), "utf-8");
-
-      const { parser, builder } = getMarshaller(xml_original, { upgradeTo: "latest" });
-      const json = parser.parse();
-
-      const xml_firstPass = builder.build(json);
-      const xml_secondPass = builder.build(getMarshaller(xml_firstPass, { upgradeTo: "latest" }).parser.parse());
+    testFile(path.join(__dirname, file));
+  }
+});
 
-      expect(xml_firstPass).toStrictEqual(xml_secondPass);
-    });
+describe("idempotency_all", () => {
+  for (const models_paths of testing_models_paths) {
+    const parent_path = path.join(__dirname, models_paths);
+    testDirectory(parent_path);
   }

Review Comment:
   @jomarko I see the point, but IMO:
   
   1. these class has two testing methods, one of which uses explicitily defined files
   2. one of the goal is to allow "transparent" inclusion of new models, i.e. whenever we add a model to the original jar, it will immediately goes under test, enhancing bug-discovery time; having to synchronize the expected number (or also name) of files would impair noticeably that, making PR much more cumbersome to create
   3. if we move the test elsewhere, the method will throw a directory not found (or similar) error
   4. the only way to move files to different directory would be changing the pom.xml itself, in which case I'm expecting people to be aware of consequences
   5. the other possibility would be to change the structure of the jar itself, but there seems no reason to do that and, eventually, the modification should be reflected to the pom.xml, to keep the same destination folder
   
   Does this make sense ? WDYT ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538015340


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",

Review Comment:
   Ok, but why should we stop using those files in the idempotency tests?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1571391333


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -21,6 +21,8 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
+const dmnTestingModels = require.resolve("@kie-tools/dmn-testing-models");

Review Comment:
   I was talking about the require.resolve() with the package.json here :P



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570132671


##########
packages/dmn-testing-models/env/index.js:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const { varsWithName, composeEnv } = require("@kie-tools-scripts/build-env");
+
+module.exports = composeEnv([require("@kie-tools/root-env/env")], {
+  vars: varsWithName({}),
+  get env() {
+    return {
+      dmnTestingModel: {
+        version: require("../package.json").version,
+      },

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1574783758


##########
packages/dmn-marshaller/tests/dmnSemanticComparison.test.ts:
##########
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { fail } from "assert";
+import {
+  checkDmnSemanticComparison,
+  checkDmnSemanticComparisonWithImports,
+} from "@kie-tools/dmn-marshaller-backend-compatibility-tester";
+
+/**
+ * This test suite compares the xml generated (parsed and built) by the dmn-parser with the original xml.
+ * The original xml and the generated one are passed and compered to the KIE DMN Core backend API.
+ * A JBang script is used to actually call the KIE DMN Core backend API.
+ */
+
+const dmnTestingModelsPath = path.dirname(require.resolve("@kie-tools/dmn-testing-models/package.json"));
+
+const dmnTestingModels = [
+  "dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/NegationOfDurationEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "dist/valid_models/DMNv1_x/multiple/Financial.dmn",
+  "dist/valid_models/DMNv1_x/multiple/Imported_Traffic_Violation.dmn",
+  "dist/valid_models/DMNv1_x/multiple/stdlib.dmn",
+  "dist/valid_models/DMNv1_x/allTypes.dmn",
+  "dist/valid_models/DMNv1_x/dtevent.dmn",
+  "dist/valid_models/DMNv1_x/habitability.dmn",
+  "dist/valid_models/DMNv1_x/loan.dmn",
+  "dist/valid_models/DMNv1_x/LoanEligibility.dmn",
+  "dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "dist/valid_models/DMNv1_x/Prequalification.dmn",
+  "dist/valid_models/DMNv1_x/testWithExtensionElements.dmn",
+  "dist/valid_models/DMNv1_x/Traffic Violation Simple.dmn",
+  "dist/valid_models/DMNv1_x/Traffic Violation.dmn",

Review Comment:
   @jomarko This is a good question. 
   The reason for this behavior is intentional and it's because we need to discriminate between DMN models that import a DMN model and DMN models that don't.
   In the first case, if want to validate / or check for semantic comparison, you need to pass both models (the importer and the imported) together to the JBang script.
   So, the first array holds all the DMN files that don't have any imported DMN files.
   The second array holds the DMN files that import another DMN file (both are specified).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1574807507


##########
packages/dmn-marshaller-backend-compatibility-tester/src/DmnSemanticComparison.java:
##########
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+///usr/bin/env jbang "$0" "$@" ; exit $?
+//SOURCES ./DmnMarshallerBackendCompatibilityTesterScript.java
+/* Please do not declare new dependencies here, but in the above Parent class to preserve 
+ *  the dependencies fetching mechanism */
+
+package jbang;
+
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+import org.kie.api.io.Resource;
+import org.kie.dmn.api.core.DMNContext;
+import org.kie.dmn.api.core.DMNModel;
+import org.kie.dmn.api.core.DMNRuntime;
+import org.kie.dmn.model.api.Definitions;
+import org.kie.dmn.model.api.NamedElement;
+import org.kie.dmn.core.internal.utils.DMNRuntimeBuilder;
+import org.kie.internal.io.ResourceFactory;
+
+/**
+ * JBang script that performs DMN files' XML (in string format) validation
+ * relying on KIE DMN Validator
+ * (https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation).
+ * The script can manage one or two (in case of imported model) DMN file paths.
+ * The XSD SCHEMA, DMN COMPLIANCE and DMN COMPILATION are validated.
+ */
+class DmnSemanticComparison extends DmnMarshallerBackendCompatibilityTesterScript {

Review Comment:
   I agree with you. Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1541469465


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",

Review Comment:
   Restored



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538681097


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   @tiagobento 
   About last comment, I get your point, but currently I see no alternatives, and TBH this string comparison is by itself a bad way to verify the behavior of this kind of code.
   We spent a lot of time setting up a testing strategy for code-generatino, backend side, and if you think about it this is more or less the same thing. We actually need something that is able to verify semantically the two objects (expected and retrieved), but currently there is not. Until then,  IMO the current proposal is an improvement, anyway, at least for the moment being.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1539216218


##########
packages/dmn-testing-models/pom.xml:
##########
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~ 
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~ 
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.      
+-->
+<project
+        xmlns="http://maven.apache.org/POM/4.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.kie.tools</groupId>
+    <artifactId>dmn-testing-models</artifactId>
+    <version>${revision}</version>
+    <packaging>jar</packaging>
+
+    <name>DMN Testing Models</name>
+    <description>Testing models for DMN editor</description>

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1539566981


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   Well, if we normalize the generated XML, and test for known discrepancies like the ones I shared above, I think we'll be fine. As for semantically verifying, we can always use the DOM. It's the most detailed semantic representation of XML documents, and it looks like there's a comparison function available. See https://developer.mozilla.org/en-US/docs/Web/API/Node/isEqualNode.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1571394800


##########
packages/dmn-testing-models/README.md:
##########
@@ -0,0 +1,20 @@
+## DMN testing models
+
+This package is meant to contain all the DMN models published inside [kie-dmn-test-resources](https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-test-resources) to make them available for testing purposes.
+
+Models are separated between < 1.5 version and 1.5 version; such classification is based on actual version-specific features, and not on the referenced tag itself.
+
+For future DMN versions there will be version specific folders.
+
+The original `org.kie:kie-dmn-test-resources` also contains _invalid_ models, but for the moment being we use only the valid ones to verify round-trip validation.
+
+### Usage
+
+The command `mvn clean generate-resources` downloads the jar and extract the models under `dist/`.
+
+To make them available for testing purpose:
+
+1. set the `KOGITO_RUNTIME_version` in the terminal (if different from the default one)
+2. `pnpm bootstrap` on the root directory
+3. cd dmn-testing-models
+4. `pnpm build:dev` or `pnpm build:prod` (they behave the same way - this executes `mvn clean generate-resources`)

Review Comment:
   Outdated.



##########
packages/dmn-testing-models/README.md:
##########
@@ -0,0 +1,20 @@
+## DMN testing models
+
+This package is meant to contain all the DMN models published inside [kie-dmn-test-resources](https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-test-resources) to make them available for testing purposes.
+
+Models are separated between < 1.5 version and 1.5 version; such classification is based on actual version-specific features, and not on the referenced tag itself.
+
+For future DMN versions there will be version specific folders.
+
+The original `org.kie:kie-dmn-test-resources` also contains _invalid_ models, but for the moment being we use only the valid ones to verify round-trip validation.
+
+### Usage
+
+The command `mvn clean generate-resources` downloads the jar and extract the models under `dist/`.

Review Comment:
   Outdated.



##########
packages/dmn-marshaller-backend-compatibility-tester/package.json:
##########
@@ -0,0 +1,34 @@
+{
+  "private": true,
+  "name": "@kie-tools/dmn-marshaller-backend-compatibility-tester",
+  "version": "0.0.0",
+  "description": "",
+  "license": "Apache-2.0",
+  "keywords": [],
+  "homepage": "https://github.com/apache/incubator-kie-tools",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/incubator-kie-tools.git"
+  },
+  "bugs": {
+    "url": "https://github.com/apache/incubator-kie-tools/issues"
+  },
+  "types": "./dist/index.d.ts",
+  "main": "dist/index.js",
+  "files": [
+    "dist",
+    "src"
+  ],
+  "scripts": {
+    "build:dev": "rimraf dist && tsc -p tsconfig.json && pnpm prefetch",
+    "build:prod": "pnpm build:dev",
+    "prefetch": "node dist/dependenciesFetch.js"
+  },
+  "devDependencies": {
+    "@jbangdev/jbang": "0.2.0",

Review Comment:
   Based on a previous conversation we had, I think this needs to be in the `dependencies` section, since it is required to run.



##########
packages/dmn-testing-models/pom.xml:
##########
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~ 
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~ 
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.      
+-->
+<project
+  xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
+>
+
+  <parent>
+    <groupId>org.kie</groupId>
+    <artifactId>kie-tools-maven-base</artifactId>
+    <version>${revision}</version>
+    <relativePath>./node_modules/@kie-tools/maven-base/pom.xml</relativePath>

Review Comment:
   👍



##########
packages/dmn-marshaller-backend-compatibility-tester/src/index.ts:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import * as path from "path";
+const buildEnv = require("../env");
+const jbang = require("@jbangdev/jbang");
+
+const parentScriptPath = path.join(__dirname, "..", "src", "DmnMarshallerBackendCompatibilityTesterScript.java");
+const dmnValidationScriptPath = path.join(__dirname, "..", "src", "DmnValidation.java");
+const dmnSemanticComparisonPath = path.join(__dirname, "..", "src", "DmnSemanticComparison.java");
+
+export function executeParentScript() {
+  executeScript(parentScriptPath);
+}
+
+export function checkDMNValidation(dmnFilePath: string) {
+  const command = "--command=no_imports";
+  const dmnFilePathCommand = "--dmnFilePath=" + dmnFilePath;
+  const importedDmnFilesPaths = "--importedDmnFilesPaths=";
+
+  executeScript(dmnValidationScriptPath, [command, dmnFilePathCommand]);
+}

Review Comment:
   ```suggestion
   export function checkDmnValidation(data: { dmnFilePath: string }) {
     const command = "--command=no_imports";
     const dmnFilePathCommand = "--dmnFilePath=" + data.dmnFilePath;
     const importedDmnFilesPaths = "--importedDmnFilesPaths=";
   
     executeScript(dmnValidationScriptPath, [command, dmnFilePathCommand]);
   }
   ```
   
   ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1574790154


##########
packages/dmn-marshaller/tests/dmnValidation.test.ts:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { fail } from "assert";
+import {
+  checkDmnValidation,
+  checkDmnValidationWithImports,
+} from "@kie-tools/dmn-marshaller-backend-compatibility-tester";
+
+/**
+ * This test suite validates the xml produced (parsed and built) by the marshaller relying on KIE DMN Validator
+ * (https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation).
+ * A JBang script is used to actually call the KIE DMN Validator Java code.
+ */
+
+const dmnTestingModelsPath = path.dirname(require.resolve("@kie-tools/dmn-testing-models/package.json"));
+
+const dmnTestingModels = [
+  "dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/NegationOfDurationEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "dist/valid_models/DMNv1_x/multiple/Financial.dmn",
+  "dist/valid_models/DMNv1_x/multiple/Imported_Traffic_Violation.dmn",

Review Comment:
   Yes, even if dmnValidation and dmnSemanticComparison are currently declaring the same arrays, I would prefer to keep them well separated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1555273489


##########
packages/dmn-marshaller/tests/jbang/dmnValidation.java:
##########
@@ -27,16 +26,16 @@ public static void main(String... args) throws Exception {
 
     public static int validate(String... args) throws Exception {
         if (args.length > 2 || args.length <= 0) {
-            throw new IllegalArgumentException("Validation requires 1 or 2 xmls");
+            throw new IllegalArgumentException("Validation requires 1 or 2 DMN file paths");

Review Comment:
   @yesamer 
   Please keep in mind that there could be more then two models in this scenario.
   Please remove the `args.length > 2 ` constraint, and adapt the exception message accordingly.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1557302724


##########
packages/dmn-marshaller/tests/jbang/jbangManager.ts:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import * as path from "path";
+const jbang = require("@jbangdev/jbang");
+const buildEnv = require("../../env");
+
+export function executeJBangScript(scriptPath: string, ...args: string[]) {
+  /* Windows requires double quotes to wrap the argument, while in POSIX it must be wrapped by single quotes */
+  const isWindowsPath = path.sep !== "/";
+  const quoteChar = isWindowsPath ? '"' : "'";
+  jbang.exec("--java 17", "properties@jbangdev", "java.version");
+  jbang.exec(
+    "-Dkogito-runtime.version=" + buildEnv.env.kogitoRuntime.version,

Review Comment:
   @jomarko No, that property name is used in the jBang script (`dmnValidation.java`)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento merged PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [incubator-kie-issues#1043] Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537706898


##########
packages/dmn-testing-models/env/index.js:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//const { getOrDefault, varsWithName, composeEnv } = require("@kie-tools-scripts/build-env");

Review Comment:
   Thanks for spotting this ! 👍 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [incubator-kie-issues#1043] Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537757951


##########
packages/dmn-marshaller/tests-data--manual/other/decisionAndInputWithAddition.dmn:
##########
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>

Review Comment:
   Thank you, yes, then keep this file as it is currently



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537783207


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];

Review Comment:
   In order not make packages dependent on the directory structure of the monorepo, for these cases we use `require.resolve("@kie-tools/dmn-testing-models")`, using the package name, instead of the package directory. The command above is like an import, but for a directory inside a package. You can use `path.join` then to concatenate the result of `require.resolve` with the path string you're pointing to. Keep in mind that we need to support these tests on Windows as well, if I'm not mistaken.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537879605


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];

Review Comment:
   (I was sure to have done something extemely naive, thanks for suggestion)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537910937


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   > Several comments here:
   > 
   > 
   > Using an array for `fileSource` and `fileExpected` is not the way to go here. I would inline the paths, to be honest.
   > 
   
   Could you provide an example ? It is not clear to me (is that already used somewhere else ?)
   
   > 
   > Having one `describe` for each `test` looks weird too. I would do one describe like this:
   > 
   > `describe("build always produces elements in the same order"`
   > 
   > and two tests like this:
   > 
   > `test("after adding elements")` `test("after reading denormalized file")`
   > 
   
   Fine
   
   > 
   > Replacing blank spaces with an empty string is tempering with the tests. My suggestion is that we match the files char by char, without exceptions.
   
   The `toStrictEqual` method fails here, because the generated xml has different formatting/white space then the original one.
   One of the caveat of this test is to be sure that the generated  xml is absolutely identical to the original one as it is: if the "litmus test" xml is somehow modified by the very code that is under test, then the result of the test could be "invalid".
   e.g.
   
   ```javascript
   1 const xml_original = fs.readFileSync(fullPathOfFile, "utf-8");
   2 const { parser, builder } = getMarshaller(xml_original, { upgradeTo: "latest" });
   3 const json = parser.parse();
   4 const xml_firstPass = builder.build(json);
   5 const xml_secondPass = builder.build(getMarshaller(xml_firstPass, { upgradeTo: "latest" }).parser.parse());
   6 expect(xml_firstPass).toStrictEqual(xml_secondPass);
   ```
   
   1. we are testing the "marshaller" (the parser and the build const)
   2. the string "xml_firstPass"  (line 4)  is a "product" of the marshaller, created from the original string
   3. the string "xml_secondPass"  (line 5)  is another "product" of the marshaller, created from the  "xml_firstPass" string
   4. at line 6, the test verify if two products of the marshaller are exactly the same
   5. in that case the `toStrictEqual` succeed because both strings have been generated by the marshaller, but at the same time it does not guarantee that the marshaller itself does not introduce/modify/whatever something wrong in both of them
   6. that's why I wanted to test the raw, original xml with the one created by the marshaller, and only way to do that comparison is to strip out whitespaces.
   If there is a nicer command, fine for me, but what it is important IMO is the logic and princiuple of the test itself.
   Does this make sense ? Am I clear ?
   
   
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [incubator-kie-issues#1043] Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537645677


##########
packages/dmn-testing-models/README.md:
##########
@@ -0,0 +1,10 @@
+## DMN testing models
+
+This package is meant to contain all the DMN models published inside `org.kie:kie-dmn-test-resources` to make them available for testing purposes.

Review Comment:
   Could we please add also a link for github repository? https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-test-resources



##########
packages/dmn-testing-models/env/index.js:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//const { getOrDefault, varsWithName, composeEnv } = require("@kie-tools-scripts/build-env");

Review Comment:
   we can remove this line probably



##########
packages/dmn-marshaller/tests-data--manual/other/decisionAndInputWithAddition.dmn:
##########
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>

Review Comment:
   Maybe we should move also this model under https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models/DMNv1_5 ?



##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];
 
 describe("idempotency", () => {
   for (const file of files) {
-    test(path.basename(file), () => {
-      const xml_original = fs.readFileSync(path.join(__dirname, file), "utf-8");
-
-      const { parser, builder } = getMarshaller(xml_original, { upgradeTo: "latest" });
-      const json = parser.parse();
-
-      const xml_firstPass = builder.build(json);
-      const xml_secondPass = builder.build(getMarshaller(xml_firstPass, { upgradeTo: "latest" }).parser.parse());
+    testFile(path.join(__dirname, file));
+  }
+});
 
-      expect(xml_firstPass).toStrictEqual(xml_secondPass);
-    });
+describe("idempotency_all", () => {
+  for (const models_paths of testing_models_paths) {
+    const parent_path = path.join(__dirname, models_paths);
+    testDirectory(parent_path);
   }

Review Comment:
   sorry, it may be silly question, I am not expert of reading directories in typescript, I also believe this does the expected work, I am just concerned if in the future for some reason we move the directory or models of the directory to a new location, this will silently still pass reading zero files?
   
   maybe some assertion of how many files were tested would make slightly more explicit, what models do we test? I do not know, or in different test suites I saw a hard-coded list of files intended to be tested.



##########
packages/dmn-testing-models/README.md:
##########
@@ -0,0 +1,10 @@
+## DMN testing models
+
+This package is meant to contain all the DMN models published inside `org.kie:kie-dmn-test-resources` to make them available for testing purposes.
+
+Simply issue `mvn clean generated-resources` to download the jar and extract the models under `target/generated-resources/valid_models`.

Review Comment:
   ```suggestion
   Simply issue `mvn clean generate-resources` to download the jar and extract the models under `target/generated-resources/valid_models`.
   ```



##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",

Review Comment:
   shouldn't this PR physically remove these models? are they still used elsewhere? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538681097


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   @tiagobento 
   About last point, currently I see no alternatives, and TBH this string comparison is by itself a bad way to verify the behavior of this kind of code.
   We spent a lot of time setting up a testing strategy for code-generatino, backend side, and if you think about it this is more or less the same thing. We actually need something that is able to verify semantically the two objects (expected and retrieved), but currently there is not. Until then,  IMO the current proposal is an improvement, anyway, at least for the moment being.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1539489224


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];
 
 describe("idempotency", () => {
   for (const file of files) {
-    test(path.basename(file), () => {
-      const xml_original = fs.readFileSync(path.join(__dirname, file), "utf-8");
-
-      const { parser, builder } = getMarshaller(xml_original, { upgradeTo: "latest" });
-      const json = parser.parse();
-
-      const xml_firstPass = builder.build(json);
-      const xml_secondPass = builder.build(getMarshaller(xml_firstPass, { upgradeTo: "latest" }).parser.parse());
+    testFile(path.join(__dirname, file));
+  }
+});
 
-      expect(xml_firstPass).toStrictEqual(xml_secondPass);
-    });
+describe("idempotency_all", () => {
+  for (const models_paths of testing_models_paths) {
+    const parent_path = path.join(__dirname, models_paths);
+    testDirectory(parent_path);
   }
 });
+
+function testDirectory(fullPathOfModels: string) {
+  fs.readdirSync(fullPathOfModels).forEach((file) => {
+    const child_path = path.join(fullPathOfModels, file);
+    const stats = fs.statSync(child_path);
+    if (stats.isFile()) {
+      testFile(child_path);
+    } else {
+      testDirectory(child_path);
+    }
+  });
+}
+
+function testFile(fullPathOfFile: string) {

Review Comment:
   Done (I hope correctly)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1554969015


##########
packages/dmn-marshaller/tests/jbang/jbangManager.ts:
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import * as path from "path";
+const jbang = require("@jbangdev/jbang");
+
+export function executeJbangScript(scriptPath: string, ...args: string[]) {
+  const quoteChar = path.sep === "/" ? "'" : '"';
+  jbang.exec("--java 17", "properties@jbangdev", "java.version");
+  jbang.exec(scriptPath, args.map((arg) => quoteChar + arg.trim().replace("\t", "") + quoteChar).join(" "));

Review Comment:
   ## Incomplete string escaping or encoding
   
   This replaces only the first occurrence of "\t".
   
   [Show more details](https://github.com/apache/incubator-kie-tools/security/code-scanning/676)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1555082094


##########
packages/dmn-marshaller/tests/jbang/jbangManager.ts:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import * as path from "path";
+const jbang = require("@jbangdev/jbang");
+
+export function executeJbangScript(scriptPath: string, ...args: string[]) {
+  /* Windows requires a double quotes to wrap the argument and a single line argument, while POSIX can be multiline and wrapped by quotes */
+  const isWindowsPath = path.sep !== "/";
+  const quoteChar = isWindowsPath ? '"' : "'";
+  jbang.exec("--java 17", "properties@jbangdev", "java.version");
+  jbang.exec(
+    scriptPath,
+    args
+      .map(
+        (arg) =>
+          quoteChar +
+          (isWindowsPath //.replace(/>(\n|\t|\s/)*</g, "><")
+            ? arg
+            : arg
+                .trim()
+                .replace(/\n|\t|\s/g, " ")
+                .replace(/\s+/g, " ")
+                .replace(/"/g, '\\"')) +

Review Comment:
   ## Incomplete string escaping or encoding
   
   This does not escape backslash characters in the input.
   
   [Show more details](https://github.com/apache/incubator-kie-tools/security/code-scanning/678)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1550352355


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   I'm trying to set in place the steps described by @tiagobento  [here](https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538040788) and I finally found a good configuration for Prettier to solve the formatting issue found by @gitgabrio  (eg. trailing whitespaces).
   After that, the configuration revealed what Tiago already anticipated [here](https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538044196). Because of the following cases, we don't have a 1:1 copy:
   
   **kie namespace**: If already present in the original xml file, the one generated by our parser replaces it with a new version. If is missing, the parser adds it.
   <img width="381" alt="Screenshot 2024-04-03 at 16 35 01" src="https://github.com/apache/incubator-kie-tools/assets/16005046/76c04eb6-eda8-4546-a7f6-dab71563d2d1">
   <img width="370" alt="Screenshot 2024-04-03 at 16 35 15" src="https://github.com/apache/incubator-kie-tools/assets/16005046/7e2aaf85-1051-488b-8bca-380ce65a8a1b">
   
   **xml prolog**: The parser automatically adds it, if not present in the original file
   <img width="299" alt="Screenshot 2024-04-03 at 16 44 28" src="https://github.com/apache/incubator-kie-tools/assets/16005046/1b02f2d3-4c01-4035-b0a0-04b1c825903a">
   
   **Special characters** Some special characters are converted (eg. `"` is converted to `&quote`)
   <img width="552" alt="Screenshot 2024-04-03 at 16 48 30" src="https://github.com/apache/incubator-kie-tools/assets/16005046/7c6c9e88-9e3b-40de-9584-9b6469f1807b">
   
   Self-closing tags case seems correctly managed with Prettier.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#issuecomment-2049177404

   @gitgabrio Thank you!
   I intentionally ignored the `picocli` part so far, my first goal is to make the test work and then I'll improve that part.
   
   About the class name, I followed the same convention I saw in the [JBangdemo](https://github.com/jbangdev/jbang-npm/tree/main/demo). Honestly, I don't know if that is a JBang convention, a mistake, or just a way to say that is "script". I don't have any strong preference for that, if In our group we managed all the JBang scripts in that way, no problem to use Uppercase there.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570399399


##########
packages/dmn-testing-models/package.json:
##########
@@ -0,0 +1,40 @@
+{
+  "private": true,
+  "name": "@kie-tools/dmn-testing-models",
+  "version": "0.0.0",
+  "description": "",
+  "license": "Apache-2.0",
+  "homepage": "https://github.com/apache/incubator-kie-tools",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/incubator-kie-tools.git"
+  },
+  "bugs": {
+    "url": "https://github.com/apache/incubator-kie-tools/issues"
+  },
+  "main": "dist/index.js",
+  "files": [
+    "dist"
+  ],
+  "scripts": {
+    "build:dev": "rimraf dist && copyfiles index.js dist/ && run-script-os",
+    "build:dev:linux:darwin": "mvn clean generate-resources",
+    "build:dev:win32": "pnpm powershell \"mvn clean generate-resources\"",
+    "build:prod": "pnpm build:dev",

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1574770014


##########
packages/dmn-marshaller-backend-compatibility-tester/src/DmnSemanticComparison.java:
##########
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+///usr/bin/env jbang "$0" "$@" ; exit $?
+//SOURCES ./DmnMarshallerBackendCompatibilityTesterScript.java
+/* Please do not declare new dependencies here, but in the above Parent class to preserve 
+ *  the dependencies fetching mechanism */
+
+package jbang;
+
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+import org.kie.api.io.Resource;
+import org.kie.dmn.api.core.DMNContext;
+import org.kie.dmn.api.core.DMNModel;
+import org.kie.dmn.api.core.DMNRuntime;
+import org.kie.dmn.model.api.Definitions;
+import org.kie.dmn.model.api.NamedElement;
+import org.kie.dmn.core.internal.utils.DMNRuntimeBuilder;
+import org.kie.internal.io.ResourceFactory;
+
+/**
+ * JBang script that performs DMN files' XML (in string format) validation
+ * relying on KIE DMN Validator
+ * (https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation).
+ * The script can manage one or two (in case of imported model) DMN file paths.
+ * The XSD SCHEMA, DMN COMPLIANCE and DMN COMPILATION are validated.
+ */
+class DmnSemanticComparison extends DmnMarshallerBackendCompatibilityTesterScript {

Review Comment:
   My comment to this jbang class is we mix a terminology. In class `Option` we speak about `generated` files while in the method implementation and logs we speak about `parsed` files, I think we could unify the naming. What is your opinion?



##########
packages/dmn-marshaller/tests/dmnValidation.test.ts:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { fail } from "assert";
+import {
+  checkDmnValidation,
+  checkDmnValidationWithImports,
+} from "@kie-tools/dmn-marshaller-backend-compatibility-tester";
+
+/**
+ * This test suite validates the xml produced (parsed and built) by the marshaller relying on KIE DMN Validator
+ * (https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation).
+ * A JBang script is used to actually call the KIE DMN Validator Java code.
+ */
+
+const dmnTestingModelsPath = path.dirname(require.resolve("@kie-tools/dmn-testing-models/package.json"));
+
+const dmnTestingModels = [
+  "dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/NegationOfDurationEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "dist/valid_models/DMNv1_x/multiple/Financial.dmn",
+  "dist/valid_models/DMNv1_x/multiple/Imported_Traffic_Violation.dmn",

Review Comment:
   is it intentional we introduce the same constants as in the file above?



##########
packages/dmn-marshaller/tests/dmnSemanticComparison.test.ts:
##########
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { fail } from "assert";
+import {
+  checkDmnSemanticComparison,
+  checkDmnSemanticComparisonWithImports,
+} from "@kie-tools/dmn-marshaller-backend-compatibility-tester";
+
+/**
+ * This test suite compares the xml generated (parsed and built) by the dmn-parser with the original xml.
+ * The original xml and the generated one are passed and compered to the KIE DMN Core backend API.
+ * A JBang script is used to actually call the KIE DMN Core backend API.
+ */
+
+const dmnTestingModelsPath = path.dirname(require.resolve("@kie-tools/dmn-testing-models/package.json"));
+
+const dmnTestingModels = [
+  "dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/NegationOfDurationEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "dist/valid_models/DMNv1_x/multiple/Financial.dmn",
+  "dist/valid_models/DMNv1_x/multiple/Imported_Traffic_Violation.dmn",
+  "dist/valid_models/DMNv1_x/multiple/stdlib.dmn",
+  "dist/valid_models/DMNv1_x/allTypes.dmn",
+  "dist/valid_models/DMNv1_x/dtevent.dmn",
+  "dist/valid_models/DMNv1_x/habitability.dmn",
+  "dist/valid_models/DMNv1_x/loan.dmn",
+  "dist/valid_models/DMNv1_x/LoanEligibility.dmn",
+  "dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "dist/valid_models/DMNv1_x/Prequalification.dmn",
+  "dist/valid_models/DMNv1_x/testWithExtensionElements.dmn",
+  "dist/valid_models/DMNv1_x/Traffic Violation Simple.dmn",
+  "dist/valid_models/DMNv1_x/Traffic Violation.dmn",

Review Comment:
   is it intentional we do not have all content from https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-test-resources/src/test/resources/valid_models ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570131205


##########
packages/dmn-testing-models/README.md:
##########
@@ -0,0 +1,21 @@
+## DMN testing models
+
+This package is meant to contain all the DMN models published inside [kie-dmn-test-resources](https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-test-resources) to make them available for testing purposes.
+
+Models are separated between < 1.5 version and 1.5 version; such classification is based on actual version-specific features, and not on the referenced tag itself.
+
+For future DMN versions there will be version specific folders.
+
+The original `org.kie:kie-dmn-test-resources` also contains _invalid_ models, but for the moment being we use only the valid ones to verify round-trip validation.
+
+### Usage
+
+The command `mvn clean generate-resources` downloads the jar and extract the models under `dist/`.
+
+To make them available for testing purpose:
+
+1. set the `KOGITO_RUNTIME_version` in the terminal (if different from the default one)
+2. `pnpm bootstrap` on the root directory
+3. cd dmn-testing-models
+4. `pnpm install` (this creates the required mvn configuration)

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [incubator-kie-issues#1043] Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537762012


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];
 
 describe("idempotency", () => {
   for (const file of files) {
-    test(path.basename(file), () => {
-      const xml_original = fs.readFileSync(path.join(__dirname, file), "utf-8");
-
-      const { parser, builder } = getMarshaller(xml_original, { upgradeTo: "latest" });
-      const json = parser.parse();
-
-      const xml_firstPass = builder.build(json);
-      const xml_secondPass = builder.build(getMarshaller(xml_firstPass, { upgradeTo: "latest" }).parser.parse());
+    testFile(path.join(__dirname, file));
+  }
+});
 
-      expect(xml_firstPass).toStrictEqual(xml_secondPass);
-    });
+describe("idempotency_all", () => {
+  for (const models_paths of testing_models_paths) {
+    const parent_path = path.join(__dirname, models_paths);
+    testDirectory(parent_path);
   }

Review Comment:
   Yes, it sounds you are confident this is robust enough, so I think we can keep as you proposed. I agree that people contributing and doing reviews will probably spot if some new model is not tested.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1539210391


##########
packages/dmn-testing-models/env/index.js:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//const { getOrDefault, varsWithName, composeEnv } = require("@kie-tools-scripts/build-env");
+const { varsWithName, composeEnv } = require("@kie-tools-scripts/build-env");
+
+module.exports = composeEnv([require("@kie-tools/root-env/env")], {
+  vars: varsWithName({}),
+  get env() {
+    return {};
+  },
+});

Review Comment:
   Done



##########
packages/dmn-testing-models/install.js:
##########
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const buildEnv = require("./env");
+const { setup } = require("@kie-tools/maven-config-setup-helper");
+
+setup(`
+    -Dversion.org.kie.kogito=${buildEnv.env.kogitoRuntime.version}

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#issuecomment-2056360282

   @gitgabrio @jomarko @tiagobento Ready for another review round. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538674605


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",

Review Comment:
   @tiagobento 
   The important thing is the quality/kind of tests, and not the number of them.
   As it currently is, the idempotency test has a very focused meaning, which does not change if executed with 10 or 100 files that basically has the same features.
   Anyway, if you want them back, no prblm to me 👍 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537888188


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];
 
 describe("idempotency", () => {
   for (const file of files) {
-    test(path.basename(file), () => {
-      const xml_original = fs.readFileSync(path.join(__dirname, file), "utf-8");
-
-      const { parser, builder } = getMarshaller(xml_original, { upgradeTo: "latest" });
-      const json = parser.parse();
-
-      const xml_firstPass = builder.build(json);
-      const xml_secondPass = builder.build(getMarshaller(xml_firstPass, { upgradeTo: "latest" }).parser.parse());
+    testFile(path.join(__dirname, file));
+  }
+});

Review Comment:
   Not sure to understand the question



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537910937


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   > Several comments here:
   > 
   > 
   > Using an array for `fileSource` and `fileExpected` is not the way to go here. I would inline the paths, to be honest.
   > 
   
   Could you provide an example ? It is not clear to me (is that already used somewhere else ?)
   
   > 
   > Having one `describe` for each `test` looks weird too. I would do one describe like this:
   > 
   > `describe("build always produces elements in the same order"`
   > 
   > and two tests like this:
   > 
   > `test("after adding elements")` `test("after reading denormalized file")`
   > 
   
   Fine
   
   > 
   > Replacing blank spaces with an empty string is tempering with the tests. My suggestion is that we match the files char by char, without exceptions.
   
   The `toStrictEqual` method fails here, because the generated xml has different formatting/white space then the original one.
   One of the caveat of this test is to be sure that the generated  xml is absolutely identical to the original one as it is: if the "litmus test" xml is somehow modified by the very code that is under test, then the result of the test could be "invalid".
   e.g.
   
   ```javascript
   1 const xml_original = fs.readFileSync(fullPathOfFile, "utf-8");
   2 const { parser, builder } = getMarshaller(xml_original, { upgradeTo: "latest" });
   3 const json = parser.parse();
   4 const xml_firstPass = builder.build(json);
   5 const xml_secondPass = builder.build(getMarshaller(xml_firstPass, { upgradeTo: "latest" }).parser.parse());
   6 expect(xml_firstPass).toStrictEqual(xml_secondPass);
   ```
   
   1. we are testing the "marshaller" (IIUC the parser and the build const)
   2. the string "xml_firstPass"  (line 4)  is a "product" of the marshaller, created from the original string
   3. the string "xml_secondPass"  (line 5)  is another "product" of the marshaller, created from the  "xml_firstPass" string
   4. at line 6, the test verify if two products of the marshaller are exactly the same
   5. in that case the `toStrictEqual` succeed because both strings have been generated by the marshaller, but at the same time it does not guarantee that the marshaller itself does not introduce/modify/whatever something wrong in both of them
   6. that's why I wanted to test the raw, original xml with the one created by the marshaller, and only way to do that comparison is to strip out whitespaces.
   If there is a nicer command, fine for me, but what it is important IMO is the logic and princiuple of the test itself.
   Does this make sense ? Am I clear ?
   
   
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538014445


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];
 
 describe("idempotency", () => {
   for (const file of files) {
-    test(path.basename(file), () => {
-      const xml_original = fs.readFileSync(path.join(__dirname, file), "utf-8");
-
-      const { parser, builder } = getMarshaller(xml_original, { upgradeTo: "latest" });
-      const json = parser.parse();
-
-      const xml_firstPass = builder.build(json);
-      const xml_secondPass = builder.build(getMarshaller(xml_firstPass, { upgradeTo: "latest" }).parser.parse());
+    testFile(path.join(__dirname, file));
+  }
+});

Review Comment:
   This comment is at the wrong place, let me go to the correct place.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1550352355


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   I'm trying to set in place the steps described by @tiagobento  [here](https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538040788) and I finally found a good configuration for Prettier to solve the formatting issue found by @gitgabrio  (eg. trailing whitespaces).
   After that, the configuration revealed what Tiago already anticipated [here](https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538044196). Because of the following cases, we don't have a 1:1 copy:
   
   **kie namespace**: If already present in the original xml file, the one generated by our parser replaces it with a new version. If is missing, the parser adds it.
   <img width="381" alt="Screenshot 2024-04-03 at 16 35 01" src="https://github.com/apache/incubator-kie-tools/assets/16005046/76c04eb6-eda8-4546-a7f6-dab71563d2d1">
   <img width="370" alt="Screenshot 2024-04-03 at 16 35 15" src="https://github.com/apache/incubator-kie-tools/assets/16005046/7e2aaf85-1051-488b-8bca-380ce65a8a1b">
   
   **xml prolog**: The parser automatically adds it, if not present in the original file
   <img width="299" alt="Screenshot 2024-04-03 at 16 44 28" src="https://github.com/apache/incubator-kie-tools/assets/16005046/1b02f2d3-4c01-4035-b0a0-04b1c825903a">
   
   **Special characters** Some special characters are converted (eg. `"` is converted to `&quote`)
   <img width="552" alt="Screenshot 2024-04-03 at 16 48 30" src="https://github.com/apache/incubator-kie-tools/assets/16005046/7c6c9e88-9e3b-40de-9584-9b6469f1807b">
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1550352355


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   I'm trying to set in place the steps described by Tiago [here](https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538040788) and I finally found a good configuration for Prettier to solve the formatting issue found by Gabriele (eg. trailing whitespaces).
   After that, the configuration revealed what Tiago already anticipated [here](https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538044196). Because of the following cases, we don't have a 1:1 copy:
   
   **kie namespace**: If already present in the original xml file, the one generated by our parser replaces it with a new version. If is missing, the parser adds it.
   <img width="381" alt="Screenshot 2024-04-03 at 16 35 01" src="https://github.com/apache/incubator-kie-tools/assets/16005046/76c04eb6-eda8-4546-a7f6-dab71563d2d1">
   <img width="370" alt="Screenshot 2024-04-03 at 16 35 15" src="https://github.com/apache/incubator-kie-tools/assets/16005046/7e2aaf85-1051-488b-8bca-380ce65a8a1b">
   
   **xml prolog**: The parser automatically adds it, if not present in the original file
   <img width="299" alt="Screenshot 2024-04-03 at 16 44 28" src="https://github.com/apache/incubator-kie-tools/assets/16005046/1b02f2d3-4c01-4035-b0a0-04b1c825903a">
   
   **Special characters** Some special characters are converted (eg. `"` is converted to `&quote`)
   <img width="552" alt="Screenshot 2024-04-03 at 16 48 30" src="https://github.com/apache/incubator-kie-tools/assets/16005046/7c6c9e88-9e3b-40de-9584-9b6469f1807b">
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570129537


##########
packages/dmn-marshaller/tests/dmnValidation.test.ts:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { fail } from "assert";
+import {
+  DmnBackendCompatibilityScript,
+  executeJBangScript,
+} from "@kie-tools/dmn-marshaller-backend-compatibility-tester";
+
+/**
+ * This test suite validates the xml produced (parsed and built) by the marshaller relying on KIE DMN Validator
+ * (https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation).
+ * A JBang script is used to actually call the KIE DMN Validator Java code.
+ */
+
+const dmnTestingModelsPath = require.resolve("@kie-tools/dmn-testing-models");
+
+const dmnTestingModels = [
+  "../valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../valid_models/DMNv1_5/NegationOfDurationEvaluate.dmn",
+  "../valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../valid_models/DMNv1_x/multiple/Financial.dmn",
+  "../valid_models/DMNv1_x/multiple/Imported_Traffic_Violation.dmn",
+  "../valid_models/DMNv1_x/multiple/stdlib.dmn",
+  "../valid_models/DMNv1_x/allTypes.dmn",
+  "../valid_models/DMNv1_x/dtevent.dmn",
+  "../valid_models/DMNv1_x/habitability.dmn",
+  "../valid_models/DMNv1_x/loan.dmn",
+  "../valid_models/DMNv1_x/LoanEligibility.dmn",
+  "../valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../valid_models/DMNv1_x/Prequalification.dmn",
+  "../valid_models/DMNv1_x/testWithExtensionElements.dmn",
+  "../valid_models/DMNv1_x/Traffic Violation Simple.dmn",
+  "../valid_models/DMNv1_x/Traffic Violation.dmn",
+];
+
+const dmnTestingImportedModels = [
+  {
+    imported: "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+    importer: "../valid_models/DMNv1_5/Importing_EmptyNamed_Model_With_Href_Namespace.dmn",
+  },
+  {
+    imported: "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+    importer: "../valid_models/DMNv1_5/Importing_EmptyNamed_Model_Without_Href_Namespace.dmn",
+  },
+  {
+    imported: "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+    importer: "../valid_models/DMNv1_5/Importing_Named_Model.dmn",
+  },
+  {
+    imported: "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+    importer: "../valid_models/DMNv1_5/Importing_OverridingEmptyNamed_Model.dmn",
+  },
+  {
+    imported: "../valid_models/DMNv1_x/multiple/Imported_Traffic_Violation.dmn",
+    importer: "../valid_models/DMNv1_x/multiple/Traffic Violation With Import.dmn",
+  },
+];
+export const dmnValidationGeneratedFilesDirectory = path.join(__dirname, "../dist-tests/dmnValidation-generated-files");
+
+describe("DMN Validation", () => {
+  beforeAll(() => {
+    if (fs.existsSync(dmnValidationGeneratedFilesDirectory)) {
+      fs.rmSync(dmnValidationGeneratedFilesDirectory, { recursive: true });
+    }
+    fs.mkdirSync(dmnValidationGeneratedFilesDirectory, { recursive: true });
+  });
+
+  for (const file of dmnTestingModels) {
+    testFile(path.join(dmnTestingModelsPath, file));
+  }
+  for (const file of dmnTestingImportedModels) {
+    file.imported = path.join(dmnTestingModelsPath, file.imported);
+    file.importer = path.join(dmnTestingModelsPath, file.importer);
+    testImportedFile(file);
+  }
+});
+
+function testFile(normalizedFsPathRelativeToTheFile: string) {
+  test(
+    "DMN Validation: " +
+      normalizedFsPathRelativeToTheFile.substring(normalizedFsPathRelativeToTheFile.lastIndexOf(path.sep) + 1),
+    () => {
+      const generatedXMLFilePath = parseXMLAndWriteInFile(normalizedFsPathRelativeToTheFile);
+
+      try {
+        executeJBangScript(
+          DmnBackendCompatibilityScript.DMN_VALIDATION,
+          "--command=no_imports",
+          "--dmnFilePath=" + generatedXMLFilePath
+        );
+      } catch (error) {
+        fail(error.cause);
+      }
+    }
+  );
+}
+
+function testImportedFile(normalizedFsPathRelativeToTheFiles: { imported: string; importer: string }) {
+  test(
+    "DMN Validation: " +
+      normalizedFsPathRelativeToTheFiles.importer.substring(
+        normalizedFsPathRelativeToTheFiles.importer.lastIndexOf(path.sep) + 1
+      ),
+    () => {
+      const importedGeneratedXMLFilePath = parseXMLAndWriteInFile(normalizedFsPathRelativeToTheFiles.imported);
+      const importerGeneratedXMLFilePath = parseXMLAndWriteInFile(normalizedFsPathRelativeToTheFiles.importer);
+
+      try {
+        executeJBangScript(
+          DmnBackendCompatibilityScript.DMN_VALIDATION,
+          "--command=with_imports",
+          "--dmnFilePath=" + importedGeneratedXMLFilePath,
+          "--importedDmnFilesPaths=" + importerGeneratedXMLFilePath
+        );
+      } catch (error) {
+        fail(error.cause);
+      }
+    }
+  );
+}
+
+function parseXMLAndWriteInFile(normalizedFsPathRelativeToTheFile: string): string {

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1572088400


##########
packages/dmn-marshaller-backend-compatibility-tester/package.json:
##########
@@ -0,0 +1,34 @@
+{
+  "private": true,
+  "name": "@kie-tools/dmn-marshaller-backend-compatibility-tester",
+  "version": "0.0.0",
+  "description": "",
+  "license": "Apache-2.0",
+  "keywords": [],
+  "homepage": "https://github.com/apache/incubator-kie-tools",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/incubator-kie-tools.git"
+  },
+  "bugs": {
+    "url": "https://github.com/apache/incubator-kie-tools/issues"
+  },
+  "types": "./dist/index.d.ts",
+  "main": "dist/index.js",
+  "files": [
+    "dist",
+    "src"
+  ],
+  "scripts": {
+    "build:dev": "rimraf dist && tsc -p tsconfig.json && pnpm prefetch",
+    "build:prod": "pnpm build:dev",
+    "prefetch": "node dist/dependenciesFetch.js"
+  },
+  "devDependencies": {
+    "@jbangdev/jbang": "0.2.0",

Review Comment:
   Done



##########
packages/dmn-marshaller-backend-compatibility-tester/src/index.ts:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import * as path from "path";
+const buildEnv = require("../env");
+const jbang = require("@jbangdev/jbang");
+
+const parentScriptPath = path.join(__dirname, "..", "src", "DmnMarshallerBackendCompatibilityTesterScript.java");
+const dmnValidationScriptPath = path.join(__dirname, "..", "src", "DmnValidation.java");
+const dmnSemanticComparisonPath = path.join(__dirname, "..", "src", "DmnSemanticComparison.java");
+
+export function executeParentScript() {
+  executeScript(parentScriptPath);
+}
+
+export function checkDMNValidation(dmnFilePath: string) {
+  const command = "--command=no_imports";
+  const dmnFilePathCommand = "--dmnFilePath=" + dmnFilePath;
+  const importedDmnFilesPaths = "--importedDmnFilesPaths=";
+
+  executeScript(dmnValidationScriptPath, [command, dmnFilePathCommand]);
+}

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1569602436


##########
packages/dmn-testing-models/package.json:
##########
@@ -0,0 +1,40 @@
+{
+  "private": true,
+  "name": "@kie-tools/dmn-testing-models",
+  "version": "0.0.0",
+  "description": "",
+  "license": "Apache-2.0",
+  "homepage": "https://github.com/apache/incubator-kie-tools",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/incubator-kie-tools.git"
+  },
+  "bugs": {
+    "url": "https://github.com/apache/incubator-kie-tools/issues"
+  },
+  "main": "dist/index.js",
+  "files": [
+    "dist"
+  ],
+  "scripts": {
+    "build:dev": "rimraf dist && copyfiles index.js dist/ && run-script-os",
+    "build:dev:linux:darwin": "mvn clean generate-resources",
+    "build:dev:win32": "pnpm powershell \"mvn clean generate-resources\"",
+    "build:prod": "pnpm build:dev",

Review Comment:
   This package, albeit not a proper Maven module producing a JAR and everything, is still a Maven package. If any other Maven package decides to depend on it as a Maven dependency, not installing it will make the build fail. You can simply change this to `mvn clean install` (or `mvn clean verify`!) to solve this problem.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#issuecomment-2019949457

   @yesamer Just pushed last modifications.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [incubator-kie-issues#1043] Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#issuecomment-2018242674

   @gitgabrio please fix the pom.xml formatting, see the logs:
   ```
   > kie-tools-root@0.0.0 format:check /home/runner/work/incubator-kie-tools/incubator-kie-tools
   > prettier --check . '**/*.xml'
   
   Checking formatting...
   [warn] packages/dmn-testing-models/pom.xml
   [warn] Code style issues found in the above file. Forgot to run Prettier?
    ELIFECYCLE  Command failed with exit code 1.
    ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1539694220


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];

Review Comment:
   Right, so the entire `src` folder is not necessary. If you remove the `main` property from the `package.json` it might work. If that doesn't work, I would leave an empty index.js somewhere so `main` can point to this file. Doesn't have to be inside `src`, can be at the root of the package.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1539679359


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",

Review Comment:
   I agree, but some files I put there have some specific behavior that was being tested before, and the new files may not reproduce those behaviors. I would prefer to keep them for the time being.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#issuecomment-2024513348

   the build fails seems to be related to the changes in this PR, please let us know once  the PR is ready for a re-review
   
   ```
   Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.6.1:unpack (unpack) on project dmn-testing-models: Unable to find/resolve artifact. The following artifacts could not be resolved: org.kie:kie-dmn-test-resources:jar:tests:999-20240218-SNAPSHOT (absent): Could not find artifact org.kie:kie-dmn-test-resources:jar:tests:999-20240218-SNAPSHOT in apache-public-repository-group 
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1557300987


##########
packages/dmn-marshaller/tests/jbang/dmnValidation.java:
##########


Review Comment:
   @jomarko dmnSemanticComparision.java is still a WIP, that will compare the semantic of two different XML files



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1555273489


##########
packages/dmn-marshaller/tests/jbang/dmnValidation.java:
##########
@@ -27,16 +26,16 @@ public static void main(String... args) throws Exception {
 
     public static int validate(String... args) throws Exception {
         if (args.length > 2 || args.length <= 0) {
-            throw new IllegalArgumentException("Validation requires 1 or 2 xmls");
+            throw new IllegalArgumentException("Validation requires 1 or 2 DMN file paths");

Review Comment:
   @yesamer 
   Please keep in mind that there could be more then two models in the "import" scenario; e.g.
   
   1. model A import both model B and model C
   2. model A import model B that, in turn, import model C
   3. ecc
   
   Please remove the `args.length > 2 ` constraint, and adapt the exception message accordingly.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1539483416


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];

Review Comment:
   @tiagobento I applied your suggestion, but I need to introduce an empty index.js in the src and assign it as `main` parameter in package.json. Without that, `require.resolve("@kie-tools/dmn-testing-models")` is not resolved as module. Is that fine or there's a nicer way to do that ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [incubator-kie-issues#1043] Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537695201


##########
packages/dmn-marshaller/tests-data--manual/other/decisionAndInputWithAddition.dmn:
##########
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>

Review Comment:
   @jomarko Scope of the different version folders is to have models showing features specific for that version.
   IINW that model has nothing specific for DMN 1.5 (beside the tag)
   Unfortunately, until now we did not enforced a strong classification/organization of models, result being that it is near to impossible to sort out the models based on the version-specific features they demonstrate.
   From now on, we plan to keep such organization, so that whenever a new DMN version comes out, version-specific models will be stored under correct folder, and will be easier to manage/use them for testing purposes.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538040788


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   Yep, I got it, you have a good point, and we indeed need a good strategy to make sure we're covered. My observation was about `xsdSequence.test.ts`, where you introduced the `/\s/g` replace. If we ignore spaces and new lines, we are ignoring the new line treatment for FEEL expressions, for example, which is very important.
   
   IMHO we should normalize the files by formatting them with Prettier, programatically. We've done it in other places, no reason why we can't do it here as well. We trust Prettier won't break anything when formatting, so doing:
   
   1. Read unformatted file
   2. Formatting it with Prettier, using the XML rules.
   3. Parsing it with our Marshaller.
   4. Building it with our Marshaller, and formatting it with Prettier.
   5. Comparing formatted original XML with formatted built XML.
   
   should be the way to go, IMHO. WDYT?
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570243762


##########
packages/dmn-testing-models/index.js:
##########
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/** Empty Entrypoint of this module - No TS/JS code here, it just holds DMN files for testing purposes */

Review Comment:
   After I applied the suggestion of comment https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1569493358, yes. Removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570252820


##########
packages/dmn-testing-models/pom.xml:
##########
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~ 
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~ 
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.      
+-->
+<project
+  xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
+>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.kie.tools</groupId>
+    <artifactId>dmn-testing-models</artifactId>
+    <version>${revision}</version>
+    <packaging>jar</packaging>
+
+    <name>DMN Testing Models</name>
+    <description>Testing models for DMN marshaller</description>

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570277128


##########
packages/dmn-marshaller/tests/dmnValidation.test.ts:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { fail } from "assert";
+import {
+  DmnBackendCompatibilityScript,
+  executeJBangScript,
+} from "@kie-tools/dmn-marshaller-backend-compatibility-tester";
+
+/**
+ * This test suite validates the xml produced (parsed and built) by the marshaller relying on KIE DMN Validator
+ * (https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation).
+ * A JBang script is used to actually call the KIE DMN Validator Java code.
+ */
+
+const dmnTestingModelsPath = require.resolve("@kie-tools/dmn-testing-models");

Review Comment:
   With `path.dirname(require.resolve("@kie-tools/dmn-testing-models/package.json"))` we need to replace `../` with `dist/`
   Done!
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570870758


##########
packages/dmn-marshaller-backend-compatibility-tester/src/index.ts:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import * as path from "path";
+const buildEnv = require("../env");
+const jbang = require("@jbangdev/jbang");
+
+export enum DmnBackendCompatibilityScript {
+  PARENT_SCRIPT,
+  DMN_VALIDATION,
+  DMN_SEMANTIC_COMPARISON,
+}
+
+const dmnBackendCompatibilityScriptPaths = new Map([
+  [
+    DmnBackendCompatibilityScript.PARENT_SCRIPT,
+    path.join(__dirname, "..", "src", "DmnMarshallerBackendCompatibilityTesterScript.java"),
+  ],
+  [DmnBackendCompatibilityScript.DMN_VALIDATION, path.join(__dirname, "..", "src", "DmnValidation.java")],
+  [
+    DmnBackendCompatibilityScript.DMN_SEMANTIC_COMPARISON,
+    path.join(__dirname, "..", "src", "DmnSemanticComparison.java"),
+  ],
+]);
+
+export function executeJBangScript(script: DmnBackendCompatibilityScript, ...args: string[]) {
+  /* Windows requires double quotes to wrap the argument, while in POSIX it must be wrapped by single quotes */
+  const isWindowsPath = path.sep !== "/";
+  const quoteChar = isWindowsPath ? '"' : "'";
+  const scriptPath = dmnBackendCompatibilityScriptPaths.get(script);
+
+  const jbangArgs = [] as string[];
+  jbangArgs.push("-Dkogito-runtime.version=" + buildEnv.env.kogitoRuntime.version);
+  jbangArgs.push(scriptPath!);
+  args?.forEach((arg) => jbangArgs.push(quoteChar + arg + quoteChar));
+
+  jbang.exec("properties@jbangdev", "java.version");
+  jbang.exec(jbangArgs.join(" "));
+}

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1574790154


##########
packages/dmn-marshaller/tests/dmnValidation.test.ts:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { fail } from "assert";
+import {
+  checkDmnValidation,
+  checkDmnValidationWithImports,
+} from "@kie-tools/dmn-marshaller-backend-compatibility-tester";
+
+/**
+ * This test suite validates the xml produced (parsed and built) by the marshaller relying on KIE DMN Validator
+ * (https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation).
+ * A JBang script is used to actually call the KIE DMN Validator Java code.
+ */
+
+const dmnTestingModelsPath = path.dirname(require.resolve("@kie-tools/dmn-testing-models/package.json"));
+
+const dmnTestingModels = [
+  "dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/NegationOfDurationEvaluate.dmn",
+  "dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "dist/valid_models/DMNv1_x/multiple/Financial.dmn",
+  "dist/valid_models/DMNv1_x/multiple/Imported_Traffic_Violation.dmn",

Review Comment:
   For the above reason yes. 
   In addition, even if dmnValidation and dmnSemanticComparison are currently declaring the same arrays, I would prefer to keep them well separated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [incubator-kie-issues#1043] Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537790153


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];
 
 describe("idempotency", () => {
   for (const file of files) {
-    test(path.basename(file), () => {
-      const xml_original = fs.readFileSync(path.join(__dirname, file), "utf-8");
-
-      const { parser, builder } = getMarshaller(xml_original, { upgradeTo: "latest" });
-      const json = parser.parse();
-
-      const xml_firstPass = builder.build(json);
-      const xml_secondPass = builder.build(getMarshaller(xml_firstPass, { upgradeTo: "latest" }).parser.parse());
+    testFile(path.join(__dirname, file));
+  }
+});
 
-      expect(xml_firstPass).toStrictEqual(xml_secondPass);
-    });
+describe("idempotency_all", () => {
+  for (const models_paths of testing_models_paths) {
+    const parent_path = path.join(__dirname, models_paths);
+    testDirectory(parent_path);
   }
 });
+
+function testDirectory(fullPathOfModels: string) {
+  fs.readdirSync(fullPathOfModels).forEach((file) => {
+    const child_path = path.join(fullPathOfModels, file);
+    const stats = fs.statSync(child_path);
+    if (stats.isFile()) {
+      testFile(child_path);
+    } else {
+      testDirectory(child_path);
+    }
+  });
+}
+
+function testFile(fullPathOfFile: string) {
+  test(fullPathOfFile.substring(fullPathOfFile.lastIndexOf("/") + 1), () => {
+    console.log("Testing " + fullPathOfFile);

Review Comment:
   We don't need this log here, as the name of the test already makes it clear what's being tested.



##########
packages/dmn-testing-models/install.js:
##########
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const buildEnv = require("./env");
+const { setup } = require("@kie-tools/maven-config-setup-helper");
+
+setup(`
+    -Dversion.org.kie.kogito=${buildEnv.env.kogitoRuntime.version}

Review Comment:
   (*)... so you can add a `-Drevision` here. In `kie-tools`, the version of a package is determined by the package.json, and all technology-specific files are generated/parameterized from there. That's why you see `-Drevision` configured for other Maven packages.



##########
packages/dmn-testing-models/pom.xml:
##########
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~ 
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~ 
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.      
+-->
+<project
+        xmlns="http://maven.apache.org/POM/4.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.kie.tools</groupId>
+    <artifactId>dmn-testing-models</artifactId>
+    <version>${revision}</version>
+    <packaging>jar</packaging>
+
+    <name>DMN Testing Models</name>
+    <description>Testing models for DMN editor</description>

Review Comment:
   Not sure if that's the better description here, as these models are currently only being used by the marshaller... Maybe we can leave this as a generic description...



##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];
 
 describe("idempotency", () => {
   for (const file of files) {
-    test(path.basename(file), () => {
-      const xml_original = fs.readFileSync(path.join(__dirname, file), "utf-8");
-
-      const { parser, builder } = getMarshaller(xml_original, { upgradeTo: "latest" });
-      const json = parser.parse();
-
-      const xml_firstPass = builder.build(json);
-      const xml_secondPass = builder.build(getMarshaller(xml_firstPass, { upgradeTo: "latest" }).parser.parse());
+    testFile(path.join(__dirname, file));
+  }
+});
 
-      expect(xml_firstPass).toStrictEqual(xml_secondPass);
-    });
+describe("idempotency_all", () => {
+  for (const models_paths of testing_models_paths) {
+    const parent_path = path.join(__dirname, models_paths);
+    testDirectory(parent_path);
   }
 });
+
+function testDirectory(fullPathOfModels: string) {
+  fs.readdirSync(fullPathOfModels).forEach((file) => {
+    const child_path = path.join(fullPathOfModels, file);
+    const stats = fs.statSync(child_path);
+    if (stats.isFile()) {
+      testFile(child_path);
+    } else {
+      testDirectory(child_path);
+    }
+  });
+}
+
+function testFile(fullPathOfFile: string) {

Review Comment:
   We usually name `path` string variables with some more details.
   
   Please take a look at this comment: https://github.com/apache/incubator-kie-issues/issues/783



##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   Several comments here:
   
   1. 
   Using an array for `fileSource` and `fileExpected` is not the way to go here. I would inline the paths, to be honest.
   
   2.
   Having one `describe` for each `test` looks weird too. I would do one describe like this:
   
   `describe("build always produces elements in the same order"`
   
   and two tests like this:
   
   `test("after adding elements")`
   `test("after reading denormalized file")`
   
   
   3. 
   Replacing blank spaces with an empty string is tempering with the tests. My suggestion is that we match the files char by char, without exceptions.



##########
packages/dmn-testing-models/package.json:
##########
@@ -0,0 +1,43 @@
+{
+  "private": true,
+  "name": "@kie-tools/dmn-testing-models",
+  "version": "0.0.0",
+  "description": "",
+  "license": "Apache-2.0",
+  "homepage": "https://github.com/apache/incubator-kie-tools",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/incubator-kie-tools.git"
+  },
+  "bugs": {
+    "url": "https://github.com/apache/incubator-kie-tools/issues"
+  },
+  "files": [
+    "dist"
+  ],
+  "scripts": {
+    "build:dev": "run-script-os",
+    "build:dev:linux:darwin": "mvn clean generate-resources",
+    "build:dev:win32": "pnpm powershell \"mvn clean generate-resources\"",
+    "build:prod": "pnpm build:dev",
+    "copy:app": "run-script-os",
+    "copy:app:linux:darwin": "copyfiles -u 1 \"target/generated-resources/valid_models/**/*.dmn\" dist/",
+    "copy:app:win32": "copyfiles -u 1 \"target/generated-resources/valid_models/**/*.dmn\" dist/",
+    "dist": "rimraf dist && mkdir dist && pnpm copy:app",

Review Comment:
   These 4 scripts are being used, from what I understood. Can you please check and remove them if that's true?



##########
packages/dmn-testing-models/pom.xml:
##########
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~ 
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~ 
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.      
+-->
+<project
+        xmlns="http://maven.apache.org/POM/4.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.kie.tools</groupId>
+    <artifactId>dmn-testing-models</artifactId>
+    <version>${revision}</version>
+    <packaging>jar</packaging>
+
+    <name>DMN Testing Models</name>
+    <description>Testing models for DMN editor</description>
+
+    <licenses>
+        <license>
+            <name>Apache Software License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <scm>
+        <connection>scm:git:git@github.com:apache/incubator-kie-tools.git</connection>
+        <developerConnection>scm:git:git@github.com:apache/incubator-kie-tools.git</developerConnection>
+        <url>scm:git:git@github.com:apache/incubator-kie-tools.git</url>
+    </scm>
+
+    <developers>
+        <developer>
+            <name>All developers are listed in the KIE GitHub organization</name>
+            <url>https://github.com/orgs/kiegroup/people</url>
+        </developer>
+    </developers>
+
+    <repositories>
+        <repository>
+            <!-- Duplicating the Maven Central repository here (as it is already coming from Super POM) makes the build much faster,
+                 as the Maven Central is now treated as the first (default) repository (because it is before the Apache Nexus one).
+                 Artifacts with release (fixed) versions are being downloaded primarily from there. Without the central being the
+                 first repository the Apache Nexus would be contacted first and since it is quite slow it slows down the build.
+                 We use Apache repo only to download our SNAPSHOTs. -->
+            <id>central</id>
+            <name>Central Repository</name>
+            <url>https://repo.maven.apache.org/maven2</url>
+            <layout>default</layout>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+        <repository>
+            <id>apache-public-repository-group</id>
+            <name>Apache Public Repository Group</name>
+            <url>https://repository.apache.org/content/groups/public/</url>
+            <releases>
+                <enabled>true</enabled>
+                <updatePolicy>never</updatePolicy>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+                <updatePolicy>daily</updatePolicy>
+            </snapshots>
+        </repository>
+    </repositories>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <dependency-plugin.version>3.6.1</dependency-plugin.version>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.kie</groupId>
+                <artifactId>kie-dmn-test-resources</artifactId>
+                <version>${version.org.kie.kogito}</version>
+                <classifier>tests</classifier>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.kie</groupId>
+            <artifactId>kie-dmn-test-resources</artifactId>
+            <classifier>tests</classifier>
+        </dependency>
+    </dependencies>
+
+    <build>
+<!--        <resources>-->
+<!--            &lt;!&ndash; DMN generated resources unpacked from org.kie:kie-dmn-test-resources &ndash;&gt;-->
+<!--            <resource>-->
+<!--                <directory>${project.build.directory}/generated-resources/valid_models</directory>-->
+<!--            </resource>-->
+<!--        </resources>-->

Review Comment:
   Remove?



##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];

Review Comment:
   In order not make make packages dependent on the directory structure of the monorepo, for these cases we use `require.resolve("@kie-tools/dmn-testing-models")`, using the package name, instead of the package directory. The command above is like an import, but for a directory inside a package. You can use `path.join` then to concatenate the result of `require.resolve` with the path string you're pointing to. Keep in mind that we need to support these tests on Windows as well, if I'm not mistaken.



##########
packages/dmn-testing-models/env/index.js:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//const { getOrDefault, varsWithName, composeEnv } = require("@kie-tools-scripts/build-env");
+const { varsWithName, composeEnv } = require("@kie-tools-scripts/build-env");
+
+module.exports = composeEnv([require("@kie-tools/root-env/env")], {
+  vars: varsWithName({}),
+  get env() {
+    return {};
+  },
+});

Review Comment:
   You need the package.json version here to be exposed as a variable (*)....



##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";

Review Comment:
   Please do not import from `src` directly, and instead use `@kie-tools/dmn-marshaller`.



##########
packages/dmn-testing-models/pom.xml:
##########
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~ 
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~ 
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.      
+-->
+<project
+        xmlns="http://maven.apache.org/POM/4.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.kie.tools</groupId>
+    <artifactId>dmn-testing-models</artifactId>
+    <version>${revision}</version>
+    <packaging>jar</packaging>
+
+    <name>DMN Testing Models</name>
+    <description>Testing models for DMN editor</description>
+
+    <licenses>
+        <license>
+            <name>Apache Software License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <scm>
+        <connection>scm:git:git@github.com:apache/incubator-kie-tools.git</connection>
+        <developerConnection>scm:git:git@github.com:apache/incubator-kie-tools.git</developerConnection>
+        <url>scm:git:git@github.com:apache/incubator-kie-tools.git</url>
+    </scm>
+
+    <developers>
+        <developer>
+            <name>All developers are listed in the KIE GitHub organization</name>
+            <url>https://github.com/orgs/kiegroup/people</url>
+        </developer>
+    </developers>

Review Comment:
   Maybe remove this?



##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x/allTypes.dmn",
+];
+
+const testing_models_paths = [
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_5",
+  "../node_modules/@kie-tools/dmn-testing-models/dist/valid_models/DMNv1_x",
 ];
 
 describe("idempotency", () => {
   for (const file of files) {
-    test(path.basename(file), () => {
-      const xml_original = fs.readFileSync(path.join(__dirname, file), "utf-8");
-
-      const { parser, builder } = getMarshaller(xml_original, { upgradeTo: "latest" });
-      const json = parser.parse();
-
-      const xml_firstPass = builder.build(json);
-      const xml_secondPass = builder.build(getMarshaller(xml_firstPass, { upgradeTo: "latest" }).parser.parse());
+    testFile(path.join(__dirname, file));
+  }
+});

Review Comment:
   Why stop testing the models that are currently being tested? 



##########
packages/dmn-testing-models/README.md:
##########
@@ -0,0 +1,10 @@
+## DMN testing models
+
+This package is meant to contain all the DMN models published inside `org.kie:kie-dmn-test-resources` to make them available for testing purposes.
+
+Simply issue `mvn clean generated-resources` to download the jar and extract the models under `target/generated-resources/valid_models`.

Review Comment:
   I guess this paragraph is not true, as we're unpacking directly at `dist`, no?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1557305621


##########
packages/dmn-testing-models/install.js:
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const buildEnv = require("./env");
+const { setup } = require("@kie-tools/maven-config-setup-helper");
+
+setup(`
+    -Drevision=${buildEnv.env.dmnTestingModel.version}
+    -Dversion.org.kie.kogito=${buildEnv.env.kogitoRuntime.version}

Review Comment:
   @gitgabrio Yep, it's correct. `version.org.kie.kogito` is used in the module pom.xml file, while `kogito-runtime.version` is used in the JBang script.



##########
packages/dmn-testing-models/install.js:
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const buildEnv = require("./env");
+const { setup } = require("@kie-tools/maven-config-setup-helper");
+
+setup(`
+    -Drevision=${buildEnv.env.dmnTestingModel.version}
+    -Dversion.org.kie.kogito=${buildEnv.env.kogitoRuntime.version}

Review Comment:
   @jomarko  Yep, it's correct. `version.org.kie.kogito` is used in the module pom.xml file, while `kogito-runtime.version` is used in the JBang script.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1555081162


##########
packages/dmn-marshaller/tests/jbang/jbangManager.ts:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import * as path from "path";
+const jbang = require("@jbangdev/jbang");
+
+export function executeJbangScript(scriptPath: string, ...args: string[]) {
+  /* Windows requires a double quotes to wrap the argument and a single line argument, while POSIX can be multiline and wrapped by quotes */
+  const isWindowsPath = path.sep !== "/";
+  const quoteChar = isWindowsPath ? '"' : "'";
+  jbang.exec("--java 17", "properties@jbangdev", "java.version");
+  jbang.exec(
+    scriptPath,
+    args
+      .map(
+        (arg) =>
+          quoteChar +
+          (isWindowsPath //.replace(/>(\n|\t|\s/)*</g, "><")
+            ? arg
+            : arg
+                .trim()
+                .replace(/\n|\t|\s/g, " ")
+                .replace(/\s+/g, " ")
+                .replace(/"/, '\\"')) +

Review Comment:
   ## Incomplete string escaping or encoding
   
   This replaces only the first occurrence of /"/.
   
   [Show more details](https://github.com/apache/incubator-kie-tools/security/code-scanning/677)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538044196


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   Btw our Marshaller will sometimes produce an XML that it NOT a 1:1 match with the original.
   
   Examples include:
   
   1. Self-closing tags.
   2. CDATA blocks get flattened and all values get escaped using XML entities.
   3. Comments
   4. xsd:sequence order (We can read in any order, but will always build in the correct order declared by xsd:sequences on the XSD)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537817255


##########
packages/dmn-testing-models/package.json:
##########
@@ -0,0 +1,43 @@
+{
+  "private": true,
+  "name": "@kie-tools/dmn-testing-models",
+  "version": "0.0.0",
+  "description": "",
+  "license": "Apache-2.0",
+  "homepage": "https://github.com/apache/incubator-kie-tools",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/incubator-kie-tools.git"
+  },
+  "bugs": {
+    "url": "https://github.com/apache/incubator-kie-tools/issues"
+  },
+  "files": [
+    "dist"
+  ],
+  "scripts": {
+    "build:dev": "run-script-os",
+    "build:dev:linux:darwin": "mvn clean generate-resources",
+    "build:dev:win32": "pnpm powershell \"mvn clean generate-resources\"",
+    "build:prod": "pnpm build:dev",
+    "copy:app": "run-script-os",
+    "copy:app:linux:darwin": "copyfiles -u 1 \"target/generated-resources/valid_models/**/*.dmn\" dist/",
+    "copy:app:win32": "copyfiles -u 1 \"target/generated-resources/valid_models/**/*.dmn\" dist/",
+    "dist": "rimraf dist && mkdir dist && pnpm copy:app",

Review Comment:
   These 4 scripts aren't being used, from what I understood. Can you please check and remove them if that's true?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1572090068


##########
packages/dmn-testing-models/README.md:
##########
@@ -0,0 +1,20 @@
+## DMN testing models
+
+This package is meant to contain all the DMN models published inside [kie-dmn-test-resources](https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-test-resources) to make them available for testing purposes.
+
+Models are separated between < 1.5 version and 1.5 version; such classification is based on actual version-specific features, and not on the referenced tag itself.
+
+For future DMN versions there will be version specific folders.
+
+The original `org.kie:kie-dmn-test-resources` also contains _invalid_ models, but for the moment being we use only the valid ones to verify round-trip validation.
+
+### Usage
+
+The command `mvn clean generate-resources` downloads the jar and extract the models under `dist/`.
+
+To make them available for testing purpose:
+
+1. set the `KOGITO_RUNTIME_version` in the terminal (if different from the default one)
+2. `pnpm bootstrap` on the root directory
+3. cd dmn-testing-models
+4. `pnpm build:dev` or `pnpm build:prod` (they behave the same way - this executes `mvn clean generate-resources`)

Review Comment:
   Done



##########
packages/dmn-testing-models/README.md:
##########
@@ -0,0 +1,20 @@
+## DMN testing models
+
+This package is meant to contain all the DMN models published inside [kie-dmn-test-resources](https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-test-resources) to make them available for testing purposes.
+
+Models are separated between < 1.5 version and 1.5 version; such classification is based on actual version-specific features, and not on the referenced tag itself.
+
+For future DMN versions there will be version specific folders.
+
+The original `org.kie:kie-dmn-test-resources` also contains _invalid_ models, but for the moment being we use only the valid ones to verify round-trip validation.
+
+### Usage
+
+The command `mvn clean generate-resources` downloads the jar and extract the models under `dist/`.

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#issuecomment-2061800232

   @tiagobento This is ready for another review round.
   
   - I added the new module that holds the JBang stuff, as agreed
   - I implemented the fetching mechanism as agreed. We can't directly call `jbang` in the `package.json` file, because after installing JBang with the preinstall hook, it requires a new Shell for changes to take effect. So I created a new TS file to manage this case. The file is then called in the package.json "fetch" script.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538674605


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",

Review Comment:
   @tiagobento 
   The important thing is the quality/kind of tests, and not the number of them.
   As it currently is, the idempotency test has a very focused meaning, which does not change if executed with 10 or 100 files that basically has the same features.
   On the other side, the scope of "centralize DMN testing files" is exactly to have and use the centralized ones, slowly removing all the others (beside very specific ones and use cases.
   Anyway, if you want them back, no prblm to me 👍 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#issuecomment-2024591883

   @jomarko 
   Yes, @yesamer mentioned [it](https://github.com/apache/incubator-kie-tools/pull/2207#pullrequestreview-1958703432)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570207808


##########
packages/dmn-marshaller/tests/xsdValidation.test.ts:
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import * as validator from "xsd-schema-validator";
+
+/**
+ * This test suite validates the xml produced (parsed and built) by the marshaller against DMN 1.5 XML Schema.
+ * The validation is performed by a 3rd party library (xsd-schema-validator)
+ */

Review Comment:
   I removed the test suite at all, as it's a duplication of dmnValidation.test
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570257069


##########
packages/dmn-marshaller-backend-compatibility-tester/package.json:
##########
@@ -0,0 +1,33 @@
+{

Review Comment:
   @tiagobento Thank you, set it as private.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] [incubator-kie-issues#1043] Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1537688090


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";
 
 const files = [
-  "../tests-data--manual/other/attachment.dmn",
-  "../tests-data--manual/other/empty13.dmn",
-  "../tests-data--manual/other/sample12.dmn",
-  "../tests-data--manual/other/list.dmn",
-  "../tests-data--manual/other/list2.dmn",
-  "../tests-data--manual/other/external.dmn",
-  "../tests-data--manual/other/weird.dmn",
-  "../tests-data--manual/dmn-1_4--examples/Chapter 11 Example 1 Originations/Chapter 11 Example.dmn",

Review Comment:
   @jomarko They are used elsewhere (e.g. typeSafety.test.ts, versions.test.test)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1539218994


##########
packages/dmn-testing-models/pom.xml:
##########
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~ 
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~ 
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.      
+-->
+<project
+        xmlns="http://maven.apache.org/POM/4.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.kie.tools</groupId>
+    <artifactId>dmn-testing-models</artifactId>
+    <version>${revision}</version>
+    <packaging>jar</packaging>
+
+    <name>DMN Testing Models</name>
+    <description>Testing models for DMN editor</description>
+
+    <licenses>
+        <license>
+            <name>Apache Software License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <scm>
+        <connection>scm:git:git@github.com:apache/incubator-kie-tools.git</connection>
+        <developerConnection>scm:git:git@github.com:apache/incubator-kie-tools.git</developerConnection>
+        <url>scm:git:git@github.com:apache/incubator-kie-tools.git</url>
+    </scm>
+
+    <developers>
+        <developer>
+            <name>All developers are listed in the KIE GitHub organization</name>
+            <url>https://github.com/orgs/kiegroup/people</url>
+        </developer>
+    </developers>

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1539220955


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -20,30 +20,61 @@
 import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnMarshaller, DmnMarshallerOpts, DmnMarshallerVersions } from "../src";

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538681097


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   @tiagobento 
   About last comment, I get your point, but currently I see no alternatives, and TBH this string comparison is by itself a bad way to verify the behavior of this kind of code.
   We spent a lot of time setting up a testing strategy for code-generation, backend side, and if you think about it this is more or less the same thing. We actually need something that is able to verify semantically the two objects (expected and retrieved), but currently there is not. Until then,  IMO the current proposal is an improvement, anyway, at least for the moment being.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1569335990


##########
packages/dmn-testing-models/README.md:
##########
@@ -0,0 +1,21 @@
+## DMN testing models
+
+This package is meant to contain all the DMN models published inside [kie-dmn-test-resources](https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-test-resources) to make them available for testing purposes.
+
+Models are separated between < 1.5 version and 1.5 version; such classification is based on actual version-specific features, and not on the referenced tag itself.
+
+For future DMN versions there will be version specific folders.
+
+The original `org.kie:kie-dmn-test-resources` also contains _invalid_ models, but for the moment being we use only the valid ones to verify round-trip validation.
+
+### Usage
+
+The command `mvn clean generate-resources` downloads the jar and extract the models under `dist/`.
+
+To make them available for testing purpose:
+
+1. set the `KOGITO_RUNTIME_version` in the terminal (if different from the default one)
+2. `pnpm bootstrap` on the root directory
+3. cd dmn-testing-models
+4. `pnpm install` (this creates the required mvn configuration)

Review Comment:
   Nto necessary. `install` scripts are executed as part of the `bootstrap` script, when `bootstrap` does `pnpm install`.



##########
packages/dmn-marshaller-backend-compatibility-tester/package.json:
##########
@@ -0,0 +1,33 @@
+{

Review Comment:
   I guess this package needs to be private... we don't want to publish this to NPM, do we?



##########
packages/dmn-marshaller/tests/dmnValidation.test.ts:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { fail } from "assert";
+import {
+  DmnBackendCompatibilityScript,
+  executeJBangScript,
+} from "@kie-tools/dmn-marshaller-backend-compatibility-tester";
+
+/**
+ * This test suite validates the xml produced (parsed and built) by the marshaller relying on KIE DMN Validator
+ * (https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation).
+ * A JBang script is used to actually call the KIE DMN Validator Java code.
+ */
+
+const dmnTestingModelsPath = require.resolve("@kie-tools/dmn-testing-models");

Review Comment:
   Ok, so I guess that's what you need the `index.js` for. You can change this to 
   
   ```ts
   path.dirname(require.resolve("@kie-tools/dmn-testing-models/package.json"))
   ```
   
   so that you don't need the index.js there :)



##########
packages/dmn-testing-models/index.js:
##########
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/** Empty Entrypoint of this module - No TS/JS code here, it just holds DMN files for testing purposes */

Review Comment:
   We don't need this file at all, do we?



##########
packages/dmn-marshaller-backend-compatibility-tester/src/index.ts:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import * as path from "path";
+const buildEnv = require("../env");
+const jbang = require("@jbangdev/jbang");
+
+export enum DmnBackendCompatibilityScript {
+  PARENT_SCRIPT,
+  DMN_VALIDATION,
+  DMN_SEMANTIC_COMPARISON,
+}
+
+const dmnBackendCompatibilityScriptPaths = new Map([
+  [
+    DmnBackendCompatibilityScript.PARENT_SCRIPT,
+    path.join(__dirname, "..", "src", "DmnMarshallerBackendCompatibilityTesterScript.java"),
+  ],
+  [DmnBackendCompatibilityScript.DMN_VALIDATION, path.join(__dirname, "..", "src", "DmnValidation.java")],
+  [
+    DmnBackendCompatibilityScript.DMN_SEMANTIC_COMPARISON,
+    path.join(__dirname, "..", "src", "DmnSemanticComparison.java"),
+  ],
+]);
+
+export function executeJBangScript(script: DmnBackendCompatibilityScript, ...args: string[]) {
+  /* Windows requires double quotes to wrap the argument, while in POSIX it must be wrapped by single quotes */
+  const isWindowsPath = path.sep !== "/";
+  const quoteChar = isWindowsPath ? '"' : "'";
+  const scriptPath = dmnBackendCompatibilityScriptPaths.get(script);
+
+  const jbangArgs = [] as string[];
+  jbangArgs.push("-Dkogito-runtime.version=" + buildEnv.env.kogitoRuntime.version);
+  jbangArgs.push(scriptPath!);
+  args?.forEach((arg) => jbangArgs.push(quoteChar + arg + quoteChar));
+
+  jbang.exec("properties@jbangdev", "java.version");
+  jbang.exec(jbangArgs.join(" "));
+}

Review Comment:
   We discussed making the JBang completely abstracted from the caller, no? This would then become a method that accepts parameters using an object parameter, instead of exposing the command itself. Let's make JBang an implementation detail of this package, instead of leaking it to the consumers.



##########
packages/dmn-marshaller/tests/xsdValidation.test.ts:
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import * as validator from "xsd-schema-validator";
+
+/**
+ * This test suite validates the xml produced (parsed and built) by the marshaller against DMN 1.5 XML Schema.
+ * The validation is performed by a 3rd party library (xsd-schema-validator)
+ */

Review Comment:
   Outdated comment?



##########
packages/dmn-marshaller-backend-compatibility-tester/README.md:
##########
@@ -0,0 +1,36 @@
+### Module Description

Review Comment:
   ```suggestion
   ### DMN Marshaller backend compatibility tester
   ```
   ?



##########
packages/dmn-testing-models/env/index.js:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const { varsWithName, composeEnv } = require("@kie-tools-scripts/build-env");
+
+module.exports = composeEnv([require("@kie-tools/root-env/env")], {
+  vars: varsWithName({}),
+  get env() {
+    return {
+      dmnTestingModel: {
+        version: require("../package.json").version,
+      },

Review Comment:
   ```suggestion
         dmnTestingModels: {
           version: require("../package.json").version,
         },
   ```



##########
packages/dmn-marshaller/package.json:
##########
@@ -51,6 +53,7 @@
     "jest-when": "^3.5.0",
     "rimraf": "^3.0.2",
     "ts-jest": "^26.5.6",
-    "typescript": "^4.6.2"
+    "typescript": "^4.6.2",
+    "xsd-schema-validator": "^0.9.0"

Review Comment:
   Not needed anymore, I suppose?



##########
packages/dmn-testing-models/pom.xml:
##########
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~ 
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~ 
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.      
+-->
+<project
+  xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
+>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.kie.tools</groupId>
+    <artifactId>dmn-testing-models</artifactId>
+    <version>${revision}</version>
+    <packaging>jar</packaging>
+
+    <name>DMN Testing Models</name>
+    <description>Testing models for DMN marshaller</description>

Review Comment:
   Can you please make this pom.xml file declare `maven-base` as parent? Please see https://github.com/apache/incubator-kie-tools/pull/2195#issuecomment-2061743588



##########
packages/dmn-marshaller-backend-compatibility-tester/README.md:
##########
@@ -0,0 +1,36 @@
+### Module Description
+
+The scope of this module is to provide a reliable scripting mechanism that tests DMN Files generated by the `dmn-marshaller` module against the backend counterpart code that lives in the drools repository.

Review Comment:
   ```suggestion
   The scope of this module is to provide a reliable scripting mechanism that tests DMN Files generated by the `dmn-marshaller` package against the backend counterpart code that lives in the drools repository.
   ```



##########
packages/dmn-marshaller-backend-compatibility-tester/README.md:
##########
@@ -0,0 +1,36 @@
+### Module Description
+
+The scope of this module is to provide a reliable scripting mechanism that tests DMN Files generated by the `dmn-marshaller` module against the backend counterpart code that lives in the drools repository.
+The scripts are based on [JBang!](https://www.jbang.dev/) which provides an out-of-the-box library to be consumed in NodeJs.
+
+At the moment of writing, two scripts are available:
+
+- DMN Validation, which can validate a DMN file (and its imported DMN assets) using the [KIE DMN Validator](https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation) back-end module.
+- DMN Semantic Comparison, which compares two DMN files (and their imported DMN assets) using a Backend logic that relies on KIE DMN Engine core code.
+
+Every script is defined in a single Java class. Inside those, you can find a list of fields (marked with `@Option` annotation) that represent the commands and their required parameters to run the scripts.
+
+An abstract class is defined as the parent class of all defined scripts. That class holds all the Dependencies required by all the Java class scripts that implement it. This is required to enable a dependency fetching mechanism useful for:
+
+- Avoid issues when launching several JBang instances. This case may lead to issues with internal JBang caching.
+- In CI/CD, it's sometimes required to download all the required dependencies in an earlier phase and then build the project.
+  To run the dependency fetching mechanism, you can just launch the jbang command passing that Abstract class location (no args).
+  To keep this mechanism consistent, please always declare all the required dependencies in the abstract superclass.
+  The dependency fetching mechanism can be called externally from a `package.json` script using the `dependenciesFetch.js` file, using the following command:
+  `node dist/dependenciesFetch.js`.
+  It's not possible to directly call JBang in the package.json script because when the JBang NPM library installs JBang in the local machine with the preinstall hook, it requires a new Shell for changes to take effect.
+
+### Usage
+
+The entry point of this module is the `index.js` file that exports:
+
+- `executeJBangScript` that requires as parameters: the Script to execute (see below) and its required args.
+- The enumeration of the currently available Script
+  That represents all the required elements for consuming this module externally.
+
+To execute a specific JBang script present in this module you must:
+
+- Import the `"@kie-tools/dmn-marshaller-backend-compatibility-tester": "workspace:*"` dependency;

Review Comment:
   ```suggestion
   - Import the `"@kie-tools/dmn-marshaller-backend-compatibility-tester" dependency;
   ```
   
   No need to expose the inner mechanisms of `pnpm` (`workspace:*`) here.



##########
packages/dmn-marshaller/tests/dmnValidation.test.ts:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { fail } from "assert";
+import {
+  DmnBackendCompatibilityScript,
+  executeJBangScript,
+} from "@kie-tools/dmn-marshaller-backend-compatibility-tester";
+
+/**
+ * This test suite validates the xml produced (parsed and built) by the marshaller relying on KIE DMN Validator
+ * (https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation).
+ * A JBang script is used to actually call the KIE DMN Validator Java code.
+ */
+
+const dmnTestingModelsPath = require.resolve("@kie-tools/dmn-testing-models");
+
+const dmnTestingModels = [
+  "../valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../valid_models/DMNv1_5/NegationOfDurationEvaluate.dmn",
+  "../valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../valid_models/DMNv1_x/multiple/Financial.dmn",
+  "../valid_models/DMNv1_x/multiple/Imported_Traffic_Violation.dmn",
+  "../valid_models/DMNv1_x/multiple/stdlib.dmn",
+  "../valid_models/DMNv1_x/allTypes.dmn",
+  "../valid_models/DMNv1_x/dtevent.dmn",
+  "../valid_models/DMNv1_x/habitability.dmn",
+  "../valid_models/DMNv1_x/loan.dmn",
+  "../valid_models/DMNv1_x/LoanEligibility.dmn",
+  "../valid_models/DMNv1_x/OneOfEachType.dmn",
+  "../valid_models/DMNv1_x/Prequalification.dmn",
+  "../valid_models/DMNv1_x/testWithExtensionElements.dmn",
+  "../valid_models/DMNv1_x/Traffic Violation Simple.dmn",
+  "../valid_models/DMNv1_x/Traffic Violation.dmn",
+];
+
+const dmnTestingImportedModels = [
+  {
+    imported: "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+    importer: "../valid_models/DMNv1_5/Importing_EmptyNamed_Model_With_Href_Namespace.dmn",
+  },
+  {
+    imported: "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+    importer: "../valid_models/DMNv1_5/Importing_EmptyNamed_Model_Without_Href_Namespace.dmn",
+  },
+  {
+    imported: "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+    importer: "../valid_models/DMNv1_5/Importing_Named_Model.dmn",
+  },
+  {
+    imported: "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+    importer: "../valid_models/DMNv1_5/Importing_OverridingEmptyNamed_Model.dmn",
+  },
+  {
+    imported: "../valid_models/DMNv1_x/multiple/Imported_Traffic_Violation.dmn",
+    importer: "../valid_models/DMNv1_x/multiple/Traffic Violation With Import.dmn",
+  },
+];
+export const dmnValidationGeneratedFilesDirectory = path.join(__dirname, "../dist-tests/dmnValidation-generated-files");
+
+describe("DMN Validation", () => {
+  beforeAll(() => {
+    if (fs.existsSync(dmnValidationGeneratedFilesDirectory)) {
+      fs.rmSync(dmnValidationGeneratedFilesDirectory, { recursive: true });
+    }
+    fs.mkdirSync(dmnValidationGeneratedFilesDirectory, { recursive: true });
+  });
+
+  for (const file of dmnTestingModels) {
+    testFile(path.join(dmnTestingModelsPath, file));
+  }
+  for (const file of dmnTestingImportedModels) {
+    file.imported = path.join(dmnTestingModelsPath, file.imported);
+    file.importer = path.join(dmnTestingModelsPath, file.importer);
+    testImportedFile(file);
+  }
+});
+
+function testFile(normalizedFsPathRelativeToTheFile: string) {
+  test(
+    "DMN Validation: " +
+      normalizedFsPathRelativeToTheFile.substring(normalizedFsPathRelativeToTheFile.lastIndexOf(path.sep) + 1),
+    () => {
+      const generatedXMLFilePath = parseXMLAndWriteInFile(normalizedFsPathRelativeToTheFile);
+
+      try {
+        executeJBangScript(
+          DmnBackendCompatibilityScript.DMN_VALIDATION,
+          "--command=no_imports",
+          "--dmnFilePath=" + generatedXMLFilePath
+        );
+      } catch (error) {
+        fail(error.cause);
+      }
+    }
+  );
+}
+
+function testImportedFile(normalizedFsPathRelativeToTheFiles: { imported: string; importer: string }) {
+  test(
+    "DMN Validation: " +
+      normalizedFsPathRelativeToTheFiles.importer.substring(
+        normalizedFsPathRelativeToTheFiles.importer.lastIndexOf(path.sep) + 1
+      ),
+    () => {
+      const importedGeneratedXMLFilePath = parseXMLAndWriteInFile(normalizedFsPathRelativeToTheFiles.imported);
+      const importerGeneratedXMLFilePath = parseXMLAndWriteInFile(normalizedFsPathRelativeToTheFiles.importer);
+
+      try {
+        executeJBangScript(
+          DmnBackendCompatibilityScript.DMN_VALIDATION,
+          "--command=with_imports",
+          "--dmnFilePath=" + importedGeneratedXMLFilePath,
+          "--importedDmnFilesPaths=" + importerGeneratedXMLFilePath
+        );
+      } catch (error) {
+        fail(error.cause);
+      }
+    }
+  );
+}
+
+function parseXMLAndWriteInFile(normalizedFsPathRelativeToTheFile: string): string {

Review Comment:
   We usually do camelCase acronyms.. So `XML` would become `Xml` here.



##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -21,6 +21,8 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
+const dmnTestingModels = require.resolve("@kie-tools/dmn-testing-models");

Review Comment:
   Same as above.



##########
packages/dmn-testing-models/README.md:
##########
@@ -0,0 +1,21 @@
+## DMN testing models
+
+This package is meant to contain all the DMN models published inside [kie-dmn-test-resources](https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-test-resources) to make them available for testing purposes.
+
+Models are separated between < 1.5 version and 1.5 version; such classification is based on actual version-specific features, and not on the referenced tag itself.
+
+For future DMN versions there will be version specific folders.
+
+The original `org.kie:kie-dmn-test-resources` also contains _invalid_ models, but for the moment being we use only the valid ones to verify round-trip validation.
+
+### Usage
+
+The command `mvn clean generate-resources` downloads the jar and extract the models under `dist/`.
+
+To make them available for testing purpose:
+
+1. set the `KOGITO_RUNTIME_version` in the terminal (if different from the default one)
+2. `pnpm bootstrap` on the root directory
+3. cd dmn-testing-models
+4. `pnpm install` (this creates the required mvn configuration)

Review Comment:
   Thanks for the README, though! Looks great.



##########
packages/dmn-marshaller-backend-compatibility-tester/README.md:
##########
@@ -0,0 +1,36 @@
+### Module Description
+
+The scope of this module is to provide a reliable scripting mechanism that tests DMN Files generated by the `dmn-marshaller` module against the backend counterpart code that lives in the drools repository.
+The scripts are based on [JBang!](https://www.jbang.dev/) which provides an out-of-the-box library to be consumed in NodeJs.
+
+At the moment of writing, two scripts are available:
+
+- DMN Validation, which can validate a DMN file (and its imported DMN assets) using the [KIE DMN Validator](https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation) back-end module.
+- DMN Semantic Comparison, which compares two DMN files (and their imported DMN assets) using a Backend logic that relies on KIE DMN Engine core code.
+
+Every script is defined in a single Java class. Inside those, you can find a list of fields (marked with `@Option` annotation) that represent the commands and their required parameters to run the scripts.
+
+An abstract class is defined as the parent class of all defined scripts. That class holds all the Dependencies required by all the Java class scripts that implement it. This is required to enable a dependency fetching mechanism useful for:
+
+- Avoid issues when launching several JBang instances. This case may lead to issues with internal JBang caching.
+- In CI/CD, it's sometimes required to download all the required dependencies in an earlier phase and then build the project.
+  To run the dependency fetching mechanism, you can just launch the jbang command passing that Abstract class location (no args).
+  To keep this mechanism consistent, please always declare all the required dependencies in the abstract superclass.
+  The dependency fetching mechanism can be called externally from a `package.json` script using the `dependenciesFetch.js` file, using the following command:
+  `node dist/dependenciesFetch.js`.
+  It's not possible to directly call JBang in the package.json script because when the JBang NPM library installs JBang in the local machine with the preinstall hook, it requires a new Shell for changes to take effect.
+
+### Usage
+
+The entry point of this module is the `index.js` file that exports:
+
+- `executeJBangScript` that requires as parameters: the Script to execute (see below) and its required args.
+- The enumeration of the currently available Script
+  That represents all the required elements for consuming this module externally.
+
+To execute a specific JBang script present in this module you must:
+
+- Import the `"@kie-tools/dmn-marshaller-backend-compatibility-tester": "workspace:*"` dependency;
+- Import the `DmnBackendCompatibilityScript` Enum and `executeJBangScript` in your JS/TS file;
+- Execute the JBang script: eg. `executeJBangScript(DmnBackendCompatibilityScript.DMN_VALIDATION, args...)`
+- For the precise args list, please check inside the Java Class Script of your interest and take note of all `@Option` annotated fields.

Review Comment:
   As we discussed, I think we're much better off encapsulating JBang as an implementation detail of this package.



##########
packages/dmn-marshaller/tests/dmnValidation.test.ts:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { fail } from "assert";
+import {
+  DmnBackendCompatibilityScript,
+  executeJBangScript,
+} from "@kie-tools/dmn-marshaller-backend-compatibility-tester";
+
+/**
+ * This test suite validates the xml produced (parsed and built) by the marshaller relying on KIE DMN Validator
+ * (https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation).
+ * A JBang script is used to actually call the KIE DMN Validator Java code.
+ */
+
+const dmnTestingModelsPath = require.resolve("@kie-tools/dmn-testing-models");

Review Comment:
   This will also remove the necessity for `../`, I guess.



##########
packages/dmn-marshaller-backend-compatibility-tester/package.json:
##########
@@ -0,0 +1,33 @@
+{

Review Comment:
   The fact that it depends on `build-env` to execute is something that prevents this from being publishable to NPM. I would say make it private or change the strategy to have `build-env` abstracted from its runtime. Creating a configuration file from it can be an option, for example.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570461526


##########
packages/dmn-marshaller-backend-compatibility-tester/src/index.ts:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import * as path from "path";
+const buildEnv = require("../env");
+const jbang = require("@jbangdev/jbang");
+
+export enum DmnBackendCompatibilityScript {
+  PARENT_SCRIPT,
+  DMN_VALIDATION,
+  DMN_SEMANTIC_COMPARISON,
+}
+
+const dmnBackendCompatibilityScriptPaths = new Map([
+  [
+    DmnBackendCompatibilityScript.PARENT_SCRIPT,
+    path.join(__dirname, "..", "src", "DmnMarshallerBackendCompatibilityTesterScript.java"),
+  ],
+  [DmnBackendCompatibilityScript.DMN_VALIDATION, path.join(__dirname, "..", "src", "DmnValidation.java")],
+  [
+    DmnBackendCompatibilityScript.DMN_SEMANTIC_COMPARISON,
+    path.join(__dirname, "..", "src", "DmnSemanticComparison.java"),
+  ],
+]);
+
+export function executeJBangScript(script: DmnBackendCompatibilityScript, ...args: string[]) {
+  /* Windows requires double quotes to wrap the argument, while in POSIX it must be wrapped by single quotes */
+  const isWindowsPath = path.sep !== "/";
+  const quoteChar = isWindowsPath ? '"' : "'";
+  const scriptPath = dmnBackendCompatibilityScriptPaths.get(script);
+
+  const jbangArgs = [] as string[];
+  jbangArgs.push("-Dkogito-runtime.version=" + buildEnv.env.kogitoRuntime.version);
+  jbangArgs.push(scriptPath!);
+  args?.forEach((arg) => jbangArgs.push(quoteChar + arg + quoteChar));
+
+  jbang.exec("properties@jbangdev", "java.version");
+  jbang.exec(jbangArgs.join(" "));
+}

Review Comment:
   (Still WIP)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570208326


##########
packages/dmn-marshaller/package.json:
##########
@@ -51,6 +53,7 @@
     "jest-when": "^3.5.0",
     "rimraf": "^3.0.2",
     "ts-jest": "^26.5.6",
-    "typescript": "^4.6.2"
+    "typescript": "^4.6.2",
+    "xsd-schema-validator": "^0.9.0"

Review Comment:
   Based on the previous comment, yes. removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570123698


##########
packages/dmn-marshaller/tests/idempotency.test.ts:
##########
@@ -21,6 +21,8 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
+const dmnTestingModels = require.resolve("@kie-tools/dmn-testing-models");

Review Comment:
   @tiagobento Isn't this already in camelCase?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1570431844


##########
packages/dmn-marshaller-backend-compatibility-tester/src/index.ts:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import * as path from "path";
+const buildEnv = require("../env");
+const jbang = require("@jbangdev/jbang");
+
+export enum DmnBackendCompatibilityScript {
+  PARENT_SCRIPT,
+  DMN_VALIDATION,
+  DMN_SEMANTIC_COMPARISON,
+}
+
+const dmnBackendCompatibilityScriptPaths = new Map([
+  [
+    DmnBackendCompatibilityScript.PARENT_SCRIPT,
+    path.join(__dirname, "..", "src", "DmnMarshallerBackendCompatibilityTesterScript.java"),
+  ],
+  [DmnBackendCompatibilityScript.DMN_VALIDATION, path.join(__dirname, "..", "src", "DmnValidation.java")],
+  [
+    DmnBackendCompatibilityScript.DMN_SEMANTIC_COMPARISON,
+    path.join(__dirname, "..", "src", "DmnSemanticComparison.java"),
+  ],
+]);
+
+export function executeJBangScript(script: DmnBackendCompatibilityScript, ...args: string[]) {
+  /* Windows requires double quotes to wrap the argument, while in POSIX it must be wrapped by single quotes */
+  const isWindowsPath = path.sep !== "/";
+  const quoteChar = isWindowsPath ? '"' : "'";
+  const scriptPath = dmnBackendCompatibilityScriptPaths.get(script);
+
+  const jbangArgs = [] as string[];
+  jbangArgs.push("-Dkogito-runtime.version=" + buildEnv.env.kogitoRuntime.version);
+  jbangArgs.push(scriptPath!);
+  args?.forEach((arg) => jbangArgs.push(quoteChar + arg + quoteChar));
+
+  jbang.exec("properties@jbangdev", "java.version");
+  jbang.exec(jbangArgs.join(" "));
+}

Review Comment:
   @tiagobento I've encapsulated all the details related to JBang, and implemented a new API to be externally consumed. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1557102430


##########
packages/dmn-marshaller/tests/dmnValidation.test.ts:
##########
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+import { fail } from "assert";
+import { executeJBangScript } from "./jbang/jbangManager";
+
+/**
+ * This test suite validates the xml produced by the marshaller relying on KIE DMN Validator
+ * (https://github.com/apache/incubator-kie-drools/tree/main/kie-dmn/kie-dmn-validation).
+ * A JBang script is used to actually call the KIE DMN Validator Java code.
+ */
+
+const dmnTestingModelsPath = require.resolve("@kie-tools/dmn-testing-models");
+
+const dmnTestingModels = [
+  "../valid_models/DMNv1_5/AllowedValuesChecksInsideCollection.dmn",
+  "../valid_models/DMNv1_5/DateToDateTimeFunction.dmn",
+  "../valid_models/DMNv1_5/ForLoopDatesEvaluate.dmn",
+  "../valid_models/DMNv1_5/ListReplaceEvaluate.dmn",
+  "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+  "../valid_models/DMNv1_5/NegationOfDurationEvaluate.dmn",
+  "../valid_models/DMNv1_5/TypeConstraintsChecks.dmn",
+  "../valid_models/DMNv1_x/multiple/Financial.dmn",
+  //FULL_1_x_MULTIPLE_DIRECTORY + "Imported_Traffic_Violation.dmn",
+  "../valid_models/DMNv1_x/multiple/stdlib.dmn",
+  "../valid_models/DMNv1_x/allTypes.dmn",
+  //FULL_1_x_DIRECTORY + "dtevent.dmn",
+  //FULL_1_x_DIRECTORY + "habitability.dmn",
+  "../valid_models/DMNv1_x/loan.dmn",
+  //FULL_1_x_DIRECTORY + "LoanEligibility.dmn",
+  "../valid_models/DMNv1_x/OneOfEachType.dmn",
+  //FULL_1_x_DIRECTORY + "Prequalification.dmn",
+  "../valid_models/DMNv1_x/testWithExtensionElements.dmn",
+  //FULL_1_x_DIRECTORY + "Traffic Violation Simple.dmn",
+];
+
+const dmnTestingImportedModels = [
+  {
+    imported: "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+    importer: "../valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn",
+  },
+  {
+    imported: "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+    importer: "../valid_models/DMNv1_5/Importing_Named_Model.dmn",
+  },
+  {
+    imported: "../valid_models/DMNv1_5/Imported_Model_Unamed.dmn",
+    importer: "../valid_models/DMNv1_5/Importing_OverridingEmptyNamed_Model.dmn",
+  },
+  // {
+  //   imported: FULL_1_x_MULTIPLE_DIRECTORY + "Imported_Traffic_Violation.dmn",
+  //   importer: FULL_1_x_MULTIPLE_DIRECTORY + "Traffic Violation With Import.dmn",
+  // },
+];
+
+const marshalledXMLDirectory = path.join(__dirname, "../dist-tests/marshalled-dmn-file");
+const jbangDmnValidationScriptPath = path.join(__dirname, "./jbang/dmnValidation.java");
+
+describe("validation", () => {
+  beforeAll(() => {
+    if (fs.existsSync(marshalledXMLDirectory)) {
+      fs.rmSync(marshalledXMLDirectory, { recursive: true });
+    }
+    fs.mkdirSync(marshalledXMLDirectory, { recursive: true });
+  });
+
+  for (const file of dmnTestingModels) {
+    testFile(path.join(dmnTestingModelsPath, file));
+  }
+  for (const file of dmnTestingImportedModels) {
+    file.imported = path.join(dmnTestingModelsPath, file.imported);
+    file.importer = path.join(dmnTestingModelsPath, file.importer);
+    testImportedFile(file);
+  }
+});
+
+function testFile(normalizedFsPathRelativeToTheFile: string) {
+  test(normalizedFsPathRelativeToTheFile.substring(normalizedFsPathRelativeToTheFile.lastIndexOf(path.sep) + 1), () => {
+    const marshalledXMLFilePath = parseXMLAndWriteInFile(normalizedFsPathRelativeToTheFile);
+
+    try {
+      executeJBangScript(jbangDmnValidationScriptPath, marshalledXMLFilePath);
+    } catch (error) {
+      const fileName = normalizedFsPathRelativeToTheFile.substring(
+        normalizedFsPathRelativeToTheFile.lastIndexOf(path.sep) + 1
+      );
+      fail("Validation of " + fileName + " failed! Please scroll up to DMN VALIDATION ERROR message to see the reason");
+    }
+  });
+}
+
+function testImportedFile(normalizedFsPathRelativeToTheFiles: { imported: string; importer: string }) {
+  test(
+    normalizedFsPathRelativeToTheFiles.importer.substring(
+      normalizedFsPathRelativeToTheFiles.importer.lastIndexOf(path.sep) + 1
+    ),
+    () => {
+      const importedMarshalledXMLFilePath = parseXMLAndWriteInFile(normalizedFsPathRelativeToTheFiles.imported);
+      const importerMarshalledXMLFilePath = parseXMLAndWriteInFile(normalizedFsPathRelativeToTheFiles.importer);
+
+      try {
+        executeJBangScript(jbangDmnValidationScriptPath, importedMarshalledXMLFilePath, importerMarshalledXMLFilePath);
+      } catch (error) {
+        const fileName = normalizedFsPathRelativeToTheFiles.importer.substring(
+          normalizedFsPathRelativeToTheFiles.importer.lastIndexOf(path.sep) + 1
+        );
+        fail("Validation of " + error + " failed! Please scroll up to DMN VALIDATION ERROR message to see the reason");

Review Comment:
   ```suggestion
           fail("Validation of " + fileName + " failed! Please scroll up to DMN VALIDATION ERROR message to see the reason");
   ```



##########
packages/dmn-marshaller/tests/jbang/dmnValidation.java:
##########


Review Comment:
   what is the difference between this file, `dmnValidation.java` and `dmnSemanticComparision.java` please?



##########
packages/dmn-marshaller/tests/jbang/jbangManager.ts:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import * as path from "path";
+const jbang = require("@jbangdev/jbang");
+const buildEnv = require("../../env");
+
+export function executeJBangScript(scriptPath: string, ...args: string[]) {
+  /* Windows requires double quotes to wrap the argument, while in POSIX it must be wrapped by single quotes */
+  const isWindowsPath = path.sep !== "/";
+  const quoteChar = isWindowsPath ? '"' : "'";
+  jbang.exec("--java 17", "properties@jbangdev", "java.version");
+  jbang.exec(
+    "-Dkogito-runtime.version=" + buildEnv.env.kogitoRuntime.version,

Review Comment:
   am I correct `kogito-runtime.version` as property, its name, is defined in `drools` repository? maybe some link/comment for it would help in case it is changed in future?



##########
packages/dmn-testing-models/install.js:
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const buildEnv = require("./env");
+const { setup } = require("@kie-tools/maven-config-setup-helper");
+
+setup(`
+    -Drevision=${buildEnv.env.dmnTestingModel.version}
+    -Dversion.org.kie.kogito=${buildEnv.env.kogitoRuntime.version}

Review Comment:
   is it correct here we do not use `kogito-runtime.version`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1043: Use shared DMN models for testing purpose [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2207:
URL: https://github.com/apache/incubator-kie-tools/pull/2207#discussion_r1538044196


##########
packages/dmn-marshaller/tests/xsdSequence.test.ts:
##########
@@ -21,74 +21,57 @@ import * as fs from "fs";
 import * as path from "path";
 import { getMarshaller } from "@kie-tools/dmn-marshaller";
 
-const files = [
+const filesForAddition = [
   { path: "../tests-data--manual/other/decisionAndInput.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInputWithAddition.dmn" },
+];
+
+const filesForNormalization = [
   { path: "../tests-data--manual/other/decisionAndInput_wrongSequenceOrder.dmn" },
+  { path: "../tests-data--manual/other/decisionAndInput.dmn" },
 ];
 
-describe("build always produces elements in the same order", () => {
-  for (const file of files) {
-    test(path.basename(file.path), () => {
-      const xml = fs.readFileSync(path.join(__dirname, file.path), "utf-8");
-      const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
-      const json = marshaller.parser.parse();
+describe("build always add elements in the same order", () => {
+  test("Addition", () => {
+    const fileSource = filesForAddition[0];
+    const fileExpected = filesForAddition[1];
+    const xml = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      // Adding some props in an arbitrary order shouldn't alter the end result.
+    // Adding some props in an arbitrary order shouldn't alter the end result.
 
-      json.definitions.import = [
-        {
-          "@_name": "some-import",
-          "@_namespace": "some-namespace",
-          "@_importType": "some-import-type",
-        },
-      ];
+    json.definitions.import = [
+      {
+        "@_name": "some-import",
+        "@_namespace": "some-namespace",
+        "@_importType": "some-import-type",
+      },
+    ];
 
-      json.definitions.artifact = [
-        {
-          __$$element: "group",
-          "@_name": "some-group",
-        },
-      ];
+    json.definitions.artifact = [
+      {
+        __$$element: "group",
+        "@_name": "some-group",
+      },
+    ];
+
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toEqual(xmlExpected);
+  });
+});
+
+describe("build always produces elements in the same order", () => {
+  test("Normalization", () => {
+    const fileSource = filesForNormalization[0];
+    const fileExpected = filesForNormalization[1];
+    const xmlSource = fs.readFileSync(path.join(__dirname, fileSource.path), "utf-8");
+    const marshaller = getMarshaller(xmlSource, { upgradeTo: "1.5" });
+    const json = marshaller.parser.parse();
 
-      expect(marshaller.builder.build(json)).toStrictEqual(`<?xml version="1.0" encoding="UTF-8" ?>
-<definitions xmlns="https://www.omg.org/spec/DMN/20230324/MODEL/" expressionLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="https://kie.org/dmn/_D19C1092-7677-427F-A493-BCED38F74A9B" id="_11655DE3-BEA5-45B1-B54E-8AD84FBBED25" name="DMN_1E889EDB-B967-4508-8DB1-E0DF5986E62F" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0">
-  <import name="some-import" namespace="some-namespace" importType="some-import-type" />
-  <inputData name="New Input Data" id="_154F9E03-B180-4C87-B7D3-8745DA4336F4">
-    <variable name="New Input Data" id="_A28401DD-9A87-4251-A1E4-C63FC3A7C729" typeRef="string" />
-  </inputData>
-  <decision name="New Decision" id="_392BEF3D-44B5-47DC-8A06-C36F15DB2984">
-    <variable id="_C2C9C21A-E708-46D9-876A-52BB25692B66" typeRef="string" name="New Decision" />
-    <informationRequirement id="_E781E253-D97E-4A1D-BE51-037B012B30F0">
-      <requiredInput href="#_154F9E03-B180-4C87-B7D3-8745DA4336F4" />
-    </informationRequirement>
-    <literalExpression id="_509ED9AF-3852-48F4-89A7-3CCF221B809C" label="New Decision" typeRef="string">
-      <text>&quot;New Decision&quot;</text>
-    </literalExpression>
-  </decision>
-  <group name="some-group" />
-  <dmndi:DMNDI>
-    <dmndi:DMNDiagram id="_0D2FD42B-91FF-4795-B71F-E501CE115389" name="Default DRD" useAlternativeInputDataShape="false">
-      <di:extension>
-        <kie:ComponentsWidthsExtension>
-          <kie:ComponentWidths dmnElementRef="_509ED9AF-3852-48F4-89A7-3CCF221B809C">
-            <kie:width>190</kie:width>
-          </kie:ComponentWidths>
-        </kie:ComponentsWidthsExtension>
-      </di:extension>
-      <dmndi:DMNShape id="_92B3305F-A892-4E38-BD92-398906A9BC24" dmnElementRef="_154F9E03-B180-4C87-B7D3-8745DA4336F4" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="280" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNShape id="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2" dmnElementRef="_392BEF3D-44B5-47DC-8A06-C36F15DB2984" isCollapsed="false" isListedInputData="false">
-        <dc:Bounds x="100" y="100" width="160" height="80" />
-      </dmndi:DMNShape>
-      <dmndi:DMNEdge id="_C54C8ED9-7DB2-47BC-844A-E79D7142844B-AUTO-TARGET" dmnElementRef="_E781E253-D97E-4A1D-BE51-037B012B30F0" sourceElement="_92B3305F-A892-4E38-BD92-398906A9BC24" targetElement="_1E49EEEB-9296-4AE5-B37C-2EE0044C0CC2">
-        <di:waypoint x="180" y="320" />
-        <di:waypoint x="180" y="140" />
-      </dmndi:DMNEdge>
-    </dmndi:DMNDiagram>
-  </dmndi:DMNDI>
-</definitions>
-`);
-    });
-  }
+    const xmlRetrieved = marshaller.builder.build(json).replace(/\s/g, "");
+    const xmlExpected = fs.readFileSync(path.join(__dirname, fileExpected.path), "utf-8").replace(/\s/g, "");
+    expect(xmlRetrieved).toStrictEqual(xmlExpected);
+  });

Review Comment:
   Btw our Marshaller will sometimes produce an XML that it NOT a 1:1 match with the original.
   
   Examples include:
   
   1. Self-closing tags.
   2. CDATA blocks get flattened and all values get escaped using XML entities.
   3. Comments
   4. xsd:sequence order (We can read in any order, but will always produce at the correct order declared by xsd:sequences on the XSD)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org