-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #855 from k163377/844
Add check for #844
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/GitHub844.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |