Skip to content

Commit

Permalink
Add test without default ID
Browse files Browse the repository at this point in the history
  • Loading branch information
dinomite committed Mar 19, 2021
1 parent 59c8d88 commit 4dfa2d6
Showing 1 changed file with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 4dfa2d6

Please sign in to comment.