Search in sources :

Example 1 with CountFilterResponseErrorThrowsError

use of com.linkedin.restli.internal.server.filter.testfilters.CountFilterResponseErrorThrowsError in project rest.li by linkedin.

the class TestRestLiFilterChain method testFilterInvocationResponseErrorThrowsError.

@SuppressWarnings(value = "unchecked")
@Test
public void testFilterInvocationResponseErrorThrowsError() throws Exception {
    _restLiFilterChain = new RestLiFilterChain(Arrays.asList(_filters), _mockFilterChainCallback);
    _filters[1] = new CountFilterResponseErrorThrowsError();
    doAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            _restLiFilterChain.onResponse(_mockFilterRequestContext, _mockFilterResponseContext, _mockResponseAttachments);
            return null;
        }
    }).when(_mockFilterChainCallback).onRequestSuccess(eq(_mockRestLiRequestData), any(RestLiCallback.class));
    when(_mockFilterRequestContext.getRequestData()).thenReturn(_mockRestLiRequestData);
    when(_mockFilterResponseContext.getResponseData()).thenReturn(_mockRestLiResponseData);
    when(_mockFilterResponseContextFactory.fromThrowable(any(Throwable.class))).thenReturn(_mockFilterResponseContext);
    _restLiFilterChain.onRequest(_mockFilterRequestContext, _mockFilterResponseContextFactory);
    verifySecondFilterResponseException();
}
Also used : CountFilterResponseErrorThrowsError(com.linkedin.restli.internal.server.filter.testfilters.CountFilterResponseErrorThrowsError) InvocationOnMock(org.mockito.invocation.InvocationOnMock) RestLiCallback(com.linkedin.restli.internal.server.RestLiCallback) Test(org.testng.annotations.Test)

Aggregations

RestLiCallback (com.linkedin.restli.internal.server.RestLiCallback)1 CountFilterResponseErrorThrowsError (com.linkedin.restli.internal.server.filter.testfilters.CountFilterResponseErrorThrowsError)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Test (org.testng.annotations.Test)1