File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
src/test/kotlin/io/github/projectmapk/jackson/module/kogera/zPorted/test/github Expand file tree Collapse file tree 1 file changed +30
-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.JsonTypeInfo
4+ import com.fasterxml.jackson.databind.ObjectMapper
5+ import io.github.projectmapk.jackson.module.kogera.readValue
6+ import io.github.projectmapk.jackson.module.kogera.registerKotlinModule
7+ import org.junit.jupiter.api.Assertions.assertEquals
8+ import org.junit.jupiter.api.Test
9+
10+ @JsonTypeInfo(use = JsonTypeInfo .Id .NAME , property = " _type" )
11+ private sealed class BaseClass
12+
13+ private data class ChildClass (val text : String ) : BaseClass()
14+
15+ class GitHub844 {
16+ @Test
17+ fun test () {
18+ val json = """
19+ {
20+ "_type": "ChildClass",
21+ "text": "Test"
22+ }
23+ """
24+
25+ val jacksonObjectMapper = ObjectMapper ().registerKotlinModule()
26+ val message = jacksonObjectMapper.readValue<BaseClass >(json)
27+
28+ assertEquals(ChildClass (" Test" ), message)
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments