Skip to content

Commit

Permalink
More fixing of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 9, 2025
1 parent 0604fab commit ae02cb9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public void testByteArrayMerging() throws Exception
MergedX<byte[]> input = new MergedX<byte[]>(new byte[] { 1, 2 });
MergedX<byte[]> result = MAPPER
.readerFor(new TypeReference<MergedX<byte[]>>() {})
.without(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
.withValueToUpdate(input)
.readValue(a2q("{'value':[4, 6.0, null]}"));
assertSame(input, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("{}")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ae02cb9

Please sign in to comment.