1
1
/*
2
- * Copyright 2002-2015 the original author or authors.
2
+ * Copyright 2002-2017 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
36
36
* @author Juergen Hoeller
37
37
* @author Sam Brannen
38
38
*/
39
- @ SuppressWarnings ({ "unchecked" , "rawtypes" })
39
+ @ SuppressWarnings ({"unchecked" , "rawtypes" })
40
40
public class GenericTypeResolverTests {
41
41
42
42
@ Test
@@ -61,7 +61,7 @@ public void simpleCollectionSuperclassType() {
61
61
62
62
@ Test
63
63
public void nullIfNotResolvable () {
64
- GenericClass <String > obj = new GenericClass <String >();
64
+ GenericClass <String > obj = new GenericClass <>();
65
65
assertNull (resolveTypeArgument (obj .getClass (), GenericClass .class ));
66
66
}
67
67
@@ -77,18 +77,17 @@ public void methodReturnTypes() {
77
77
}
78
78
79
79
@ Test
80
- @ Deprecated
81
80
public void testResolveType () {
82
81
Method intMessageMethod = findMethod (MyTypeWithMethods .class , "readIntegerInputMessage" , MyInterfaceType .class );
83
82
MethodParameter intMessageMethodParam = new MethodParameter (intMessageMethod , 0 );
84
83
assertEquals (MyInterfaceType .class ,
85
- resolveType (intMessageMethodParam .getGenericParameterType (), new HashMap <TypeVariable , Type >()));
84
+ resolveType (intMessageMethodParam .getGenericParameterType (), new HashMap <>()));
86
85
87
86
Method intArrMessageMethod = findMethod (MyTypeWithMethods .class , "readIntegerArrayInputMessage" ,
88
87
MyInterfaceType [].class );
89
88
MethodParameter intArrMessageMethodParam = new MethodParameter (intArrMessageMethod , 0 );
90
89
assertEquals (MyInterfaceType [].class ,
91
- resolveType (intArrMessageMethodParam .getGenericParameterType (), new HashMap <TypeVariable , Type >()));
90
+ resolveType (intArrMessageMethodParam .getGenericParameterType (), new HashMap <>()));
92
91
93
92
Method genericArrMessageMethod = findMethod (MySimpleTypeWithMethods .class , "readGenericArrayInputMessage" ,
94
93
Object [].class );
@@ -103,7 +102,6 @@ public void testBoundParameterizedType() {
103
102
}
104
103
105
104
@ Test
106
- @ Deprecated
107
105
public void testGetTypeVariableMap () throws Exception {
108
106
Map <TypeVariable , Type > map ;
109
107
@@ -141,40 +139,35 @@ public void testGetTypeVariableMap() throws Exception {
141
139
assertThat (x , equalTo ((Type ) Long .class ));
142
140
}
143
141
144
- @ Test
142
+ @ Test // SPR-11030
145
143
public void getGenericsCannotBeResolved () throws Exception {
146
- // SPR-11030
147
144
Class <?>[] resolved = GenericTypeResolver .resolveTypeArguments (List .class , Iterable .class );
148
145
assertNull (resolved );
149
146
}
150
147
151
- @ Test
148
+ @ Test // SPR-11052
152
149
public void getRawMapTypeCannotBeResolved () throws Exception {
153
- // SPR-11052
154
150
Class <?>[] resolved = GenericTypeResolver .resolveTypeArguments (Map .class , Map .class );
155
151
assertNull (resolved );
156
152
}
157
153
158
- @ Test
154
+ @ Test // SPR-11044
159
155
public void getGenericsOnArrayFromParamCannotBeResolved () throws Exception {
160
- // SPR-11044
161
156
MethodParameter methodParameter = MethodParameter .forMethodOrConstructor (
162
157
WithArrayBase .class .getDeclaredMethod ("array" , Object [].class ), 0 );
163
158
Class <?> resolved = GenericTypeResolver .resolveParameterType (methodParameter , WithArray .class );
164
159
assertThat (resolved , equalTo ((Class <?>) Object [].class ));
165
160
}
166
161
167
- @ Test
162
+ @ Test // SPR-11044
168
163
public void getGenericsOnArrayFromReturnCannotBeResolved () throws Exception {
169
- // SPR-11044
170
164
Class <?> resolved = GenericTypeResolver .resolveReturnType (
171
165
WithArrayBase .class .getDeclaredMethod ("array" , Object [].class ), WithArray .class );
172
166
assertThat (resolved , equalTo ((Class <?>) Object [].class ));
173
167
}
174
168
175
- @ Test
169
+ @ Test // SPR-11763
176
170
public void resolveIncompleteTypeVariables () {
177
- // SPR-11763
178
171
Class <?>[] resolved = GenericTypeResolver .resolveTypeArguments (IdFixingRepository .class , Repository .class );
179
172
assertNotNull (resolved );
180
173
assertEquals (2 , resolved .length );
0 commit comments