-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test for GitHub issue 337
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/failing/GitHub337.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} | ||
} |