* </p>
*
* <p>
- * It works by first delegating to the default injector (typically CDI). Afterwards it traverses the
- * object graph of the injected object and performs custom injection of test objects as specified by the
- * {@link Binding} class. This approach makes sure that test dependencies also find their way into
- * objects that were created by the injection framework.
+ * It works by first delegating to the default injector (typically CDI).
+ * Afterwards it traverses the object graph of the injected object and performs
+ * custom injection of test objects as specified by the {@link Binding} class.
+ * This approach makes sure that test dependencies also find their way into
+ * objects that were created by the injection framework.
* </p>
*
* @author Erik Brakkee
private class InjectionVisitor implements ObjectVisitor {
@Override
public boolean mustVisit(Class aClass) {
- if (EntityManager.class.isAssignableFrom(aClass)) {
+ if (EntityManager.class.isAssignableFrom(aClass)) {
return false;
}
return true;
}
+
@Override
public boolean mustVisit(Field aField) {
// just process any field with annotations
- return aField.getAnnotations().length > 0;
+ return aField.getAnnotations().length > 0;
}
+
@Override
public boolean mustVisit(Method aMethod) {
return false;
}
+
@Override
public boolean visitArray(Object aArray) {
return true;
}
+
@Override
public boolean visitList(List aObject) {
return true;
}
+
@Override
public boolean visitMap(Map aObject) {
return true;
}
+
@Override
public boolean visitPlainObject(Object aObject) {
performTestInjections(aObject);
return true;
}
+
@Override
public boolean visitSet(Set aSet) {
return true;
public void inject(Object aComponent) {
// basic injection
delegate.inject(aComponent);
-
+
// Now perform test injections.
ObjectTraversal traversal = new ObjectTraversal(new InjectionVisitor());
traversal.accept(aComponent);