File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
src/test/kotlin/io/github/projectmapk/jackson/module/kogera/zPorted/test/github Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ package io.github.projectmapk.jackson.module.kogera.zPorted.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 io.github.projectmapk.jackson.module.kogera.jacksonObjectMapper
8+ import io.github.projectmapk.jackson.module.kogera.readValue
9+ import org.junit.jupiter.api.Assertions.assertEquals
10+ import org.junit.jupiter.api.Test
11+ import org.junit.jupiter.api.assertThrows
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