Skip to content

Commit

Permalink
Merge pull request #855 from k163377/844
Browse files Browse the repository at this point in the history
Add check for #844
  • Loading branch information
k163377 authored Nov 16, 2024
2 parents aa1cb9b + edf9592 commit 779cf85
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 779cf85

Please sign in to comment.