Skip to content

Commit

Permalink
Add check for #841
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Nov 16, 2024
1 parent 9889989 commit 1c805d6
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<Foo>(serialized)

assertEquals(value, deserialized)
}
}

0 comments on commit 1c805d6

Please sign in to comment.