### Question:
HandlerChainImpl implements HandlerChain { @Override public void proceed() { if (pos < handlers.size()) { AnnotationHandler<Annotation> handler = handlers.get(pos++); Annotation annotation = element.getAnnotation(handler.handles()); Assert.notNull(annotation, "Could not find annotation [" + handler.handles().getName() + "] on: " + element); handler.process(context, annotation, this); } } @SuppressWarnings("unchecked")  HandlerChainImpl(ClassContext context, AnnotatedElement element, List<? extends AnnotationHandler<?>> handlers); @Override void proceed();  }### Answer:
@Test public void testNoHandlers() { List<String> log = new ArrayList<String>(); HandlerChainImpl chain = new HandlerChainImpl( null, TestAnnotationHandler.class, Collections.<AnnotationHandler<Annotation>> emptyList()); chain.proceed(); assertEquals(0, log.size()); }
@Test public void testOneHandler() { List<String> log = new ArrayList<String>(); HandlerChainImpl chain = new HandlerChainImpl(null, TestAnnotationHandler.class, Arrays.asList( new TestAnnotationHandler("Handler", log) )); chain.proceed(); assertEquals(Arrays.asList( "Before: Handler", "After: Handler" ), log); }
@Test public void testTwoHandlers() { List<String> log = new ArrayList<String>(); HandlerChainImpl chain = new HandlerChainImpl(new ClassContextImpl(ConfigurationBuilder.begin(), TestAnnotationHandler.class), TestAnnotationHandler.class, Arrays.asList( new TestAnnotationHandler("First", log), new TestAnnotationHandler("Second", log) )); chain.proceed(); assertEquals(Arrays.asList( "Before: First", "Before: Second", "After: Second", "After: First" ), log); }