6
6
import com .fasterxml .jackson .databind .JavaType ;
7
7
import com .fasterxml .jackson .databind .MapperFeature ;
8
8
import com .fasterxml .jackson .databind .ObjectMapper ;
9
+ import com .fasterxml .jackson .databind .json .JsonMapper ;
9
10
import com .fasterxml .jackson .databind .ser .FilterProvider ;
10
11
import com .fasterxml .jackson .databind .ser .impl .SimpleBeanPropertyFilter ;
11
12
import com .fasterxml .jackson .databind .ser .impl .SimpleFilterProvider ;
@@ -132,8 +133,13 @@ public void setProperty2(String property2) {
132
133
/**********************************************************
133
134
*/
134
135
135
- private final ObjectMapper MAPPER = new ObjectMapper ();
136
+ private final ObjectMapper MAPPER = objectMapper ();
136
137
138
+ private final ObjectMapper SORTED_MAPPER = JsonMapper .builder ()
139
+ .enable (MapperFeature .SORT_PROPERTIES_ALPHABETICALLY )
140
+ .build ();
141
+
142
+
137
143
/**
138
144
* Test simple generation
139
145
*/
@@ -275,8 +281,7 @@ public void testSimpleMap() throws Exception {
275
281
}
276
282
277
283
public void testSinglePropertyDependency () throws Exception {
278
- ObjectMapper mapper = new ObjectMapper ();
279
- mapper .configure (MapperFeature .SORT_PROPERTIES_ALPHABETICALLY , true );
284
+ final ObjectMapper mapper = SORTED_MAPPER ;
280
285
JsonSchemaGenerator generator = new JsonSchemaGenerator (mapper );
281
286
JsonSchema jsonSchema = generator .generateSchema (SimpleBean .class );
282
287
((ObjectSchema ) jsonSchema ).addSimpleDependency ("property1" , "property2" );
@@ -296,8 +301,7 @@ public void testSinglePropertyDependency() throws Exception {
296
301
}
297
302
298
303
public void testMultiplePropertyDependencies () throws Exception {
299
- ObjectMapper mapper = new ObjectMapper ();
300
- mapper .configure (MapperFeature .SORT_PROPERTIES_ALPHABETICALLY , true );
304
+ final ObjectMapper mapper = SORTED_MAPPER ;
301
305
JsonSchemaGenerator generator = new JsonSchemaGenerator (mapper );
302
306
JsonSchema jsonSchema = generator .generateSchema (SimpleBean .class );
303
307
((ObjectSchema ) jsonSchema ).addSimpleDependency ("property1" , "property2" );
@@ -320,8 +324,7 @@ public void testMultiplePropertyDependencies() throws Exception {
320
324
}
321
325
322
326
public void testSchemaPropertyDependency () throws Exception {
323
- ObjectMapper mapper = new ObjectMapper ();
324
- mapper .configure (MapperFeature .SORT_PROPERTIES_ALPHABETICALLY , true );
327
+ final ObjectMapper mapper = SORTED_MAPPER ;
325
328
JsonSchemaGenerator generator = new JsonSchemaGenerator (mapper );
326
329
327
330
// Given this dependency schema
@@ -347,8 +350,7 @@ public void testSchemaPropertyDependency() throws Exception {
347
350
}
348
351
349
352
public void testSchemaPropertyDependencies () throws Exception {
350
- ObjectMapper mapper = new ObjectMapper ();
351
- mapper .configure (MapperFeature .SORT_PROPERTIES_ALPHABETICALLY , true );
353
+ final ObjectMapper mapper = SORTED_MAPPER ;
352
354
JsonSchemaGenerator generator = new JsonSchemaGenerator (mapper );
353
355
354
356
// Given this dependency schema
0 commit comments