From 1c805d6ac8d432824dc2c3c754e3055b6cfe8dd6 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 16 Nov 2024 09:26:24 +0900 Subject: [PATCH] Add check for #841 --- .../module/kotlin/test/github/GitHub841.kt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/GitHub841.kt diff --git a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/GitHub841.kt b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/GitHub841.kt new file mode 100644 index 00000000..0bb0ec51 --- /dev/null +++ b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/GitHub841.kt @@ -0,0 +1,34 @@ +package com.fasterxml.jackson.module.kotlin.test.github + +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonInclude +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 + +class GitHub841 { + object Foo { + override fun toString(): String = "Foo()" + + @JvmStatic + @JsonCreator + fun deserialize(): Foo { + return Foo + } + } + + private val mapper = ObjectMapper() + .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) + .registerKotlinModule() + + @Test + fun shouldDeserializeSimpleObject() { + val value = Foo + val serialized = mapper.writeValueAsString(value) + val deserialized = mapper.readValue(serialized) + + assertEquals(value, deserialized) + } +}