@@ -7,39 +7,61 @@ import org.hamcrest.CoreMatchers
7
7
import org.hamcrest.MatcherAssert.assertThat
8
8
import org.junit.Test
9
9
10
- class Github490 {
10
+ class TestGithub490 {
11
+ val mapper = jacksonObjectMapper()
12
+ val value: DataClassWithAllNullableParams = mapper.readValue(
13
+ " {" +
14
+ " \" jsonNodeValueWithNullAsDefaultProvidedNull\" :null, " +
15
+ " \" jsonNodeValueProvidedNull\" :null}"
16
+ )
11
17
12
18
@Test
13
- fun testKotlinDeserialization () {
14
- val mapper = jacksonObjectMapper()
15
- val value: DataClassWithAllNullableParams = mapper.readValue(" {" +
16
- " \" jsonNodeValueWithNullAsDefaultProvidedNull\" :null, " +
17
- " \" jsonNodeValueProvidedNull\" :null}" )
19
+ fun testKotlinDeserialization_intValue () {
18
20
assertThat(
19
21
" Nullable missing Int value should be deserialized as null" ,
20
22
value.intValue,
21
23
CoreMatchers .nullValue()
22
24
)
25
+ }
26
+
27
+ @Test
28
+ fun testKotlinDeserialization_stringValue () {
23
29
assertThat(
24
30
" Nullable missing String value should be deserialized as null" ,
25
31
value.stringValue,
26
32
CoreMatchers .nullValue()
27
33
)
34
+ }
35
+
36
+ @Test
37
+ fun testKotlinDeserialization_jsonNodeValue () {
28
38
assertThat(
29
39
" Nullable missing JsonNode value should be deserialized as null and not as NullNode" ,
30
40
value.jsonNodeValue,
31
41
CoreMatchers .nullValue()
32
42
)
43
+ }
44
+
45
+ @Test
46
+ fun testKotlinDeserialization_jsonNodeValueProvidedNull () {
33
47
assertThat(
34
- " Nullable missing JsonNode value should be deserialized as null and not as NullNode" ,
48
+ " Nullable JsonNode value provided as null should be deserialized as null and not as NullNode" ,
35
49
value.jsonNodeValueProvidedNull,
36
50
CoreMatchers .nullValue()
37
51
)
52
+ }
53
+
54
+ @Test
55
+ fun testKotlinDeserialization_jsonNodeValueWithNullAsDefault () {
38
56
assertThat(
39
57
" Nullable by default missing JsonNode value should be deserialized as null and not as NullNode" ,
40
58
value.jsonNodeValueWithNullAsDefault,
41
59
CoreMatchers .nullValue()
42
60
)
61
+ }
62
+
63
+ @Test
64
+ fun testKotlinDeserialization_jsonNodeValueWithNullAsDefaultProvidedNull () {
43
65
assertThat(
44
66
" Nullable by default JsonNode with provided null value in payload should be deserialized as null and not as NullNode" ,
45
67
value.jsonNodeValueWithNullAsDefaultProvidedNull,
@@ -55,4 +77,4 @@ data class DataClassWithAllNullableParams(
55
77
val jsonNodeValueProvidedNull : JsonNode ? ,
56
78
val jsonNodeValueWithNullAsDefault : JsonNode ? = null ,
57
79
val jsonNodeValueWithNullAsDefaultProvidedNull : JsonNode ? = null
58
- )
80
+ )
0 commit comments