Skip to content

Commit b2ca809

Browse files
Update to move away from deprecated methods (#91)
1 parent 377e8c4 commit b2ca809

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

src/test/java/org/openapitools/jackson/nullable/JsonNullableBasicTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static class Container {
5252
public static interface Contained { }
5353

5454
public static class ContainedImpl implements Contained { }
55-
55+
5656
/*
5757
/**********************************************************
5858
/* Test methods
@@ -157,7 +157,7 @@ void testSerGeneric() throws Exception {
157157
void testSerOptDefault() throws Exception {
158158
JsonNullableData data = new JsonNullableData();
159159
data.myString = JsonNullable.undefined();
160-
String value = mapperWithModule().setSerializationInclusion(
160+
String value = mapperWithModule().setDefaultPropertyInclusion(
161161
JsonInclude.Include.ALWAYS).writeValueAsString(data);
162162
assertEquals("{}", value);
163163
}
@@ -166,7 +166,7 @@ void testSerOptDefault() throws Exception {
166166
void testSerOptNull() throws Exception {
167167
JsonNullableData data = new JsonNullableData();
168168
data.myString = null;
169-
String value = mapperWithModule().setSerializationInclusion(
169+
String value = mapperWithModule().setDefaultPropertyInclusion(
170170
JsonInclude.Include.NON_NULL).writeValueAsString(data);
171171
assertEquals("{}", value);
172172
}
@@ -175,7 +175,7 @@ void testSerOptNull() throws Exception {
175175
void testSerOptNullNulled() throws Exception {
176176
JsonNullableData data = new JsonNullableData();
177177
data.myString = JsonNullable.of(null);
178-
String value = mapperWithModule().setSerializationInclusion(
178+
String value = mapperWithModule().setDefaultPropertyInclusion(
179179
JsonInclude.Include.NON_NULL).writeValueAsString(data);
180180
assertEquals("{\"myString\":null}", value);
181181
}
@@ -186,26 +186,26 @@ void testSerOptAbsent() throws Exception {
186186
data.myString = JsonNullable.undefined();
187187

188188
ObjectMapper mapper = mapperWithModule()
189-
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
189+
.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL);
190190

191191
assertEquals("{}", mapper.writeValueAsString(data));
192192

193193
// but do exclude with NON_EMPTY
194194
mapper = mapperWithModule()
195-
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
195+
.setDefaultPropertyInclusion(JsonInclude.Include.NON_EMPTY);
196196
assertEquals("{}", mapper.writeValueAsString(data));
197197

198198
// and with new (2.6) NON_ABSENT
199199
mapper = mapperWithModule()
200-
.setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
200+
.setDefaultPropertyInclusion(JsonInclude.Include.NON_ABSENT);
201201
assertEquals("{}", mapper.writeValueAsString(data));
202202
}
203203

204204
@Test
205205
void testSerOptAbsentNull() throws Exception {
206206
JsonNullableData data = new JsonNullableData();
207207
data.myString = JsonNullable.of(null);
208-
String value = mapperWithModule().setSerializationInclusion(
208+
String value = mapperWithModule().setDefaultPropertyInclusion(
209209
JsonInclude.Include.NON_ABSENT).writeValueAsString(data);
210210
assertEquals("{\"myString\":null}", value);
211211
}
@@ -214,7 +214,7 @@ void testSerOptAbsentNull() throws Exception {
214214
void testSerOptNonEmpty() throws Exception {
215215
JsonNullableData data = new JsonNullableData();
216216
data.myString = null;
217-
String value = mapperWithModule().setSerializationInclusion(
217+
String value = mapperWithModule().setDefaultPropertyInclusion(
218218
JsonInclude.Include.NON_EMPTY).writeValueAsString(data);
219219
assertEquals("{}", value);
220220
}
@@ -224,7 +224,7 @@ void testWithTypingEnabled() throws Exception {
224224
final ObjectMapper objectMapper = mapperWithModule();
225225
// ENABLE TYPING
226226
objectMapper
227-
.enableDefaultTyping(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE);
227+
.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(), ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE);
228228

229229
final JsonNullableData myData = new JsonNullableData();
230230
myData.myString = JsonNullable.of("abc");
@@ -287,4 +287,4 @@ void testPolymorphic() throws Exception {
287287
assertTrue(fromJson.contained.isPresent());
288288
assertSame(ContainedImpl.class, fromJson.contained.get().getClass());
289289
}
290-
}
290+
}

src/test/java/org/openapitools/jackson/nullable/JsonNullableInclusionTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public OptMapBean(String key, JsonNullable<?> v) {
6060
void testSerOptNonEmpty() throws Exception {
6161
JsonNullableData data = new JsonNullableData();
6262
data.myString = null;
63-
String value = mapperWithModule().setSerializationInclusion(
63+
String value = mapperWithModule().setDefaultPropertyInclusion(
6464
JsonInclude.Include.NON_EMPTY).writeValueAsString(data);
6565
assertEquals("{}", value);
6666
}
@@ -69,7 +69,7 @@ void testSerOptNonEmpty() throws Exception {
6969
void testSerOptNonDefault() throws Exception {
7070
JsonNullableData data = new JsonNullableData();
7171
data.myString = null;
72-
String value = mapperWithModule().setSerializationInclusion(
72+
String value = mapperWithModule().setDefaultPropertyInclusion(
7373
JsonInclude.Include.NON_DEFAULT).writeValueAsString(data);
7474
assertEquals("{}", value);
7575
}
@@ -78,7 +78,7 @@ void testSerOptNonDefault() throws Exception {
7878
void testSerOptNonAbsent() throws Exception {
7979
JsonNullableData data = new JsonNullableData();
8080
data.myString = null;
81-
String value = mapperWithModule().setSerializationInclusion(
81+
String value = mapperWithModule().setDefaultPropertyInclusion(
8282
JsonInclude.Include.NON_ABSENT).writeValueAsString(data);
8383
assertEquals("{}", value);
8484
}
@@ -143,4 +143,4 @@ void testMapElementInclusion() throws Exception {
143143
assertEquals("{\"values\":{\"key\":\"\"}}",
144144
mapper.writeValueAsString(new OptMapBean("key", JsonNullable.of(""))));
145145
}
146-
}
146+
}

src/test/java/org/openapitools/jackson/nullable/JsonNullableSimpleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void serializeAlways() throws JsonProcessingException {
100100

101101
@Test
102102
void serializeNonNull() throws JsonProcessingException {
103-
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
103+
mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL);
104104
assertEquals("{}", mapper.writeValueAsString(new Pet().name(JsonNullable.<String>undefined())));
105105
assertEquals("{}", mapper.writeValueAsString(new Pet().name(null)));
106106
assertEquals("{\"name\":null}", mapper.writeValueAsString(new Pet().name(JsonNullable.<String>of(null))));
@@ -109,7 +109,7 @@ void serializeNonNull() throws JsonProcessingException {
109109

110110
@Test
111111
void serializeNonAbsent() throws JsonProcessingException {
112-
mapper.setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
112+
mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_ABSENT);
113113
assertEquals("{}", mapper.writeValueAsString(new Pet().name(JsonNullable.<String>undefined())));
114114
assertEquals("{}", mapper.writeValueAsString(new Pet().name(null)));
115115
assertEquals("{\"name\":null}", mapper.writeValueAsString(new Pet().name(JsonNullable.<String>of(null))));

src/test/java/org/openapitools/jackson/nullable/JsonNullableTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void testJsonNullableStringInBean() throws Exception {
194194
@Test
195195
void testExcludeIfJsonNullableAbsent() throws Exception {
196196
ObjectMapper mapper = mapperWithModule()
197-
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
197+
.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL);
198198
assertEquals(aposToQuotes("{'value':'foo'}"),
199199
mapper.writeValueAsString(new JsonNullableStringBean("foo")));
200200
// absent is not strictly null so
@@ -203,7 +203,7 @@ void testExcludeIfJsonNullableAbsent() throws Exception {
203203

204204
// however:
205205
mapper = mapperWithModule()
206-
.setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
206+
.setDefaultPropertyInclusion(JsonInclude.Include.NON_ABSENT);
207207
assertEquals(aposToQuotes("{'value':'foo'}"),
208208
mapper.writeValueAsString(new JsonNullableStringBean("foo")));
209209
assertEquals(aposToQuotes("{\"value\":null}"),
@@ -241,7 +241,7 @@ void testCustomSerializer() throws Exception {
241241
@Test
242242
void testCustomSerializerIfJsonNullableAbsent() throws Exception {
243243
ObjectMapper mapper = mapperWithModule()
244-
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
244+
.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL);
245245
assertEquals(aposToQuotes("{'value':'FOO'}"),
246246
mapper.writeValueAsString(new CaseChangingStringWrapper("foo")));
247247
// absent is not strictly null so
@@ -252,7 +252,7 @@ void testCustomSerializerIfJsonNullableAbsent() throws Exception {
252252

253253
// however:
254254
mapper = mapperWithModule()
255-
.setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
255+
.setDefaultPropertyInclusion(JsonInclude.Include.NON_ABSENT);
256256
assertEquals(aposToQuotes("{'value':'FOO'}"),
257257
mapper.writeValueAsString(new CaseChangingStringWrapper("foo")));
258258
assertEquals(aposToQuotes("{'value':null}"),
@@ -278,4 +278,4 @@ private <T> JsonNullable<T> roundtrip(JsonNullable<T> obj, TypeReference<JsonNul
278278
String bytes = MAPPER.writeValueAsString(obj);
279279
return MAPPER.readValue(bytes, type);
280280
}
281-
}
281+
}

0 commit comments

Comments
 (0)