From ae02cb9afb5cb56afd4638b23fe9ec441c24469c Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 8 Jan 2025 18:53:12 -0800 Subject: [PATCH] More fixing of tests --- .../jackson/databind/deser/merge/ArrayMergeTest.java | 1 + .../introspect/DefaultCreatorDetection4584Test.java | 1 + .../databind/introspect/IsGetterRenaming2527Test.java | 1 + .../databind/struct/TestPOJOAsArrayAdvanced.java | 3 ++- .../databind/struct/TestPOJOAsArrayWithBuilder.java | 11 +++++++---- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/merge/ArrayMergeTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/merge/ArrayMergeTest.java index 8a56c8db70..93c292d1a4 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/merge/ArrayMergeTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/merge/ArrayMergeTest.java @@ -129,6 +129,7 @@ public void testByteArrayMerging() throws Exception MergedX input = new MergedX(new byte[] { 1, 2 }); MergedX result = MAPPER .readerFor(new TypeReference>() {}) + .without(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) .withValueToUpdate(input) .readValue(a2q("{'value':[4, 6.0, null]}")); assertSame(input, result); diff --git a/src/test/java/com/fasterxml/jackson/databind/introspect/DefaultCreatorDetection4584Test.java b/src/test/java/com/fasterxml/jackson/databind/introspect/DefaultCreatorDetection4584Test.java index 8c53cd2e4c..b252edefcc 100644 --- a/src/test/java/com/fasterxml/jackson/databind/introspect/DefaultCreatorDetection4584Test.java +++ b/src/test/java/com/fasterxml/jackson/databind/introspect/DefaultCreatorDetection4584Test.java @@ -189,6 +189,7 @@ public void testCanonicalConstructor2ArgPropertiesCreator() throws Exception assertEquals(POJO4584.factoryString(null), readerWith(new PrimaryCreatorFindingIntrospector(JsonCreator.Mode.PROPERTIES, String.class, Integer.TYPE)) + .without(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) .readValue(a2q("{}"))); } diff --git a/src/test/java/com/fasterxml/jackson/databind/introspect/IsGetterRenaming2527Test.java b/src/test/java/com/fasterxml/jackson/databind/introspect/IsGetterRenaming2527Test.java index f4d1529027..709188a238 100644 --- a/src/test/java/com/fasterxml/jackson/databind/introspect/IsGetterRenaming2527Test.java +++ b/src/test/java/com/fasterxml/jackson/databind/introspect/IsGetterRenaming2527Test.java @@ -72,6 +72,7 @@ public PropertyName findRenameByField(MapperConfig config, private final ObjectMapper MAPPER = jsonMapperBuilder() .annotationIntrospector(new MyIntrospector()) + .disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) .build(); @Test diff --git a/src/test/java/com/fasterxml/jackson/databind/struct/TestPOJOAsArrayAdvanced.java b/src/test/java/com/fasterxml/jackson/databind/struct/TestPOJOAsArrayAdvanced.java index 318f1a2ec3..2074d382f4 100644 --- a/src/test/java/com/fasterxml/jackson/databind/struct/TestPOJOAsArrayAdvanced.java +++ b/src/test/java/com/fasterxml/jackson/databind/struct/TestPOJOAsArrayAdvanced.java @@ -3,7 +3,7 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.*; - +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.testutil.DatabindTestUtil; @@ -120,6 +120,7 @@ public void testWithViewAndCreator() throws Exception { AsArrayWithViewAndCreator result = MAPPER.readerFor(AsArrayWithViewAndCreator.class) .withView(ViewB.class) + .without(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) .readValue("[1,2,3]"); // should include 'c' (not view-able) and 'b' (include in ViewB) but not 'a' assertEquals(3, result.c); diff --git a/src/test/java/com/fasterxml/jackson/databind/struct/TestPOJOAsArrayWithBuilder.java b/src/test/java/com/fasterxml/jackson/databind/struct/TestPOJOAsArrayWithBuilder.java index 8dbe523826..f781741d95 100644 --- a/src/test/java/com/fasterxml/jackson/databind/struct/TestPOJOAsArrayWithBuilder.java +++ b/src/test/java/com/fasterxml/jackson/databind/struct/TestPOJOAsArrayWithBuilder.java @@ -146,23 +146,26 @@ public void testBuilderWithUpdate() throws Exception @Test public void testWithCreator() throws Exception { - CreatorValue value = MAPPER.readValue("[1,2,3]", CreatorValue.class); + ObjectReader r = MAPPER.readerFor(CreatorValue.class) + .without(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES); + + CreatorValue value = r.readValue("[1,2,3]"); assertEquals(1, value.a); assertEquals(2, value.b); assertEquals(3, value.c); // and should be ok with partial too? - value = MAPPER.readValue("[1,2]", CreatorValue.class); + value = r.readValue("[1,2]"); assertEquals(1, value.a); assertEquals(2, value.b); assertEquals(0, value.c); - value = MAPPER.readValue("[1]", CreatorValue.class); + value = r.readValue("[1]"); assertEquals(1, value.a); assertEquals(0, value.b); assertEquals(0, value.c); - value = MAPPER.readValue("[]", CreatorValue.class); + value = r.readValue("[]"); assertEquals(0, value.a); assertEquals(0, value.b); assertEquals(0, value.c);