have a case class Person with default param.
pass mapper a string missing a param, mapper sets it as null.
expecting it to set the default value
why is this ?
example :
@JsonIgnoreProperties(ignoreUnknown = true)
case class Person(id:Int,name:String="")
class MapperTest extends SpecificationWithJUnit {
"Mapper" should {
"use default param" in {
val personWithNoNameString = """{"id":1}"""
val mapper = new ObjectMapper();
mapper.registerModule(DefaultScalaModule)
val personWithNoName = mapper.readValue(personWithNoNameString,classOf[Person])
personWithNoName.name must be("")
}
}
}
get error :
'null' is not the same as ''
java.lang.Exception: 'null' is not the same as ''