|
@@ -31,7 +31,6 @@ import java.lang.reflect.Constructor;
|
31
|
31
|
import java.lang.reflect.InvocationTargetException;
|
32
|
32
|
import java.lang.reflect.Method;
|
33
|
33
|
import java.util.ArrayList;
|
34
|
|
-import java.util.Arrays;
|
35
|
34
|
import java.util.HashMap;
|
36
|
35
|
import java.util.List;
|
37
|
36
|
import java.util.Map;
|
|
@@ -180,9 +179,7 @@ public class CallbackObject {
|
180
|
179
|
for (Annotation ann : anns) {
|
181
|
180
|
if (ann.annotationType().equals(FakableArgument.class)
|
182
|
181
|
&& args[i] == null) {
|
183
|
|
- args[i] = getFakeArg(args,
|
184
|
|
- type.getMethods()[0].getParameterTypes()[i],
|
185
|
|
- ((FakableArgument) ann).group());
|
|
182
|
+ args[i] = getFakeArg(args, type.getMethods()[0].getParameterTypes()[i]);
|
186
|
183
|
}
|
187
|
184
|
}
|
188
|
185
|
|
|
@@ -193,8 +190,6 @@ public class CallbackObject {
|
193
|
190
|
/**
|
194
|
191
|
* Tries to create fake argument of the specified target class, by using
|
195
|
192
|
* {@link FakableSource} denoted parameters from the specified arg array.
|
196
|
|
- * Parameters are only used if their groups value contains the specified
|
197
|
|
- * group.
|
198
|
193
|
*
|
199
|
194
|
* If an argument is missing, the method attempts to create a fake instance
|
200
|
195
|
* by recursing into this method again. Note that this could cause an
|
|
@@ -206,17 +201,15 @@ public class CallbackObject {
|
206
|
201
|
*
|
207
|
202
|
* @param args The arguments array to use for sources
|
208
|
203
|
* @param target The class that should be constructed
|
209
|
|
- * @param group The group of arguments to use
|
210
|
204
|
* @return An instance of the target class, or null on failure
|
211
|
205
|
*/
|
212
|
|
- protected Object getFakeArg(final Object[] args, final Class<?> target, final String group) {
|
|
206
|
+ protected Object getFakeArg(final Object[] args, final Class<?> target) {
|
213
|
207
|
final Map<Class, Object> sources = new HashMap<Class, Object>();
|
214
|
208
|
int i = 0;
|
215
|
209
|
|
216
|
210
|
for (Annotation[] anns : type.getMethods()[0].getParameterAnnotations()) {
|
217
|
211
|
for (Annotation ann : anns) {
|
218
|
|
- if (ann.annotationType().equals(FakableSource.class)
|
219
|
|
- && Arrays.asList(((FakableSource) ann).group()).contains(group)) {
|
|
212
|
+ if (ann.annotationType().equals(FakableSource.class)) {
|
220
|
213
|
sources.put(type.getMethods()[0].getParameterTypes()[i], args[i]);
|
221
|
214
|
}
|
222
|
215
|
}
|
|
@@ -234,7 +227,7 @@ public class CallbackObject {
|
234
|
227
|
for (Class<?> needed : ctor.getParameterTypes()) {
|
235
|
228
|
if (sources.containsKey(needed)) {
|
236
|
229
|
params[i] = sources.get(needed);
|
237
|
|
- } else if ((param = getFakeArg(args, needed, group)) != null) {
|
|
230
|
+ } else if ((param = getFakeArg(args, needed)) != null) {
|
238
|
231
|
params[i] = param;
|
239
|
232
|
} else {
|
240
|
233
|
failed = true;
|