File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,14 @@ Authors:
13
13
14
14
Contributors :
15
15
16
+ Christopher Mason (masoncj @github )
17
+ * #194 : Contributed test case for @JsonIdentityInfo usage
18
+ (2.12 .NEXT )
19
+
20
+ Martin Häusler (MartinHaeusler @github )
21
+ * Reported #194 : @JsonIdentityInfo bug
22
+ (2.12 .NEXT )
23
+
16
24
Eric Fenderbosch (efenderbosch @github )
17
25
* Fixed #182 : Serialize unsigned numbers
18
26
(2.12 .2 )
Original file line number Diff line number Diff line change
1
+ package com.fasterxml.jackson.module.kotlin.test.github
2
+
3
+ import com.fasterxml.jackson.annotation.JsonIdentityInfo
4
+ import com.fasterxml.jackson.annotation.ObjectIdGenerators
5
+ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
6
+ import org.junit.Test
7
+ import java.util.UUID
8
+ import kotlin.test.assertEquals
9
+
10
+ class TestGithub194 {
11
+ val id: UUID = UUID .fromString(" 149800a6-7855-4e09-9185-02e442da8013" )
12
+ val json = """ {"id": "$id ", "name": "Foo"}"""
13
+
14
+ @Test
15
+ fun testIdentityInfo () {
16
+ val mapper = jacksonObjectMapper()
17
+ val value = mapper.readValue(json, WithIdentity ::class .java)
18
+ assertEquals(id, value.id)
19
+ assertEquals(id.toString(), value.idString)
20
+ assertEquals(" Foo" , value.name)
21
+ }
22
+ }
23
+
24
+ @JsonIdentityInfo(
25
+ property = " id" ,
26
+ scope = WithIdentity ::class ,
27
+ generator = ObjectIdGenerators .PropertyGenerator ::class
28
+ )
29
+ class WithIdentity (val id : UUID = UUID .randomUUID(),
30
+ val idString : String = id.toString(),
31
+ val name : String )
You can’t perform that action at this time.
0 commit comments