Skip to content

Commit 9f9317d

Browse files
committed
try to fix tests due to #698
1 parent 14a64ac commit 9f9317d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/test/scala/tools/jackson/module/scala/deser/CreatorTest.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package tools.jackson.module.scala.deser
33
import com.fasterxml.jackson.annotation.JsonCreator
44
import com.fasterxml.jackson.annotation.JsonCreator.Mode
55
import tools.jackson.core.`type`.TypeReference
6-
import tools.jackson.databind.{JsonNode, MapperFeature, ObjectMapper}
6+
import tools.jackson.databind.{DeserializationFeature, JsonNode, MapperFeature, ObjectMapper}
77
import tools.jackson.databind.json.JsonMapper
88
import tools.jackson.databind.node.IntNode
99
import tools.jackson.module.scala.introspect.ScalaAnnotationIntrospectorModule
@@ -178,6 +178,7 @@ class CreatorTest extends DeserializationFixture {
178178
.build()
179179
val mapper = initBuilder()
180180
.addModule(scalaModule)
181+
.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false)
181182
.build()
182183
val deser = mapper.readValue("""{}""", classOf[ConstructorWithDefaultValues])
183184
deser.s shouldEqual null
@@ -195,6 +196,7 @@ class CreatorTest extends DeserializationFixture {
195196
.build()
196197
val mapper = initBuilder()
197198
.addModule(scalaModule)
199+
.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false)
198200
.build()
199201
val deser = mapper.readValue("""{}""", classOf[ConstructorWithDefaultValues])
200202
deser.s shouldEqual null
@@ -208,6 +210,7 @@ class CreatorTest extends DeserializationFixture {
208210
it should "ignore default values (when MapperFeature is overridden)" in { _ =>
209211
val builder = initBuilder()
210212
.disable(MapperFeature.APPLY_DEFAULT_VALUES)
213+
.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false)
211214
.addModule(DefaultScalaModule)
212215
val mapper = builder.build()
213216
val deser = mapper.readValue("""{}""", classOf[ConstructorWithDefaultValues])

src/test/scala/tools/jackson/module/scala/deser/DefaultValueDeserializerTest.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package tools.jackson.module.scala.deser
22

3+
import tools.jackson.databind.DeserializationFeature
34
import tools.jackson.module.scala.DefaultScalaModule
45

56
object DefaultValueDeserializerTest {
@@ -25,7 +26,11 @@ class DefaultValueDeserializerTest extends DeserializerTest {
2526
// this may not be ideal but it is the existing behaviour so we will probably need
2627
// a config or annotation to get the test to use the 2nd constructor
2728
val json = """{"name":"123"}"""
28-
val d = deserialize(json, classOf[Defaulted])
29+
val mapper = newBuilder
30+
.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false)
31+
.build()
32+
33+
val d = mapper.readValue(json, classOf[Defaulted])
2934
d.id shouldEqual 0
3035
d.name shouldEqual "123"
3136
}

0 commit comments

Comments
 (0)