-
-
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
dc2c003
commit 075319d
Showing
4 changed files
with
68 additions
and
4 deletions.
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
45 changes: 45 additions & 0 deletions
45
src/test/java/com/fasterxml/jackson/databind/type/RecursiveType1658Test.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,45 @@ | ||
package com.fasterxml.jackson.databind.type; | ||
|
||
import java.util.*; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.databind.*; | ||
import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; | ||
import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder; | ||
|
||
public class RecursiveType1658Test extends BaseMapTest | ||
{ | ||
@SuppressWarnings("serial") | ||
static class Tree<T> extends HashMap<T, Tree<T>> // implements Serializable | ||
{ | ||
public Tree() { } | ||
|
||
public Tree(List<T> children) { | ||
this(); | ||
for (final T t : children) { | ||
this.put(t, new Tree<T>()); | ||
} | ||
} | ||
|
||
public List<Tree<T>> getLeafTrees() { | ||
return null; | ||
} | ||
} | ||
|
||
public void testRecursive1658() throws Exception | ||
{ | ||
Tree<String> t = new Tree<String>(Arrays.asList("hello", "world")); | ||
ObjectMapper mapper = new ObjectMapper(); | ||
|
||
final TypeResolverBuilder<?> typer = new StdTypeResolverBuilder() | ||
.init(JsonTypeInfo.Id.CLASS, null) | ||
.inclusion(JsonTypeInfo.As.PROPERTY); | ||
mapper.setDefaultTyping(typer); | ||
|
||
String res = mapper.writeValueAsString(t); | ||
|
||
Tree<?> tRead = mapper.readValue(res, Tree.class); | ||
|
||
assertNotNull(tRead); | ||
} | ||
} |