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

Fix GraphMetadata serialization: attributes' order #659

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.powsybl.commons.json.JsonUtil;
Expand All @@ -32,6 +33,11 @@
public class GraphMetadata extends AbstractMetadata {

@JsonInclude(JsonInclude.Include.NON_NULL)
// On some systems, the export order is determined by the order of the 1st encountered JsonCreator's attributes
// and "unescapedId" is put in last place. But on other systems, the export order is determined by the getters' order
// and "unescapedId" is put in 1st place, which leads to comparison errors in the unit tests.
// To prevent this discrepancy, the order is manually fixed.
@JsonPropertyOrder(value = {"unescapedId", "id", "vid", "nextVId", "componentType", "open", "direction", "vlabel", "equipmentId", "labels"})
public static class NodeMetadata {

private final String unescapedId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"positionName" : "NW_LABEL"
} ]
}, {
"unescapedId" : "LCC_1",
"id" : "idLCC_95_1",
"vid" : "VoltageLevel1",
"nextVId" : "VoltageLevel2",
Expand All @@ -134,8 +135,7 @@
"labels" : [ {
"id" : "LCC_1_S_LABEL",
"positionName" : "S_LABEL"
} ],
"unescapedId" : "LCC_1"
} ]
}, {
"id" : "LABEL_VL_VoltageLevel1",
"vid" : "VoltageLevel1",
Expand Down Expand Up @@ -164,6 +164,7 @@
"vlabel" : false,
"labels" : [ ]
}, {
"unescapedId" : "VSC_1",
"id" : "idVSC_95_1",
"vid" : "VoltageLevel1",
"nextVId" : "VoltageLevel2",
Expand All @@ -175,8 +176,7 @@
"labels" : [ {
"id" : "VSC_1_N_LABEL",
"positionName" : "N_LABEL"
} ],
"unescapedId" : "VSC_1"
} ]
}, {
"id" : "idBUSCO_95_Bus1_95_VSC_95_1",
"vid" : "VoltageLevel1",
Expand Down