Skip to content

Commit 1a1391b

Browse files
committed
test case for #459
1 parent 39b6938 commit 1a1391b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/test/scala/com/fasterxml/jackson/module/scala/deser/OptionWithNumberDeserializerTest.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fasterxml.jackson.module.scala.deser
22

33
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
4+
import com.fasterxml.jackson.databind.exc.InvalidFormatException
45
import com.fasterxml.jackson.module.scala.DefaultScalaModule
56
import com.fasterxml.jackson.module.scala.introspect.ScalaAnnotationIntrospector
67
import org.scalatest.BeforeAndAfterEach
@@ -50,6 +51,12 @@ class OptionWithNumberDeserializerTest extends DeserializerTest with BeforeAndAf
5051
useOptionLong(v1.valueLong) shouldBe 302L
5152
}
5253

54+
it should "fail to deserialize OptionLong when value is text" in {
55+
intercept[InvalidFormatException] {
56+
deserialize("""{"valueLong":"xy"}""", classOf[OptionLong])
57+
}.getMessage should include("""Cannot deserialize value of type `long` from String "xy": not a valid `long` value""")
58+
}
59+
5360
it should "deserialize OptionJavaLong" in {
5461
val v1 = deserialize("""{"valueLong":151}""", classOf[OptionJavaLong])
5562
v1 shouldBe OptionJavaLong(Some(151L))

0 commit comments

Comments
 (0)