|
29 | 29 | import com.fasterxml.jackson.annotation.JsonInclude; |
30 | 30 | import com.fasterxml.jackson.core.JsonProcessingException; |
31 | 31 | import com.fasterxml.jackson.databind.MapperFeature; |
32 | | -import com.fasterxml.jackson.databind.ObjectMapper; |
33 | 32 | import com.fasterxml.jackson.databind.json.JsonMapper; |
34 | 33 | import com.fasterxml.jackson.databind.module.SimpleModule; |
35 | 34 | import com.fasterxml.jackson.databind.type.TypeFactory; |
@@ -67,9 +66,12 @@ void polymorphicScore() { |
67 | 66 |
|
68 | 67 | @Test |
69 | 68 | void scoreAnalysisWithoutMatches() throws JsonProcessingException { |
70 | | - var objectMapper = new ObjectMapper(); |
71 | | - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); |
72 | | - objectMapper.registerModule(TimefoldJacksonModule.createModule()); |
| 69 | + var objectMapper = JsonMapper.builder() |
| 70 | + .enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY) |
| 71 | + .defaultPropertyInclusion( |
| 72 | + JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL)) |
| 73 | + .addModule(TimefoldJacksonModule.createModule()) |
| 74 | + .build(); |
73 | 75 |
|
74 | 76 | var constraintRef1 = ConstraintRef.of("constraint1"); |
75 | 77 | var constraintRef2 = ConstraintRef.of("constraint2"); |
@@ -107,9 +109,12 @@ void scoreAnalysisWithoutMatches() throws JsonProcessingException { |
107 | 109 |
|
108 | 110 | @Test |
109 | 111 | void scoreAnalysisWithMatches() throws JsonProcessingException { |
110 | | - var objectMapper = new ObjectMapper(); |
111 | | - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); |
112 | | - objectMapper.registerModule(TimefoldJacksonModule.createModule()); |
| 112 | + var objectMapper = JsonMapper.builder() |
| 113 | + .enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY) |
| 114 | + .defaultPropertyInclusion( |
| 115 | + JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL)) |
| 116 | + .addModule(TimefoldJacksonModule.createModule()) |
| 117 | + .build(); |
113 | 118 |
|
114 | 119 | var originalScoreAnalysis = getScoreAnalysis(); |
115 | 120 | var serialized = objectMapper.writeValueAsString(originalScoreAnalysis); |
@@ -179,9 +184,12 @@ private static String getSerializedScoreAnalysis() { |
179 | 184 |
|
180 | 185 | @Test |
181 | 186 | void recommendedAssignment() throws JsonProcessingException { |
182 | | - var objectMapper = new ObjectMapper(); |
183 | | - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); |
184 | | - objectMapper.registerModule(TimefoldJacksonModule.createModule()); |
| 187 | + var objectMapper = JsonMapper.builder() |
| 188 | + .enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY) |
| 189 | + .defaultPropertyInclusion( |
| 190 | + JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL)) |
| 191 | + .addModule(TimefoldJacksonModule.createModule()) |
| 192 | + .build(); |
185 | 193 |
|
186 | 194 | var proposition = new Pair<>("A", "1"); |
187 | 195 | var originalScoreAnalysis = getScoreAnalysis(); |
@@ -211,9 +219,12 @@ void recommendedAssignment() throws JsonProcessingException { |
211 | 219 |
|
212 | 220 | @Test |
213 | 221 | void constraintWeightOverrides() throws JsonProcessingException { |
214 | | - var objectMapper = new ObjectMapper(); |
215 | | - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); |
216 | | - objectMapper.registerModule(TimefoldJacksonModule.createModule()); |
| 222 | + var objectMapper = JsonMapper.builder() |
| 223 | + .enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY) |
| 224 | + .defaultPropertyInclusion( |
| 225 | + JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL)) |
| 226 | + .addModule(TimefoldJacksonModule.createModule()) |
| 227 | + .build(); |
217 | 228 |
|
218 | 229 | var constraintWeightOverrides = ConstraintWeightOverrides.of( |
219 | 230 | Map.of( |
|
0 commit comments