The problem could be addressed using Element SPI. Subclass the DefaultElementVisitor and write the implementation for visiting the Bindings you need to test. For e.g.
public class MyElementVisitor extends DefaultElementVisitor<Void>{
@Override
public <String> Void visit(Binding<String> binding) {
Key<String> key = binding.getKey();
System.out.println("Key :" + key.getTypeLiteral());
System.out.println("Annotation : " + key.getAnnotation());
System.out.println("Source : " + binding.getSource());
return visitOther(binding);
}
}
Test code could be written in the visit(...) method.
Such bindings which are termed as Module Bindings(hence are open to manipulation), are incomplete.The reason is there is no implementation present to be injected. To visit these bindings we need to iterate over modules we intend to visit. Prepare a list of modules and pass the reference to it as the second argument to Elements.getElements().
MyElementVisitor defaultElementVisitor = new MyElementVisitor();
for(Element element : Elements.getElements(Stage.DEVELOPMENT,modules)){
element.acceptVisitor(defaultElementVisitor);
}
Advantage to this method is that you do not need to prepare Injector for analysis.