This is an automated email from the ASF dual-hosted git repository.
mariofusco pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-drools.git
The following commit(s) were added to refs/heads/main by this push:
new a74b548954 [kie-issues#843] Generate reproducible dmndefinitions.json.
(#5676)
a74b548954 is described below
commit a74b548954a2c8cdc2ac7fb568ab40908f361ad5
Author: Tibor Zimányi <[email protected]>
AuthorDate: Fri Feb 9 08:03:54 2024 +0100
[kie-issues#843] Generate reproducible dmndefinitions.json. (#5676)
* Generate reproducible dmndefinitions.json.
* Replace HashMap with TreeMap.
* Revert TreeMap as that breaks some transitively related code.
* Adding a comment.
---
.../kie/dmn/openapi/impl/DMNOASGeneratorImpl.java | 27 ++++++++++++----------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git
a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNOASGeneratorImpl.java
b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNOASGeneratorImpl.java
index bd006c1dfa..1e948f09ce 100644
---
a/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNOASGeneratorImpl.java
+++
b/kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/DMNOASGeneratorImpl.java
@@ -18,16 +18,6 @@
*/
package org.kie.dmn.openapi.impl;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.stream.Collectors;
-
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.smallrye.openapi.runtime.io.JsonUtil;
import io.smallrye.openapi.runtime.io.schema.SchemaWriter;
@@ -44,6 +34,17 @@ import org.kie.dmn.typesafe.DMNTypeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.stream.Collectors;
+
public class DMNOASGeneratorImpl implements DMNOASGenerator {
private static final Logger LOG =
LoggerFactory.getLogger(DMNOASGeneratorImpl.class);
private final List<DMNModel> dmnModels;
@@ -81,7 +82,10 @@ public class DMNOASGeneratorImpl implements DMNOASGenerator {
ObjectNode tree = JsonUtil.objectNode();
ObjectNode definitions = JsonUtil.objectNode();
tree.set("definitions", definitions);
- for (Entry<DMNType, Schema> kv : schemas.entrySet()) {
+ // It would be better if the map is a TreeMap, however that breaks
test ProcessItemTest.test_together
+ // For some reason, it looks like there is some reliance on the map
being a HashMap, which should be investigated later as that should never happen.
+ final List<Entry<DMNType, Schema>> sortedEntries =
schemas.entrySet().stream().sorted(Map.Entry.comparingByKey(Comparator.comparing(DMNType::getName))).toList();
+ for (Entry<DMNType, Schema> kv : sortedEntries) {
SchemaWriter.writeSchema(definitions, kv.getValue(),
namingPolicy.getName(kv.getKey()));
}
jsonSchema = tree;
@@ -191,5 +195,4 @@ public class DMNOASGeneratorImpl implements DMNOASGenerator
{
}
}
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]