1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2013 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.
@@ -65,10 +65,13 @@ public void nullIfNotResolvable() {
65
65
66
66
@ Test
67
67
public void methodReturnTypes () {
68
- assertEquals (Integer .class , resolveReturnTypeArgument (findMethod (MyTypeWithMethods .class , "integer" ), MyInterfaceType .class ));
69
- assertEquals (String .class , resolveReturnTypeArgument (findMethod (MyTypeWithMethods .class , "string" ), MyInterfaceType .class ));
68
+ assertEquals (Integer .class ,
69
+ resolveReturnTypeArgument (findMethod (MyTypeWithMethods .class , "integer" ), MyInterfaceType .class ));
70
+ assertEquals (String .class ,
71
+ resolveReturnTypeArgument (findMethod (MyTypeWithMethods .class , "string" ), MyInterfaceType .class ));
70
72
assertEquals (null , resolveReturnTypeArgument (findMethod (MyTypeWithMethods .class , "raw" ), MyInterfaceType .class ));
71
- assertEquals (null , resolveReturnTypeArgument (findMethod (MyTypeWithMethods .class , "object" ), MyInterfaceType .class ));
73
+ assertEquals (null ,
74
+ resolveReturnTypeArgument (findMethod (MyTypeWithMethods .class , "object" ), MyInterfaceType .class ));
72
75
}
73
76
74
77
/**
@@ -135,20 +138,22 @@ public void genericMethodReturnTypes() {
135
138
*/
136
139
@ Test
137
140
public void testResolveType () {
138
- Method intMessageMethod = findMethod (MyTypeWithMethods .class , "readIntegerInputMessage" , MyInterfaceType .class );
139
- MethodParameter intMessageMethodParam = new MethodParameter (intMessageMethod , 0 );
140
- assertEquals (MyInterfaceType .class ,
141
- resolveType (intMessageMethodParam .getGenericParameterType (), new HashMap <TypeVariable , Type >()));
142
-
143
- Method intArrMessageMethod = findMethod (MyTypeWithMethods .class , "readIntegerArrayInputMessage" , MyInterfaceType [].class );
144
- MethodParameter intArrMessageMethodParam = new MethodParameter (intArrMessageMethod , 0 );
145
- assertEquals (MyInterfaceType [].class ,
146
- resolveType (intArrMessageMethodParam .getGenericParameterType (), new HashMap <TypeVariable , Type >()));
147
-
148
- Method genericArrMessageMethod = findMethod (MySimpleTypeWithMethods .class , "readGenericArrayInputMessage" , Object [].class );
149
- MethodParameter genericArrMessageMethodParam = new MethodParameter (genericArrMessageMethod , 0 );
150
- Map <TypeVariable , Type > varMap = getTypeVariableMap (MySimpleTypeWithMethods .class );
151
- assertEquals (Integer [].class , resolveType (genericArrMessageMethodParam .getGenericParameterType (), varMap ));
141
+ Method intMessageMethod = findMethod (MyTypeWithMethods .class , "readIntegerInputMessage" , MyInterfaceType .class );
142
+ MethodParameter intMessageMethodParam = new MethodParameter (intMessageMethod , 0 );
143
+ assertEquals (MyInterfaceType .class ,
144
+ resolveType (intMessageMethodParam .getGenericParameterType (), new HashMap <TypeVariable , Type >()));
145
+
146
+ Method intArrMessageMethod = findMethod (MyTypeWithMethods .class , "readIntegerArrayInputMessage" ,
147
+ MyInterfaceType [].class );
148
+ MethodParameter intArrMessageMethodParam = new MethodParameter (intArrMessageMethod , 0 );
149
+ assertEquals (MyInterfaceType [].class ,
150
+ resolveType (intArrMessageMethodParam .getGenericParameterType (), new HashMap <TypeVariable , Type >()));
151
+
152
+ Method genericArrMessageMethod = findMethod (MySimpleTypeWithMethods .class , "readGenericArrayInputMessage" ,
153
+ Object [].class );
154
+ MethodParameter genericArrMessageMethodParam = new MethodParameter (genericArrMessageMethod , 0 );
155
+ Map <TypeVariable , Type > varMap = getTypeVariableMap (MySimpleTypeWithMethods .class );
156
+ assertEquals (Integer [].class , resolveType (genericArrMessageMethodParam .getGenericParameterType (), varMap ));
152
157
}
153
158
154
159
@@ -171,26 +176,44 @@ public class MyCollectionSuperclassType extends MySuperclassType<Collection<Stri
171
176
}
172
177
173
178
public static class MyTypeWithMethods <T > {
174
- public MyInterfaceType <Integer > integer () { return null ; }
175
- public MySimpleInterfaceType string () { return null ; }
176
- public Object object () { return null ; }
179
+
180
+ public MyInterfaceType <Integer > integer () {
181
+ return null ;
182
+ }
183
+
184
+ public MySimpleInterfaceType string () {
185
+ return null ;
186
+ }
187
+
188
+ public Object object () {
189
+ return null ;
190
+ }
191
+
177
192
@ SuppressWarnings ("rawtypes" )
178
- public MyInterfaceType raw () { return null ; }
179
- public String notParameterized () { return null ; }
180
- public String notParameterizedWithArguments (Integer x , Boolean b ) { return null ; }
193
+ public MyInterfaceType raw () {
194
+ return null ;
195
+ }
196
+
197
+ public String notParameterized () {
198
+ return null ;
199
+ }
200
+
201
+ public String notParameterizedWithArguments (Integer x , Boolean b ) {
202
+ return null ;
203
+ }
181
204
182
205
/**
183
- * Simulates a factory method that wraps the supplied object in a proxy
184
- * of the same type.
206
+ * Simulates a factory method that wraps the supplied object in a proxy of the
207
+ * same type.
185
208
*/
186
209
public static <T > T createProxy (T object ) {
187
210
return null ;
188
211
}
189
212
190
213
/**
191
- * Similar to {@link #createProxy(Object)} but adds an additional argument
192
- * before the argument of type {@code T}. Note that they may potentially
193
- * be of the same time when invoked!
214
+ * Similar to {@link #createProxy(Object)} but adds an additional argument before
215
+ * the argument of type {@code T}. Note that they may potentially be of the same
216
+ * time when invoked!
194
217
*/
195
218
public static <T > T createNamedProxy (String name , T object ) {
196
219
return null ;
@@ -204,8 +227,8 @@ public static <MOCK> MOCK createMock(Class<MOCK> toMock) {
204
227
}
205
228
206
229
/**
207
- * Similar to {@link #createMock(Class)} but adds an additional method
208
- * argument before the parameterized argument.
230
+ * Similar to {@link #createMock(Class)} but adds an additional method argument
231
+ * before the parameterized argument.
209
232
*/
210
233
public static <T > T createNamedMock (String name , Class <T > toMock ) {
211
234
return null ;
@@ -220,8 +243,8 @@ public static <V extends Object, T> T createVMock(V name, Class<T> toMock) {
220
243
}
221
244
222
245
/**
223
- * Extract some value of the type supported by the interface (i.e., by
224
- * a concrete, non-generic implementation of the interface).
246
+ * Extract some value of the type supported by the interface (i.e., by a concrete,
247
+ * non-generic implementation of the interface).
225
248
*/
226
249
public static <T > T extractValueFrom (MyInterfaceType <T > myInterfaceType ) {
227
250
return null ;
0 commit comments