@Test public void childModuleWithManualConstruction() { @Module(injects = TestEntryPoint.class, includes = ModuleWithConstructor.class) class TestModule {} ObjectGraph objectGraph = ObjectGraph.create(new ModuleWithConstructor("a"), new TestModule()); TestEntryPoint entryPoint = new TestEntryPoint(); objectGraph.inject(entryPoint); assertThat(entryPoint.s).isEqualTo("a"); }
@Test public void childModuleWithChildModule() { @Module(injects = TestEntryPoint.class, includes = ModuleWithChildModule.class) class TestModule {} ObjectGraph objectGraph = ObjectGraph.create(new TestModule()); TestEntryPoint entryPoint = new TestEntryPoint(); objectGraph.inject(entryPoint); assertThat(entryPoint.s).isEqualTo("injected"); }
private <T> T injectWithModule(T ep, Object... modules) { // TODO(cgruber): Make og.inject(foo) return foo properly. ObjectGraph og = ObjectGraph.get(modules); og.inject(ep); return ep; }