use of dagger.internal.TestingLoader in project dagger by square.
the class UnusedProviderTest method unusedProvidesMethod_whenModuleLibrary_passes.
@Test
public void unusedProvidesMethod_whenModuleLibrary_passes() throws Exception {
class EntryPoint {
}
class BagOfMoney {
}
@Module(injects = EntryPoint.class, library = true)
class TestModule {
@Provides
BagOfMoney providesMoney() {
return new BagOfMoney();
}
}
ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
graph.validate();
}
use of dagger.internal.TestingLoader in project dagger by square.
the class LazyInjectionTest method getLazyDoesNotCauseProvidesParametersToBeLoaded.
@Test
public void getLazyDoesNotCauseProvidesParametersToBeLoaded() {
@Module
class TestModule {
@Provides
Object provideObject(LazyProvidesParameter parameter) {
throw new AssertionError();
}
}
ObjectGraph.createWith(new TestingLoader(), new TestModule());
assertThat(lazyProvidesParameterLoaded).isFalse();
}
use of dagger.internal.TestingLoader in project dagger by square.
the class ModuleTest method moduleExtendingClassThrowsException.
@Test
public void moduleExtendingClassThrowsException() {
try {
ObjectGraph.createWith(new TestingLoader(), new ThreadModule());
fail();
} catch (IllegalArgumentException e) {
assertThat(e.getMessage()).startsWith("Modules must not extend from other classes: ");
}
}
use of dagger.internal.TestingLoader in project dagger by square.
the class ModuleTest method provideRawLazyFails.
@Test
public void provideRawLazyFails() {
@Module
class ProvidesRawLazyModule {
@Provides
Lazy provideObject() {
return null;
}
}
try {
ObjectGraph.createWith(new TestingLoader(), new ProvidesRawLazyModule());
fail();
} catch (IllegalStateException e) {
assertThat(e.getMessage()).startsWith("@Provides method must not return Lazy directly: ");
assertThat(e.getMessage()).endsWith("ProvidesRawLazyModule.provideObject");
}
}
use of dagger.internal.TestingLoader in project dagger by square.
the class ModuleTest method childModuleWithStaticInjection.
@Test
public void childModuleWithStaticInjection() {
@Module(includes = ModuleWithStaticInjection.class)
class TestModule {
@Provides
String provideString() {
return "injected";
}
}
ObjectGraph objectGraph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
TestStaticInjection.s = null;
objectGraph.injectStatics();
assertThat(TestStaticInjection.s).isEqualTo("injected");
}
Aggregations