File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com.fasterxml.jackson.module.kotlin.test.github
2
2
3
+ import com.fasterxml.jackson.databind.annotation.JsonSerialize
4
+ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer
3
5
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
4
6
import com.fasterxml.jackson.module.kotlin.readValue
5
7
import org.junit.Test
@@ -9,6 +11,13 @@ class TestGithub269 {
9
11
data class Foo (val pattern : Regex )
10
12
data class Bar (val thing : Regex )
11
13
14
+ data class Goo (
15
+ @JsonSerialize(using = ToStringSerializer ::class )
16
+ val myPattern : Regex
17
+ ) {
18
+ constructor (strPattern: String ) : this (Regex (strPattern))
19
+ }
20
+
12
21
@Test
13
22
fun testGithub269WithFoo () {
14
23
val mapper = jacksonObjectMapper()
@@ -36,4 +45,15 @@ class TestGithub269 {
36
45
37
46
mapper.readValue<Bar >(""" {"thing":"test"}""" )
38
47
}
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
+ }
39
59
}
You can’t perform that action at this time.
0 commit comments