Skip to content

Commit

Permalink
try to fix tests due to #698
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Jan 16, 2025
1 parent 14a64ac commit 9f9317d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package tools.jackson.module.scala.deser
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonCreator.Mode
import tools.jackson.core.`type`.TypeReference
import tools.jackson.databind.{JsonNode, MapperFeature, ObjectMapper}
import tools.jackson.databind.{DeserializationFeature, JsonNode, MapperFeature, ObjectMapper}
import tools.jackson.databind.json.JsonMapper
import tools.jackson.databind.node.IntNode
import tools.jackson.module.scala.introspect.ScalaAnnotationIntrospectorModule
Expand Down Expand Up @@ -178,6 +178,7 @@ class CreatorTest extends DeserializationFixture {
.build()
val mapper = initBuilder()
.addModule(scalaModule)
.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false)
.build()
val deser = mapper.readValue("""{}""", classOf[ConstructorWithDefaultValues])
deser.s shouldEqual null
Expand All @@ -195,6 +196,7 @@ class CreatorTest extends DeserializationFixture {
.build()
val mapper = initBuilder()
.addModule(scalaModule)
.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false)
.build()
val deser = mapper.readValue("""{}""", classOf[ConstructorWithDefaultValues])
deser.s shouldEqual null
Expand All @@ -208,6 +210,7 @@ class CreatorTest extends DeserializationFixture {
it should "ignore default values (when MapperFeature is overridden)" in { _ =>
val builder = initBuilder()
.disable(MapperFeature.APPLY_DEFAULT_VALUES)
.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false)
.addModule(DefaultScalaModule)
val mapper = builder.build()
val deser = mapper.readValue("""{}""", classOf[ConstructorWithDefaultValues])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tools.jackson.module.scala.deser

import tools.jackson.databind.DeserializationFeature
import tools.jackson.module.scala.DefaultScalaModule

object DefaultValueDeserializerTest {
Expand All @@ -25,7 +26,11 @@ class DefaultValueDeserializerTest extends DeserializerTest {
// 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])
val mapper = newBuilder
.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false)
.build()

val d = mapper.readValue(json, classOf[Defaulted])
d.id shouldEqual 0
d.name shouldEqual "123"
}
Expand Down

0 comments on commit 9f9317d

Please sign in to comment.