@Test
public void test_stanzabroker_substitution_chaining() throws ProtocolException {

    StanzaBroker secondStanzaBroker = mock(StanzaBroker.class);
    StanzaBroker thirdStanzaBroker = mock(StanzaBroker.class);
    InterceptorMock firstInterceptor = new InterceptorMock().replaceStanzaBroker(secondStanzaBroker);
    InterceptorMock secondInterceptor = new InterceptorMock().replaceStanzaBroker(thirdStanzaBroker);
    List<StanzaHandlerInterceptor> interceptors = new ArrayList<>();
    interceptors.add(firstInterceptor);
    interceptors.add(secondInterceptor);
    new SimpleStanzaHandlerInterceptorChain(stanzaHandler, interceptors).intercept(stanza, serverRuntimeContext,
            false, sessionContext, sessionStateHolder, firstStanzaBroker);
    assertEquals(firstStanzaBroker, firstInterceptor.receivedStanzaBroker);
    assertEquals(secondStanzaBroker, secondInterceptor.receivedStanzaBroker);
    verify(stanzaHandler).execute(stanza, serverRuntimeContext, false, sessionContext, sessionStateHolder,
            thirdStanzaBroker);
}