From 8bd6978ebe872a43d0bf2d8d7e28f9432eeb9164 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 20 Sep 2021 20:16:16 +0100 Subject: [PATCH] Update OptionWithBooleanDeserializerTest.scala --- .../deser/OptionWithBooleanDeserializerTest.scala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/test/scala/com/fasterxml/jackson/module/scala/deser/OptionWithBooleanDeserializerTest.scala b/src/test/scala/com/fasterxml/jackson/module/scala/deser/OptionWithBooleanDeserializerTest.scala index c67659d16..144077086 100644 --- a/src/test/scala/com/fasterxml/jackson/module/scala/deser/OptionWithBooleanDeserializerTest.scala +++ b/src/test/scala/com/fasterxml/jackson/module/scala/deser/OptionWithBooleanDeserializerTest.scala @@ -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" }