-
-
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
9700cd6
commit 7783a3b
Showing
5 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
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
59 changes: 59 additions & 0 deletions
59
...java/com/fasterxml/jackson/databind/jsontype/ext/ExternalTypeIdWithIgnoreUnknownTest.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,59 @@ | ||
package com.fasterxml.jackson.databind.jsontype.ext; | ||
|
||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.annotation.*; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.*; | ||
|
||
public class ExternalTypeIdWithIgnoreUnknownTest extends BaseMapTest | ||
{ | ||
// [databind#2611] | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
static class Wrapper2611 { | ||
private String type; | ||
|
||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.NAME, | ||
include = JsonTypeInfo.As.EXTERNAL_PROPERTY, | ||
property = "type", | ||
defaultImpl = Default2611.class | ||
) | ||
private Default2611 data; | ||
|
||
@JsonCreator | ||
public Wrapper2611( | ||
@JsonProperty(value = "type", required = true) String type, | ||
@JsonProperty(value = "data", required = true) Default2611 data | ||
) { | ||
this.type = type; | ||
this.data = data; | ||
} | ||
|
||
String getType() { | ||
return type; | ||
} | ||
|
||
Default2611 getData() { | ||
return data; | ||
} | ||
} | ||
|
||
static class Default2611 {} | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
// [databind#2611] | ||
public void testDeserialization() throws Exception | ||
{ | ||
final String data = aposToQuotes("[{'type': 'test','data': {},'additional': {}}]"); | ||
|
||
List<Wrapper2611> result = MAPPER.readValue(data, new TypeReference<List<Wrapper2611>>() {}); | ||
|
||
assertEquals(1, result.size()); | ||
|
||
Wrapper2611 item = result.get(0); | ||
assertEquals("test", item.getType()); | ||
assertNotNull(item.getData()); | ||
} | ||
} |