Skip to content

Commit 00461d2

Browse files
committed
Update test cases for #269 to cover more items noted in the issue report
1 parent 8eb81c1 commit 00461d2

File tree

1 file changed

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

1 file changed

+20
-0
lines changed

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github269.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.fasterxml.jackson.module.kotlin.test.github
22

3+
import com.fasterxml.jackson.annotation.JsonCreator
34
import com.fasterxml.jackson.databind.annotation.JsonSerialize
45
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer
56
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
@@ -18,6 +19,14 @@ class TestGithub269 {
1819
constructor(strPattern: String) : this(Regex(strPattern))
1920
}
2021

22+
data class Zoo(
23+
@JsonSerialize(using = ToStringSerializer::class)
24+
val myPattern: Regex
25+
) {
26+
@JsonCreator
27+
constructor(strPattern: String) : this(Regex(strPattern))
28+
}
29+
2130
@Test
2231
fun testGithub269WithFoo() {
2332
val mapper = jacksonObjectMapper()
@@ -56,4 +65,15 @@ class TestGithub269 {
5665

5766
assertEquals(testObject.myPattern.pattern, resultObject.myPattern.pattern)
5867
}
68+
69+
@Test
70+
fun testGithub269WithZoo() {
71+
val mapper = jacksonObjectMapper()
72+
73+
val testObject = Zoo(Regex("test_pattern_1"))
74+
val testJson = mapper.writeValueAsString(testObject)
75+
val resultObject = mapper.readValue<Zoo>(testJson)
76+
77+
assertEquals(testObject.myPattern.pattern, resultObject.myPattern.pattern)
78+
}
5979
}

0 commit comments

Comments
 (0)