final ImmutableSet<Key<?>> ab = ImmutableSet.of(a, b);
checkModule(
new AbstractModule() {
protected void configure() {
PrivateBinder one = binder().newPrivateBinder();
one.expose(ArrayList.class);
one.expose(Collection.class).annotatedWith(SampleAnnotation.class);
one.bind(List.class).to(ArrayList.class);
PrivateBinder two = binder().withSource("1 ElementsTest.java")
.newPrivateBinder().withSource("2 ElementsTest.java");
two.expose(String.class).annotatedWith(Names.named("a"));
two.expose(b);
two.bind(List.class).to(ArrayList.class);
}
},
new FailingElementVisitor() {
@Override public Void visit(PrivateElements one) {
assertEquals(collections, one.getExposedKeys());
checkElements(one.getElements(),
new FailingElementVisitor() {
@Override public <T> Void visit(Binding<T> binding) {
assertEquals(Key.get(List.class), binding.getKey());
return null;
}
}
);
return null;
}
},
new FailingElementVisitor() {
@Override public Void visit(PrivateElements two) {
assertEquals(ab, two.getExposedKeys());
assertEquals("1 ElementsTest.java", two.getSource());
checkElements(two.getElements(),
new FailingElementVisitor() {
@Override public <T> Void visit(Binding<T> binding) {
assertEquals("2 ElementsTest.java", binding.getSource());
assertEquals(Key.get(List.class), binding.getKey());
return null;