for (Method m : classModel.getAnnotatedLeafMethods(ParametersFactory.class).keySet()) {
Validation.checkThat(m)
.isStatic()
.isPublic();
ParametersFactory pfAnnotation = m.getAnnotation(ParametersFactory.class);
assert pfAnnotation != null;
if (!Iterable.class.isAssignableFrom(m.getReturnType())) {
throw new RuntimeException("@" + ParametersFactory.class.getSimpleName() + " annotated " +
"methods must be public, static and returning Iterable<Object[]>:" + m);
}
List<Object[]> result = new ArrayList<Object[]>();
try {
for (Object [] p : (Iterable<Object[]>) m.invoke(null)) {
result.add(p);
}
} catch (InvocationTargetException e) {
Rethrow.rethrow(e.getCause());
} catch (Throwable t) {
throw new RuntimeException("Error collecting parameters from: " + m, t);
}
if (result.isEmpty()) {
throw new InternalAssumptionViolatedException("Parameters set should not be empty. Ignoring tests.");
}
if (pfAnnotation.shuffle()) {
Collections.shuffle(result, new Random(runnerRandomness.getSeed()));
}
parameters.addAll(result);
}