From d7983a5aea73e01da35d96b0fa5ddba7d83a168b Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sun, 24 Nov 2024 01:47:12 +0900 Subject: [PATCH] Porting check for #841 https://github.com/FasterXML/jackson-module-kotlin/pull/850 --- .../kogera/zPorted/test/github/GitHub841.kt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/kotlin/io/github/projectmapk/jackson/module/kogera/zPorted/test/github/GitHub841.kt diff --git a/src/test/kotlin/io/github/projectmapk/jackson/module/kogera/zPorted/test/github/GitHub841.kt b/src/test/kotlin/io/github/projectmapk/jackson/module/kogera/zPorted/test/github/GitHub841.kt new file mode 100644 index 0000000..75a7640 --- /dev/null +++ b/src/test/kotlin/io/github/projectmapk/jackson/module/kogera/zPorted/test/github/GitHub841.kt @@ -0,0 +1,34 @@ +package io.github.projectmapk.jackson.module.kogera.zPorted.test.github + +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.databind.ObjectMapper +import io.github.projectmapk.jackson.module.kogera.readValue +import io.github.projectmapk.jackson.module.kogera.registerKotlinModule +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test + +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) + } +}