Skip to content

Commit 02cfe51

Browse files
committed
Clarify test
1 parent 6b549f0 commit 02cfe51

File tree

1 file changed

+25
-21
lines changed
  • src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github

1 file changed

+25
-21
lines changed
Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
package com.fasterxml.jackson.module.kotlin.test.github
22

33
import com.fasterxml.jackson.annotation.JsonProperty
4+
import com.fasterxml.jackson.databind.MapperFeature
5+
import com.fasterxml.jackson.databind.SerializationFeature
46
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
57
import kotlin.test.assertEquals
68

79
class TestGithub52 {
810
class Test(
9-
// This gets serialized as "is_lol", as expected. No issues here.
10-
@JsonProperty("is_lol")
11-
val lol: String = "sdf",
12-
13-
// This gets serialized as "bar", even though we asked for "is_bar". This is an issue.
14-
@JsonProperty("is_bar")
15-
val bar: Boolean = true,
16-
17-
@JsonProperty("is_bar2")
18-
val isBar2: Boolean = true) {
19-
20-
// This gets serialized as both "foo" and "is_foo", although we only asked for "is_foo". Also an issue.
11+
// Should only be serialized as "is_bar"
12+
@JsonProperty("is_bar")
13+
val bar: Boolean = true,
14+
15+
@JsonProperty("is_bar2")
16+
val isBar2: Boolean = true,
17+
18+
// This gets serialized as "is_lol", as expected. No issues here.
19+
@JsonProperty("is_lol")
20+
val lol: String = "sdf"
21+
) {
22+
// Should only be serialized as "is_foo"
2123
@JsonProperty("is_foo")
2224
val foo: Boolean = true
2325

@@ -28,17 +30,19 @@ class TestGithub52 {
2830
@org.junit.Test
2931
fun testGithub52() {
3032
val mapper = jacksonObjectMapper()
33+
.configure(SerializationFeature.INDENT_OUTPUT, true)
34+
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
3135

3236
val actual = mapper.writeValueAsString(Test())
33-
val expected = """{"is_lol":"sdf","is_bar":true,"is_bar2":true,"is_foo":true,"is_foo2":true}"""
34-
35-
// error
36-
// {"is_lol":"sdf",
37-
// "is_bar":true,
38-
// "bar2":true, ... should be is_bar2
39-
// "foo2":true, ... should not be here
40-
// "is_foo":true,
41-
// "is_foo2":true}
37+
val expected = """
38+
{
39+
"is_bar":true,
40+
"is_bar2":true,
41+
"is_lol":"sdf",
42+
"is_foo":true,
43+
"is_foo2":true
44+
}""".trimIndent()
45+
4246
assertEquals(expected, actual)
4347
}
4448
}

0 commit comments

Comments
 (0)