Skip to content

Commit 8eb81c1

Browse files
committed
update test case for #269 to cover another case from the issue report.
1 parent 1c2c0ca commit 8eb81c1

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,7 @@
11
package com.fasterxml.jackson.module.kotlin.test.github
22

3+
import com.fasterxml.jackson.databind.annotation.JsonSerialize
4+
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer
35
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
46
import com.fasterxml.jackson.module.kotlin.readValue
57
import org.junit.Test
@@ -9,6 +11,13 @@ class TestGithub269 {
911
data class Foo(val pattern: Regex)
1012
data class Bar(val thing: Regex)
1113

14+
data class Goo(
15+
@JsonSerialize(using = ToStringSerializer::class)
16+
val myPattern: Regex
17+
) {
18+
constructor(strPattern: String) : this(Regex(strPattern))
19+
}
20+
1221
@Test
1322
fun testGithub269WithFoo() {
1423
val mapper = jacksonObjectMapper()
@@ -36,4 +45,15 @@ class TestGithub269 {
3645

3746
mapper.readValue<Bar>("""{"thing":"test"}""")
3847
}
48+
49+
@Test
50+
fun testGithub269WithGoo() {
51+
val mapper = jacksonObjectMapper()
52+
53+
val testObject = Goo(Regex("test_pattern_1"))
54+
val testJson = mapper.writeValueAsString(testObject)
55+
val resultObject = mapper.readValue<Goo>(testJson)
56+
57+
assertEquals(testObject.myPattern.pattern, resultObject.myPattern.pattern)
58+
}
3959
}

0 commit comments

Comments
 (0)