Skip to content

Commit

Permalink
Update OptionWithBooleanDeserializerTest.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Sep 20, 2021
1 parent fc621a2 commit 8bd6978
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ class OptionWithBooleanDeserializerTest extends DeserializerTest with BeforeAndA
useOptionBoolean(v1.valueBoolean) shouldBe "false"
}

it should "support OptionBoolean" in {
it should "support OptionBoolean (without registerReferencedType)" in {
val v1 = deserialize("""{"valueBoolean":false}""", classOf[OptionBoolean])
v1 shouldBe OptionBoolean(Some(false))
v1.valueBoolean.get shouldBe false
useOptionBoolean(v1.valueBoolean) shouldBe "false"
}

it should "support OptionBoolean (with registerReferencedType)" in {
ScalaAnnotationIntrospector.registerReferencedType(classOf[OptionBoolean], "valueBoolean", classOf[Boolean])
val v1 = deserialize("""{"valueBoolean":false}""", classOf[OptionBoolean])
v1 shouldBe OptionBoolean(Some(false))
v1.valueBoolean.get shouldBe false
//this will next call will fail with a Scala unboxing exception unless you ScalaAnnotationIntrospector.registerReferencedType
//or use one of the equivalent classes in OptionWithBooleanDeserializerTest
useOptionBoolean(v1.valueBoolean) shouldBe "false"
}

Expand Down

0 comments on commit 8bd6978

Please sign in to comment.