Skip to content

Commit bf2abce

Browse files
committed
Add property serialize tests
1 parent 6b8c2ec commit bf2abce

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.fasterxml.jackson.module.kotlin._integration.ser
2+
3+
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
4+
import org.junit.jupiter.api.Assertions.assertEquals
5+
import org.junit.jupiter.api.Test
6+
7+
class PropertySerializeTest {
8+
data class Src(
9+
// Serialized by property name in Kotlin even when not following getter naming conventions
10+
@get:JvmName("renamed") val fooFoo: Int,
11+
// https://github.com/FasterXML/jackson-module-kotlin/issues/600
12+
val isBar: Boolean,
13+
val bar: String,
14+
// https://github.com/FasterXML/jackson-module-kotlin/pull/451
15+
@Suppress("PropertyName") val `baz-baz`: String,
16+
// https://github.com/FasterXML/jackson-module-kotlin/issues/503
17+
val nQux: Int
18+
) {
19+
// Ignored because it is not a Kotlin property
20+
fun getZzz(): Int = -1
21+
}
22+
23+
@Test
24+
fun test() {
25+
assertEquals(
26+
"""{"fooFoo":0,"isBar":true,"bar":"bar","baz-baz":"baz-baz","nQux":1}""",
27+
jacksonObjectMapper().writeValueAsString(Src(0, true, "bar", "baz-baz", 1))
28+
)
29+
}
30+
}

0 commit comments

Comments
 (0)