CachedConstructorAnalyzer { public Constructor<T> getConstructor() { return constructor.get(); } CachedConstructorAnalyzer(Class<T> clazz, Collection<Class<? extends Annotation>> annotations); Constructor<T> getConstructor(); boolean hasCompatibleConstructor();  }
@Test public void testContainsSmallerNonAnnotatedConstructor() { CachedConstructorAnalyzer<ContainsSmallerNonAnnotatedConstructor> analyzer = new CachedConstructorAnalyzer<>(ContainsSmallerNonAnnotatedConstructor.class, ANNOTATIONS); assertEquals(2, analyzer.getConstructor().getParameterCount()); }
@Test public void testContainsLargerNonAnnotatedConstructor() { CachedConstructorAnalyzer<ContainsLargerNonAnnotatedConstructor> analyzer = new CachedConstructorAnalyzer<>(ContainsLargerNonAnnotatedConstructor.class, ANNOTATIONS); assertEquals(1, analyzer.getConstructor().getParameterCount()); }
@Test public void testSameNonAnnotatedConstructor() { CachedConstructorAnalyzer<SameNonAnnotatedConstructor> analyzer = new CachedConstructorAnalyzer<>(SameNonAnnotatedConstructor.class, ANNOTATIONS); assertEquals(1, analyzer.getConstructor().getParameterCount()); }
@Test public void testBothAnnotatedConstructor() { CachedConstructorAnalyzer<BothAnnotatedConstructor> analyzer = new CachedConstructorAnalyzer<>(BothAnnotatedConstructor.class, ANNOTATIONS); Constructor<BothAnnotatedConstructor> constructor = analyzer.getConstructor(); assertEquals(1, constructor.getParameterCount()); assertEquals(Integer.class, constructor.getParameterTypes()[0]); }
@Test public void testOneNonAnnotatedConstructor() { CachedConstructorAnalyzer<OneNonAnnotatedConstructor> analyzer = new CachedConstructorAnalyzer<>(OneNonAnnotatedConstructor.class, ANNOTATIONS); assertEquals(1, analyzer.getConstructor().getParameterCount()); }
@Test public void testMultiAnnotatedConstructor() { CachedConstructorAnalyzer<MultiAnnotatedConstructor> analyzer = new CachedConstructorAnalyzer<>(MultiAnnotatedConstructor.class, ANNOTATIONS); assertEquals(2, analyzer.getConstructor().getParameterCount()); }
@Test(expected = InjectionException.class) public void testUnknownAnnotatedConstructor() { new CachedConstructorAnalyzer<>(UnknownAnnotatedConstructor.class, ANNOTATIONS).getConstructor(); }
@Test(expected = InjectionException.class) public void testSingleNonAnnotatedConstructor() { new CachedConstructorAnalyzer<>(SingleNonAnnotatedConstructor.class, ANNOTATIONS).getConstructor(); }
@Test public void testDefaultConstructor() { CachedConstructorAnalyzer<DefaultConstructor> analyzer = new CachedConstructorAnalyzer<>(DefaultConstructor.class, ANNOTATIONS); assertEquals(0, analyzer.getConstructor().getParameterCount()); }
@Test public void testNoArgsConstructor() { CachedConstructorAnalyzer<NoArgsConstructor> analyzer = new CachedConstructorAnalyzer<>(NoArgsConstructor.class, ANNOTATIONS); assertEquals(0, analyzer.getConstructor().getParameterCount()); }
@Test public void testSingleAnnotatedConstructor() { CachedConstructorAnalyzer<SingleAnnotatedConstructor> analyzer = new CachedConstructorAnalyzer<>(SingleAnnotatedConstructor.class, ANNOTATIONS); assertEquals(1, analyzer.getConstructor().getParameterCount()); }
@Test public void testSingleMultiAnnotatedConstructor() { CachedConstructorAnalyzer<SingleMultiAnnotatedConstructor> analyzer = new CachedConstructorAnalyzer<>(SingleMultiAnnotatedConstructor.class, ANNOTATIONS); assertEquals(2, analyzer.getConstructor().getParameterCount()); }
@Test public void testLargestAnnotatedConstructor() { CachedConstructorAnalyzer<LargestAnnotatedConstructor> analyzer = new CachedConstructorAnalyzer<>(LargestAnnotatedConstructor.class, ANNOTATIONS); assertEquals(3, analyzer.getConstructor().getParameterCount()); }