4
4
5
5
import com .fasterxml .jackson .databind .*;
6
6
7
- // for [databind#938]
8
- public class RecursiveType938Test extends BaseMapTest
7
+ public class RecursiveTypeTest extends BaseMapTest
9
8
{
9
+ // for [databind#1301]
10
+ @ SuppressWarnings ("serial" )
11
+ static class HashTree <K , V > extends HashMap <K , HashTree <K , V >> { }
12
+
13
+ // for [databind#938]
10
14
public static interface Ability <T > { }
11
15
12
16
public static final class ImmutablePair <L , R > implements Map .Entry <L , R >, Ability <ImmutablePair <L , R >> {
@@ -38,8 +42,27 @@ static <L, R> ImmutablePair<L, R> of(final L left, final R right) {
38
42
}
39
43
}
40
44
45
+ // for [databind#1301]
46
+ public void testRecursiveType ()
47
+ {
48
+ TypeFactory tf = TypeFactory .defaultInstance ();
49
+ JavaType type = tf .constructType (HashTree .class );
50
+ assertNotNull (type );
51
+ }
52
+
53
+ // for [databind#1301]
54
+ @ SuppressWarnings ("serial" )
55
+ static class DataDefinition extends HashMap <String , DataDefinition > {
56
+ public DataDefinition definition ;
57
+ public DataDefinition elements ;
58
+ public String regex ;
59
+ public boolean required ;
60
+ public String type ;
61
+ }
62
+
41
63
private final ObjectMapper MAPPER = new ObjectMapper ();
42
64
65
+ // [databind#938]
43
66
public void testRecursivePair () throws Exception
44
67
{
45
68
JavaType t = MAPPER .constructType (ImmutablePair .class );
@@ -55,4 +78,19 @@ public void testRecursivePair() throws Exception
55
78
56
79
// can not deserialize with current definition, however
57
80
}
81
+
82
+ // for [databind#1301]
83
+ public void testJavaTypeToString () throws Exception
84
+ {
85
+ TypeFactory tf = objectMapper ().getTypeFactory ();
86
+ String desc = tf .constructType (DataDefinition .class ).toString ();
87
+ assertNotNull (desc );
88
+ // could try comparing exact message, but since it's informational try looser:
89
+ if (!desc .contains ("map type" )) {
90
+ fail ("Description should contain 'map type', did not: " +desc );
91
+ }
92
+ if (!desc .contains ("recursive type" )) {
93
+ fail ("Description should contain 'recursive type', did not: " +desc );
94
+ }
95
+ }
58
96
}
0 commit comments