for (Method method : currentClass.getDeclaredMethods()) {
if (method.isAnnotationPresent(Test.class)
|| method.isAnnotationPresent(Before.class)
|| method.isAnnotationPresent(After.class)) {
Errors errors = new Errors(method);
List<Key<?>> keys = GuiceUtils.getMethodKeys(method, errors);
for (Key<?> key : keys) {
// Skip keys annotated with @All
if (!All.class.equals(key.getAnnotationType())) {
Key<?> keyNeeded = GuiceUtils.ensureProvidedKey(key, errors);
addNeededKey(keysObserved, keysNeeded, keyNeeded, true);
}
}
errors.throwConfigurationExceptionIfErrorsExist();
}
}
currentClass = currentClass.getSuperclass();
}
// Preempt JIT binding by looking through the test class looking for
// fields and methods annotated with @Inject.
// Concrete classes bound in this way are bound in @TestSingleton.
if (testClass != null) {
Set<InjectionPoint> injectionPoints = InjectionPoint.forInstanceMethodsAndFields(testClass);
for (InjectionPoint injectionPoint : injectionPoints) {
Errors errors = new Errors(injectionPoint);
List<Dependency<?>> dependencies = injectionPoint.getDependencies();
for (Dependency<?> dependency : dependencies) {
Key<?> keyNeeded = GuiceUtils.ensureProvidedKey(dependency.getKey(),
errors);
addNeededKey(keysObserved, keysNeeded, keyNeeded, true);
}
errors.throwConfigurationExceptionIfErrorsExist();
}
}
// Recursively add the dependencies of all the bindings observed. Warning, we can't use for each here
// since it would result into concurrency issues.