示例#1
0
  @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");
  }
示例#2
0
  @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");
  }
示例#3
0
 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;
 }