-
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 remote-tracking branch 'FasterXML/2.19'
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/test/kotlin/tools/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,29 @@ | ||
package tools.jackson.module.kotlin.test.github | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo | ||
import tools.jackson.module.kotlin.readValue | ||
import tools.jackson.module.kotlin.jsonMapper | ||
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 = jsonMapper() | ||
val message = jacksonObjectMapper.readValue<BaseClass>(json) | ||
|
||
assertEquals(ChildClass("Test"), message) | ||
} | ||
} |