Skip to content

Commit

Permalink
Add failing test for GitHub issue 337
Browse files Browse the repository at this point in the history
  • Loading branch information
dinomite committed Mar 6, 2021
1 parent 00f8432 commit dd047d6
Showing 1 changed file with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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))
}
}

0 comments on commit dd047d6

Please sign in to comment.