diff --git a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/failing/GitHub337.kt b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/failing/GitHub337.kt new file mode 100644 index 00000000..c34c0077 --- /dev/null +++ b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/failing/GitHub337.kt @@ -0,0 +1,66 @@ +package com.fasterxml.jackson.module.kotlin.test.github.failing + +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.MapperFeature.SORT_PROPERTIES_ALPHABETICALLY +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import org.junit.Ignore +import org.junit.Test +import kotlin.test.assertEquals + +class TestGitHub337 { + private val mapper = jacksonObjectMapper() + .setSerializationInclusion(JsonInclude.Include.ALWAYS) + .configure(SORT_PROPERTIES_ALPHABETICALLY, true) + private val writer = mapper.writerWithDefaultPrettyPrinter() + + @Test + @Ignore + fun test_ClassWithIsFields() { + data class ClassWithIsFields( + val isBooleanField: Boolean, + val isIntField: Int + ) + + val problematic = ClassWithIsFields(true, 9) + val expected = """ + { + "isBooleanField" : true, + "isIntField" : 9 + }""".trimIndent() + assertEquals(expected, writer.writeValueAsString(problematic)) + } + + @Test + @Ignore + fun test_AnnotatedClassWithIsFields() { + data class ClassWithIsFields( + @JsonProperty("isBooleanField") val isBooleanField: Boolean, + @JsonProperty("isIntField") val isIntField: Int + ) + + val problematic = ClassWithIsFields(true, 9) + val expected = """ + { + "isBooleanField" : true, + "isIntField" : 9 + }""".trimIndent() + assertEquals(expected, writer.writeValueAsString(problematic)) + } + + @Test + fun test_AnnotatedGetClassWithIsFields() { + data class ClassWithIsFields( + @JsonProperty("isBooleanField") val isBooleanField: Boolean, + @get:JsonProperty("isIntField") val isIntField: Int + ) + + val problematic = ClassWithIsFields(true, 9) + val expected = """ + { + "isBooleanField" : true, + "isIntField" : 9 + }""".trimIndent() + assertEquals(expected, writer.writeValueAsString(problematic)) + } +} \ No newline at end of file