use of dagger.internal.TestingLoader in project dagger by square.
the class InjectionTest method injectWildcardType.
@Test
public void injectWildcardType() {
class TestEntryPoint {
@Inject
List<? extends Number> listOfNumbers;
}
@Module(injects = TestEntryPoint.class)
class TestModule {
@Provides
List<? extends Number> provideList() {
return Arrays.asList(1, 2);
}
}
try {
ObjectGraph.createWith(new TestingLoader(), new TestModule());
fail();
} catch (UnsupportedOperationException expected) {
}
}
use of dagger.internal.TestingLoader in project dagger by square.
the class InjectionTest method getInstanceRequiresEntryPoint.
@Test
public void getInstanceRequiresEntryPoint() {
@Module
class TestModule {
@Provides
Integer provideInteger() {
throw new AssertionError();
}
}
ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
try {
graph.get(Integer.class);
fail();
} catch (IllegalArgumentException expected) {
}
}
use of dagger.internal.TestingLoader in project dagger by square.
the class InjectionTest method twoAtInjectConstructorsIsRejected.
@Test
public void twoAtInjectConstructorsIsRejected() {
@Module(injects = TwoAtInjectConstructors.class)
class TestModule {
@Provides
String provideString() {
throw new AssertionError();
}
}
ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
try {
graph.validate();
fail();
} catch (IllegalStateException expected) {
}
}
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) {
}
}
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) {
}
}
Aggregations