@@ -12,7 +12,9 @@ class Github490 {
12
12
@Test
13
13
fun testKotlinDeserialization () {
14
14
val mapper = jacksonObjectMapper()
15
- val value: DataClassWithAllNullableParams = mapper.readValue(" {}" )
15
+ val value: DataClassWithAllNullableParams = mapper.readValue(" {" +
16
+ " \" jsonNodeValueWithNullAsDefaultProvidedNull\" :null, " +
17
+ " \" jsonNodeValueProvidedNull\" :null}" )
16
18
assertThat(
17
19
" Nullable missing Int value should be deserialized as null" ,
18
20
value.intValue,
@@ -28,7 +30,29 @@ class Github490 {
28
30
value.jsonNodeValue,
29
31
CoreMatchers .nullValue()
30
32
)
33
+ assertThat(
34
+ " Nullable missing JsonNode value should be deserialized as null and not as NullNode" ,
35
+ value.jsonNodeValueProvidedNull,
36
+ CoreMatchers .nullValue()
37
+ )
38
+ assertThat(
39
+ " Nullable by default missing JsonNode value should be deserialized as null and not as NullNode" ,
40
+ value.jsonNodeValueWithNullAsDefault,
41
+ CoreMatchers .nullValue()
42
+ )
43
+ assertThat(
44
+ " Nullable by default JsonNode with provided null value in payload should be deserialized as null and not as NullNode" ,
45
+ value.jsonNodeValueWithNullAsDefaultProvidedNull,
46
+ CoreMatchers .nullValue()
47
+ )
31
48
}
32
49
}
33
50
34
- data class DataClassWithAllNullableParams (val intValue : Int? , val stringValue : String? , val jsonNodeValue : JsonNode ? )
51
+ data class DataClassWithAllNullableParams (
52
+ val intValue : Int? ,
53
+ val stringValue : String? ,
54
+ val jsonNodeValue : JsonNode ? ,
55
+ val jsonNodeValueProvidedNull : JsonNode ? ,
56
+ val jsonNodeValueWithNullAsDefault : JsonNode ? = null ,
57
+ val jsonNodeValueWithNullAsDefaultProvidedNull : JsonNode ? = null
58
+ )
0 commit comments