JavaxInjectionConfig implements InjectionConfig { @Override public ConstructorSelector provideConstructorSelector() { return mConstructorSelector; }  @Override ConstructorSelector provideConstructorSelector(); @Override List<Class<? extends Annotation>> provideInjectableFieldAnnotations(); @Override List<Class<? extends Annotation>> provideInjectableMethodAnnotations();  }
@Test public void testFindInjectConstructor() { Constructor<TestClassWithMultipleConstructorsButOnlyOneInject> constructor = mInjectionConfig.provideConstructorSelector() .chooseConstructor(TypeToken.of(TestClassWithMultipleConstructorsButOnlyOneInject.class)); assertThat(constructor).isNotNull(); assertThat(constructor.isAnnotationPresent(Inject.class)).isTrue(); assertThat(constructor.getParameterCount()).isEqualTo(2); }
@Test(expected = MultipleInjectConstructorException.class) public void testMultipleInjectConstructors() { Constructor<TestClassWithTwoInjectAnnotations> constructor = mInjectionConfig.provideConstructorSelector() .chooseConstructor(TypeToken.of(TestClassWithTwoInjectAnnotations.class)); }
@Test public void testFindFallbackConstructor() { Constructor<TestClassWithEmptyFallback> constructor = mInjectionConfig.provideConstructorSelector() .chooseConstructor(TypeToken.of(TestClassWithEmptyFallback.class)); assertThat(constructor).isNotNull(); assertThat(constructor.isAnnotationPresent(Inject.class)).isFalse(); assertThat(constructor.getParameterCount()).isEqualTo(0); }
@Test public void testNoValidConstructor() { Constructor<TestClassWithNoValidConstructor> constructor = mInjectionConfig.provideConstructorSelector() .chooseConstructor(TypeToken.of(TestClassWithNoValidConstructor.class)); assertThat(constructor).isNull(); }
@Test public void testFindFallbackConstructorWhenNoneDeclared() { Constructor<TestClassWithNoDefinedConstructors> constructor = mInjectionConfig.provideConstructorSelector() .chooseConstructor(TypeToken.of(TestClassWithNoDefinedConstructors.class)); assertThat(constructor).isNotNull(); assertThat(constructor.isAnnotationPresent(Inject.class)).isFalse(); assertThat(constructor.getParameterCount()).isEqualTo(0); }