### Question:
MethodInterceptorChain { public Object invoke(Object[] arguments) { try { return new MethodInterceptorIterator(arguments).proceed(); } catch (Throwable e) { throw new TransfuseInjectionException("Error while invoking Method Interceptor", e); } } MethodInterceptorChain(MethodExecution methodExecution, Object proxy, MethodInterceptor... methodInterceptorChains); Object invoke(Object[] arguments);  }### Answer:
@Test public void testMethodChain() throws Throwable { MethodInterceptor[] interceptors = new MethodInterceptor[INTERCEPTOR_SIZE]; for (int i = 0; i < INTERCEPTOR_SIZE; i++) { interceptors[i] = mock(MethodInterceptor.class); final ArgumentCaptor<MethodInvocation> invocationCapture = ArgumentCaptor.forClass(MethodInvocation.class); when(interceptors[i].invoke(invocationCapture.capture())).thenAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return invocationCapture.getValue().proceed(); } }); } MethodInterceptorChain.MethodExecution execution = mock(MethodInterceptorChain.MethodExecution.class); MethodInterceptorChain interceptorChain = new MethodInterceptorChain(execution, proxy, interceptors); interceptorChain.invoke(ARGUMENTS); for (MethodInterceptor interceptor : interceptors) { verify(interceptor).invoke(any(MethodInvocation.class)); } verify(execution).invoke(); }
@Test public void testGetters() throws Exception { final Method mockMethod = MethodInterceptorChainTest.class.getMethod("targetMethod"); MethodInterceptorChain.MethodExecution methodExecution = mock(MethodInterceptorChain.MethodExecution.class); when(methodExecution.getMethod()).thenReturn(mockMethod); MethodInterceptorChain interceptorChain = new MethodInterceptorChain(methodExecution, proxy, new MethodInterceptor() { @Override public Object invoke(MethodInvocation invocation) throws Throwable { assertEquals(mockMethod, invocation.getMethod()); assertArrayEquals(ARGUMENTS, invocation.getArguments()); assertEquals(mockMethod, invocation.getStaticPart()); return invocation.proceed(); } }); interceptorChain.invoke(ARGUMENTS); verify(methodExecution, times(2)).getMethod(); }