Skip to content

Commit

Permalink
Add check for #844
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Nov 16, 2024
1 parent aa1cb9b commit edf9592
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.fasterxml.jackson.module.kotlin.test.github

import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import kotlin.test.Test
import kotlin.test.assertEquals

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "_type")
private sealed class BaseClass

private data class ChildClass(val text: String) : BaseClass()

class GitHub844 {
@Test
fun test() {
val json = """
{
"_type": "ChildClass",
"text": "Test"
}
"""

val jacksonObjectMapper = ObjectMapper().registerKotlinModule()
val message = jacksonObjectMapper.readValue<BaseClass>(json)

assertEquals(ChildClass("Test"), message)
}
}

0 comments on commit edf9592

Please sign in to comment.