@Test public void testGetDependencies() throws Exception { AbstractInjectionProvider<SomeInjectedClass> underTest = new AbstractInjectionProvider<SomeInjectedClass>(Key.get(SomeInjectedClass.class)); boolean foundC1 = false; boolean foundC2 = false; boolean foundV1 = false; boolean foundV2 = false; boolean foundF1 = false; for (Dependency<?> dependency : underTest.getDependencies()) { if (dependency.getInjectionPoint().getMember() instanceof Constructor) { if (dependency.getParameterIndex() == 0 && dependency.getKey().equals(keyC1)) { foundC1 = true; } else if (dependency.getParameterIndex() == 1 && dependency.getKey().equals(keyC2)) { foundC2 = true; } else { fail("Did not expect constructor dependency with key " + dependency.getKey() + " at parameter index " + dependency.getParameterIndex()); } } else if (dependency.getInjectionPoint().getMember() instanceof Method) { if (dependency.getKey().equals(keyV1)) { foundV1 = true; } else if (dependency.getKey().equals(keyV2)) { foundV2 = true; } else { fail("Did not expect method dependency with key " + dependency.getKey()); } } else if (dependency.getInjectionPoint().getMember() instanceof Field) { if (dependency.getKey().equals(keyF1)) { foundF1 = true; } else { fail("Did not expect field dependency with key " + dependency.getKey()); } } else { fail("Did not expect dependency with key " + dependency.getKey()); } } assertTrue("Did not find dependency C1", foundC1); assertTrue("Did not find dependency C2", foundC2); assertTrue("Did not find dependency V1", foundV1); assertTrue("Did not find dependency V2", foundV2); assertTrue("Did not find dependency F1", foundF1); }
public Set<Dependency<?>> getDependencies() { return dependencies; }
AbstractInjectionProvider implements ProviderWithDependencies<T> { public Set<Dependency<?>> getDependencies() { return dependencies; } }
AbstractInjectionProvider implements ProviderWithDependencies<T> { public Set<Dependency<?>> getDependencies() { return dependencies; } AbstractInjectionProvider(Key<T> key); }
AbstractInjectionProvider implements ProviderWithDependencies<T> { public Set<Dependency<?>> getDependencies() { return dependencies; } AbstractInjectionProvider(Key<T> key); T get(); Set<Dependency<?>> getDependencies(); }
AbstractInjectionProvider implements ProviderWithDependencies<T> { public Set<Dependency<?>> getDependencies() { return dependencies; } AbstractInjectionProvider(Key<T> key); T get(); Set<Dependency<?>> getDependencies();  }