File tree 1 file changed +35
-0
lines changed
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/failing
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.fasterxml.jackson.module.kotlin.test.failing
2
+
3
+ import com.fasterxml.jackson.annotation.JsonSubTypes
4
+ import com.fasterxml.jackson.annotation.JsonSubTypes.Type
5
+ import com.fasterxml.jackson.annotation.JsonTypeInfo
6
+ import com.fasterxml.jackson.annotation.JsonTypeInfo.As
7
+ import com.fasterxml.jackson.annotation.JsonTypeInfo.Id
8
+ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
9
+ import com.fasterxml.jackson.module.kotlin.readValue
10
+ import org.junit.Test
11
+ import kotlin.test.assertNull
12
+
13
+ class Github335Test {
14
+ val mapper = jacksonObjectMapper()
15
+
16
+ interface Payload
17
+ data class UniquePayload (val data : String ) : Payload
18
+
19
+ data class MyEntity (
20
+ val type : String? ,
21
+ @JsonTypeInfo(use = Id .NAME , include = As .EXTERNAL_PROPERTY , property = " type" )
22
+ @JsonSubTypes(Type (value = UniquePayload ::class , name = " UniquePayload" ))
23
+ val payload : Payload ?
24
+ )
25
+
26
+ @Test
27
+ fun serializeAndDeserializeTypeable () {
28
+ val oldEntity = MyEntity (null , null )
29
+ val json = mapper.writeValueAsString(oldEntity)
30
+ val newEntity = mapper.readValue<MyEntity >(json)
31
+
32
+ // Returns false: "null" String instead of null
33
+ assertNull(newEntity.type)
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments