Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[kie-issues#843] Generate reproducible dmndefinitions.json. #5676

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -44,6 +34,17 @@
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;
Expand Down Expand Up @@ -81,7 +82,10 @@ private void prepareSerializaton() {
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) {
baldimir marked this conversation as resolved.
Show resolved Hide resolved
SchemaWriter.writeSchema(definitions, kv.getValue(), namingPolicy.getName(kv.getKey()));
}
jsonSchema = tree;
Expand Down Expand Up @@ -191,5 +195,4 @@ private void visitForIndexing(DMNType idnType) {
}
}
}

}
Loading