public void onRequest(FilterRequestContext requestContext,
                        RestLiFilterResponseContextFactory filterResponseContextFactory)
  {
    // Initiate the filter chain iterator. The RestLiCallback will be passed to the method invoker at the end of the
    // filter chain.
    _filterChainIterator.onRequest(requestContext, filterResponseContextFactory,
                                   new RestLiCallback(requestContext, filterResponseContextFactory, this));
  }
@SuppressWarnings("unchecked")
  @Test
  public void testFilterInvocationRequestOnError() throws Exception
  {
    _restLiFilterChain = new RestLiFilterChain(Arrays.asList(_filters),
        _mockFilterChainDispatcher, _mockFilterChainCallback);
    _filters[1] = new CountFilterRequestOnError();
    when(_responseHandler.buildExceptionResponseData(eq(_method), any(RestLiServiceException.class), anyMap(), anyList()))
        .thenReturn(_mockRestLiResponseData);
    when(_mockFilterResponseContextFactory.fromThrowable(any(Throwable.class))).thenReturn(_mockFilterResponseContext);
    when(_mockFilterResponseContext.getResponseData()).thenReturn(_mockRestLiResponseData);
    when(_mockRestLiResponseData.getResponseEnvelope()).thenReturn(mock(RestLiResponseEnvelope.class));

    _restLiFilterChain.onRequest(_mockFilterRequestContext,
                                 new RestLiFilterResponseContextFactory(_request, _method, _responseHandler));

    verifySecondFilterRequestException();
  }