Search in sources :

Example 41 with TestingLoader

use of dagger.internal.TestingLoader in project dagger by square.

the class UnusedProviderTest method unusedSetBinding.

@Test
public void unusedSetBinding() throws Exception {
    @Module
    class TestModule {

        @Provides(type = Provides.Type.SET)
        String provideA() {
            throw new AssertionError();
        }
    }
    ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
    try {
        graph.validate();
        fail();
    } catch (IllegalStateException expected) {
    }
}
Also used : TestingLoader(dagger.internal.TestingLoader) Test(org.junit.Test)

Example 42 with TestingLoader

use of dagger.internal.TestingLoader in project dagger by square.

the class LazyInjectionTest method getLazyDoesNotCauseInjectedTypesToBeLoaded.

@Test
public void getLazyDoesNotCauseInjectedTypesToBeLoaded() {
    @Module(injects = LazyEntryPoint.class)
    class TestModule {
    }
    ObjectGraph.createWith(new TestingLoader(), new TestModule());
    assertThat(lazyEntryPointLoaded).isFalse();
}
Also used : TestingLoader(dagger.internal.TestingLoader) Test(org.junit.Test)

Example 43 with TestingLoader

use of dagger.internal.TestingLoader in project dagger by square.

the class MembersInjectorTest method instanceInjectionOfNonStaticInnerFailsEarly.

@Test
public void instanceInjectionOfNonStaticInnerFailsEarly() {
    class TestEntryPoint {

        @Inject
        NonStaticInner nonStaticInner;
    }
    @Module(injects = TestEntryPoint.class)
    class TestModule {
    }
    ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
    try {
        graph.get(TestEntryPoint.class);
        fail();
    } catch (IllegalStateException expected) {
    }
}
Also used : TestingLoader(dagger.internal.TestingLoader) Test(org.junit.Test)

Example 44 with TestingLoader

use of dagger.internal.TestingLoader in project dagger by square.

the class MembersInjectorTest method injectionOfUnconstructableFails.

@Test
public void injectionOfUnconstructableFails() {
    class TestEntryPoint {

        @Inject
        Unconstructable unconstructable;
    }
    @Module(injects = TestEntryPoint.class)
    class TestModule {
    }
    ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
    try {
        graph.get(TestEntryPoint.class);
        fail();
    } catch (IllegalStateException expected) {
    }
}
Also used : TestingLoader(dagger.internal.TestingLoader) Test(org.junit.Test)

Example 45 with TestingLoader

use of dagger.internal.TestingLoader in project dagger by square.

the class MembersInjectorTest method rejectUnconstructableSingleton.

@Test
public void rejectUnconstructableSingleton() {
    class TestEntryPoint {

        @Inject
        MembersInjector<UnconstructableSingleton> membersInjector;
    }
    @Module(injects = TestEntryPoint.class)
    class TestModule {
    }
    ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
    try {
        graph.get(TestEntryPoint.class);
        fail();
    } catch (IllegalStateException expected) {
    }
}
Also used : TestingLoader(dagger.internal.TestingLoader) Test(org.junit.Test)

Aggregations

TestingLoader (dagger.internal.TestingLoader)65 Test (org.junit.Test)65 ArrayList (java.util.ArrayList)3 Collections.emptySet (java.util.Collections.emptySet)3 LinkedHashSet (java.util.LinkedHashSet)3 Set (java.util.Set)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 AbstractList (java.util.AbstractList)2 Callable (java.util.concurrent.Callable)2 Future (java.util.concurrent.Future)2 List (java.util.List)1 RandomAccess (java.util.RandomAccess)1 Provider (javax.inject.Provider)1