Skip to content

Commit

Permalink
Add failing test case for #4200.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 28, 2023
1 parent a4879d6 commit 8371ce1
Showing 1 changed file with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.fasterxml.jackson.failing;

import java.util.Map;

import com.fasterxml.jackson.annotation.*;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.exc.InvalidNullException;

// [databind#4200]: Nulls.FAIL not taken into account with DELEGATING creator
public class NullConversionsForContent4200Test extends BaseMapTest
{
static class DelegatingWrapper4200 {
private final Map<String, String> value;

@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
DelegatingWrapper4200(@JsonSetter(contentNulls = Nulls.FAIL)
Map<String, String> value)
{
this.value = value;
}

public Map<String, String> getValue() {
return value;
}
}

static class SetterWrapper4200 {
private Map<String, String> value;

public Map<String, String> getValue() {
return value;
}

@JsonSetter(contentNulls = Nulls.FAIL)
public void setValue(Map<String, String> value) {
this.value = value;
}
}

private final ObjectMapper MAPPER = newJsonMapper();

public void testDelegatingCreatorNulls4200() throws Exception
{
try {
MAPPER.readValue(a2q("{'foo': null}"), DelegatingWrapper4200.class);
fail("Should not pass");
} catch (InvalidNullException e) {
verifyException(e, "Invalid `null` value");
}
}

public void testSetterNulls4200() throws Exception
{
try {
MAPPER.readValue(a2q("{'value':{'foo': null}}"),
SetterWrapper4200.class);
fail("Should not pass");
} catch (InvalidNullException e) {
verifyException(e, "Invalid `null` value");
}
}
}

0 comments on commit 8371ce1

Please sign in to comment.