-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4879d6
commit 8371ce1
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/test/java/com/fasterxml/jackson/failing/NullConversionsForContent4200Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |