Skip to content

Commit 8e5212a

Browse files
committed
Merge branch '2.12' into 2.13
2 parents 689e8cc + 4dfa2d6 commit 8e5212a

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

release-notes/CREDITS-2.x

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ Authors:
1313

1414
Contributors:
1515

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+
1624
Eric Fenderbosch (efenderbosch@github)
1725
* Fixed #182: Serialize unsigned numbers
1826
(2.12.2)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
@JsonIdentityInfo(
24+
property = "id",
25+
scope = WithIdentity::class,
26+
generator = ObjectIdGenerators.PropertyGenerator::class
27+
)
28+
class WithIdentity(val id: UUID,
29+
val idString: String = id.toString(),
30+
val name: String)
31+
32+
@Test
33+
fun testIdentityInfo_WithDefaultId() {
34+
val mapper = jacksonObjectMapper()
35+
val value = mapper.readValue(json, WithIdentityAndDefaultId::class.java)
36+
assertEquals(id, value.id)
37+
assertEquals(id.toString(), value.idString)
38+
assertEquals("Foo", value.name)
39+
}
40+
41+
@JsonIdentityInfo(
42+
property = "id",
43+
scope = WithIdentityAndDefaultId::class,
44+
generator = ObjectIdGenerators.PropertyGenerator::class
45+
)
46+
class WithIdentityAndDefaultId(val id: UUID,
47+
val idString: String = id.toString(),
48+
val name: String)
49+
}

0 commit comments

Comments
 (0)