Skip to content

Commit fd61ca8

Browse files
committed
Added serialization test for value class that wraps Map
from FasterXML/jackson-module-kotlin#904
1 parent 50eabca commit fd61ca8

File tree

1 file changed

+45
-0
lines changed
  • src/test/kotlin/io/github/projectmapk/jackson/module/kogera/zPorted/test/github

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package io.github.projectmapk.jackson.module.kogera.zPorted.test.github
2+
3+
import io.github.projectmapk.jackson.module.kogera.readValue
4+
import io.github.projectmapk.jackson.module.kogera.defaultMapper
5+
import org.junit.jupiter.api.Test
6+
7+
class GitHub873 {
8+
@Test
9+
fun `should serialize value class`() {
10+
11+
val person = Person(
12+
mapOf(
13+
"id" to "123",
14+
"updated" to "2023-11-22 12:11:23",
15+
"login" to "2024-01-15",
16+
),
17+
)
18+
19+
val serialized = defaultMapper.writeValueAsString(
20+
TimestampedPerson(
21+
123L,
22+
Person(person.properties),
23+
)
24+
)
25+
26+
val deserialized = defaultMapper.readValue<TimestampedPerson>(serialized)
27+
28+
assert(
29+
deserialized == TimestampedPerson(
30+
123L,
31+
Person(person.properties),
32+
)
33+
)
34+
}
35+
36+
@JvmInline
37+
value class Person(
38+
val properties: Map<String, Any>,
39+
)
40+
41+
data class TimestampedPerson(
42+
val timestamp: Long,
43+
val person: Person,
44+
)
45+
}

0 commit comments

Comments
 (0)