-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate test case out from Option tests
- Loading branch information
Showing
2 changed files
with
32 additions
and
11 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/test/scala/com/fasterxml/jackson/module/scala/deser/DefaultValueDeserializerTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.fasterxml.jackson.module.scala.deser | ||
|
||
import com.fasterxml.jackson.module.scala.DefaultScalaModule | ||
|
||
object DefaultValueDeserializerTest { | ||
|
||
case class Defaulted(id: Int, name: String = "") { | ||
def this() = this(1) | ||
} | ||
|
||
} | ||
|
||
class DefaultValueDeserializerTest extends DeserializerTest { | ||
import DefaultValueDeserializerTest._ | ||
lazy val module: DefaultScalaModule.type = DefaultScalaModule | ||
|
||
"An ObjectMapper with DefaultScalaModule" should "deserialize defaulted parameters correctly" in { | ||
val json = newMapper.writeValueAsString(Defaulted(id = 1)) | ||
json shouldBe """{"id":1,"name":""}""" | ||
val d = deserialize(json, classOf[Defaulted]) | ||
d.name shouldEqual "" | ||
} | ||
|
||
it should "deserialize defaulted parameters correctly (ignores 2nd constructor)" in { | ||
// this may not be ideal but it is the existing behaviour so we will probably need | ||
// a config or annotation to get the test to use the 2nd constructor | ||
val json = """{"name":"123"}""" | ||
val d = deserialize(json, classOf[Defaulted]) | ||
d.id shouldEqual 0 | ||
d.name shouldEqual "123" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters