1
1
package tools.jackson.module.kotlin.test.github
2
2
3
+ import java.util.UUID
4
+
5
+ import kotlin.test.assertEquals
6
+
7
+ import org.junit.Test
8
+
3
9
import com.fasterxml.jackson.annotation.JsonIdentityInfo
4
10
import com.fasterxml.jackson.annotation.ObjectIdGenerators
11
+ import tools.jackson.databind.MapperFeature
12
+ import tools.jackson.module.kotlin.jacksonMapperBuilder
5
13
import tools.jackson.module.kotlin.jacksonObjectMapper
6
- import org.junit.Test
7
- import java.util.UUID
8
- import kotlin.test.assertEquals
9
14
10
15
class TestGithub194 {
16
+ val mapperWithFinalFieldsAsMutators = jacksonMapperBuilder()
17
+ .enable(MapperFeature .ALLOW_FINAL_FIELDS_AS_MUTATORS )
18
+ .build()
19
+
11
20
val id: UUID = UUID .fromString(" 149800a6-7855-4e09-9185-02e442da8013" )
12
21
val json = """ {"id": "$id ", "name": "Foo"}"""
13
22
14
23
@Test
15
24
fun testIdentityInfo () {
16
25
val mapper = jacksonObjectMapper()
17
- val value = mapper .readValue(json, WithIdentity ::class .java)
26
+ val value = mapperWithFinalFieldsAsMutators .readValue(json, WithIdentity ::class .java)
18
27
assertEquals(id, value.id)
19
28
assertEquals(id.toString(), value.idString)
20
29
assertEquals(" Foo" , value.name)
@@ -32,7 +41,7 @@ class TestGithub194 {
32
41
@Test
33
42
fun testIdentityInfo_WithDefaultId () {
34
43
val mapper = jacksonObjectMapper()
35
- val value = mapper .readValue(json, WithIdentityAndDefaultId ::class .java)
44
+ val value = mapperWithFinalFieldsAsMutators .readValue(json, WithIdentityAndDefaultId ::class .java)
36
45
assertEquals(id, value.id)
37
46
assertEquals(id.toString(), value.idString)
38
47
assertEquals(" Foo" , value.name)
0 commit comments