Skip to content

Commit f6479ca

Browse files
committedFeb 2, 2025
Add test for #873
1 parent 3f117c3 commit f6479ca

File tree

1 file changed

+46
-0
lines changed
  • src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github

1 file changed

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

0 commit comments

Comments
 (0)
Please sign in to comment.