Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
PJ Fanning committed Dec 29, 2019
1 parent e891fa6 commit 020781b
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import org.scalatestplus.junit.JUnitRunner
object ParamWithDashNameDeserializerTest {
case class AnnotatedOptionLong(@JsonDeserialize(contentAs = classOf[java.lang.Long]) valueLong: Option[Long])

case class OptionLongWithDash(`value-long`: Option[Long])

case class AnnotatedOptionLongWithDash(@JsonDeserialize(contentAs = classOf[java.lang.Long]) `value-long`: Option[Long])

case class AnnotatedOptionLongWithDashButChangeToCamelCase(@JsonProperty("value-long") @JsonDeserialize(contentAs = classOf[java.lang.Long]) valueLong: Option[Long])
Expand All @@ -35,6 +37,20 @@ class ParamWithDashNameDeserializerTest extends DeserializerTest {
}

it should "support param names with dashes" in {
// check deserialization
val v1 = deserialize[OptionLongWithDash]("""{"value-long":251}""")
v1 shouldBe OptionLongWithDash(Some(251L))
v1.`value-long`.get shouldBe 251L

// serialize from case class then deserialize and then apply the method that will fail
val v2 = deserialize[OptionLongWithDash](serialize(OptionLongWithDash(Some(252))))
v2 shouldBe OptionLongWithDash(Some(252L))
v2.`value-long`.get shouldBe 252L
//TODO last assert fails due to unboxing issue
//useOptionLong(v2.`value-long`) shouldBe 504L
}

it should "support param names with dashes (annotated case)" in {
// check deserialization
val v1 = deserialize[AnnotatedOptionLongWithDash]("""{"value-long":251}""")
v1 shouldBe AnnotatedOptionLongWithDash(Some(251L))
Expand Down

0 comments on commit 020781b

Please sign in to comment.