From 4dfa2d6eded01237c1706ce5fba7f29697cd02d4 Mon Sep 17 00:00:00 2001 From: Drew Stephens Date: Fri, 19 Mar 2021 17:52:06 +0000 Subject: [PATCH] Add test without default ID --- .../module/kotlin/test/github/Github194.kt | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github194.kt b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github194.kt index 25519e10..90a093bd 100644 --- a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github194.kt +++ b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github194.kt @@ -19,13 +19,31 @@ class TestGithub194 { assertEquals(id.toString(), value.idString) assertEquals("Foo", value.name) } -} -@JsonIdentityInfo( - property = "id", - scope = WithIdentity::class, - generator = ObjectIdGenerators.PropertyGenerator::class -) -class WithIdentity(val id: UUID = UUID.randomUUID(), - val idString: String = id.toString(), - val name: String) + @JsonIdentityInfo( + property = "id", + scope = WithIdentity::class, + generator = ObjectIdGenerators.PropertyGenerator::class + ) + class WithIdentity(val id: UUID, + val idString: String = id.toString(), + val name: String) + + @Test + fun testIdentityInfo_WithDefaultId() { + val mapper = jacksonObjectMapper() + val value = mapper.readValue(json, WithIdentityAndDefaultId::class.java) + assertEquals(id, value.id) + assertEquals(id.toString(), value.idString) + assertEquals("Foo", value.name) + } + + @JsonIdentityInfo( + property = "id", + scope = WithIdentityAndDefaultId::class, + generator = ObjectIdGenerators.PropertyGenerator::class + ) + class WithIdentityAndDefaultId(val id: UUID, + val idString: String = id.toString(), + val name: String) +}