File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ Tatu Saloranta (@cowtowncoder)
21
21
* #889 : Upgrade kotlin dep to 1.9.25 (from 1.9.24)
22
22
23
23
WrongWrong (@k163377 )
24
+ * #930 : Add tests for #917
24
25
* #929 : Bug fixes to hasRequiredMarker and added isRequired considerations
25
26
* #914 : Add test case to serialize Nothing? (for #314)
26
27
* #910 : Add default KeyDeserializer for value class
Original file line number Diff line number Diff line change
1
+ package com.fasterxml.jackson.module.kotlin.test.github
2
+
3
+ import com.fasterxml.jackson.annotation.JsonInclude
4
+ import com.fasterxml.jackson.annotation.JsonProperty
5
+ import com.fasterxml.jackson.annotation.OptBoolean
6
+ import com.fasterxml.jackson.databind.exc.InvalidNullException
7
+ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
8
+ import com.fasterxml.jackson.module.kotlin.readValue
9
+ import org.junit.jupiter.api.Test
10
+ import org.junit.jupiter.api.assertThrows
11
+ import kotlin.test.assertEquals
12
+
13
+ class GitHub917 {
14
+ data class Failing <T >(val data : T )
15
+
16
+ val mapper = jacksonObjectMapper().setSerializationInclusion(JsonInclude .Include .NON_NULL )
17
+
18
+ @Test
19
+ fun failing () {
20
+ val value = Failing <String ?>(null )
21
+ val json = mapper.writeValueAsString(value)
22
+
23
+ assertThrows<InvalidNullException > {
24
+ val deserializedValue = mapper.readValue<Failing <String ?>>(json)
25
+ assertEquals(value ,deserializedValue)
26
+ }
27
+ }
28
+
29
+ data class WorkAround <T >(@JsonProperty(isRequired = OptBoolean .FALSE ) val data : T )
30
+
31
+ @Test
32
+ fun workAround () {
33
+ val value = WorkAround <String ?>(null )
34
+ val json = mapper.writeValueAsString(value)
35
+
36
+ val deserializedValue = mapper.readValue<WorkAround <String ?>>(json)
37
+ assertEquals(value ,deserializedValue)
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments