DaggerScreenScoopFactory extends ScreenScoopFactory { @Override protected Scoop addServices(Scoop.Builder scoopBuilder, Screen screen, Scoop parentScoop) { DaggerInjector parentDagger = DaggerInjector.fromScoop(parentScoop); DaggerModule daggerModule = screen.getClass().getAnnotation(DaggerModule.class); if (daggerModule == null) { return scoopBuilder.service(DaggerInjector.SERVICE_NAME, parentDagger).build(); } DaggerInjector screenInjector; try { final Object module = daggerModule.value().newInstance(); screenInjector = parentDagger.extend(module); } catch (Throwable e) { throw new RuntimeException("Failed to instantiate module for screen: " + screen.getClass().getSimpleName(), e); } return scoopBuilder .service(DaggerInjector.SERVICE_NAME, screenInjector).build(); }    }
@Test public void testAddModule() { when(mockDaggerInjector.extend(any(TestModule.class))).thenReturn(mockDaggerInjector); assertNotNull(daggerScreenScooper.addServices(scoopBuilder, new TestScreen(), scoop)); }
@Test public void testNoModule() { assertNotNull(daggerScreenScooper.addServices(scoopBuilder, new TestNoModuleScreen(), scoop)); }