use of com.linkedin.restli.internal.server.filter.testfilters.CountFilterResponseErrorFixesError in project rest.li by linkedin.
the class TestRestLiFilterChain method testFilterInvocationResponseErrorFixesError.
@SuppressWarnings(value = "unchecked")
@Test
public void testFilterInvocationResponseErrorFixesError() throws Exception {
_restLiFilterChain = new RestLiFilterChain(Arrays.asList(_filters), _mockFilterChainCallback);
_filters[1] = new CountFilterResponseErrorFixesError();
_filters[2] = new CountFilterResponseErrorOnError();
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);
_restLiFilterChain.onRequest(_mockFilterRequestContext, _mockFilterResponseContextFactory);
assertFilterCounts(_filters[0], 1, 1, 0);
assertFilterCounts(_filters[1], 1, 0, 1);
assertFilterCounts(_filters[2], 1, 1, 0);
verify(_mockFilterChainCallback).onRequestSuccess(eq(_mockRestLiRequestData), any(RestLiCallback.class));
verify(_mockFilterChainCallback).onResponseSuccess(eq(_mockRestLiResponseData), eq(_mockResponseAttachments));
verify(_mockFilterRequestContext).getRequestData();
verify(_mockFilterResponseContext, times(3)).getResponseData();
verifyNoMoreInteractions(_mockFilterChainCallback, _mockFilterRequestContext, _mockRestLiRequestData);
}
use of com.linkedin.restli.internal.server.filter.testfilters.CountFilterResponseErrorFixesError in project rest.li by linkedin.
the class TestRestLiFilterChain method testFilterInvocationLastResponseErrorFixesError.
@SuppressWarnings(value = "unchecked")
@Test
public void testFilterInvocationLastResponseErrorFixesError() throws Exception {
_restLiFilterChain = new RestLiFilterChain(Arrays.asList(_filters), _mockFilterChainCallback);
_filters[0] = new CountFilterResponseErrorFixesError();
_filters[1] = new CountFilterResponseErrorOnError();
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);
_restLiFilterChain.onRequest(_mockFilterRequestContext, _mockFilterResponseContextFactory);
assertFilterCounts(_filters[0], 1, 0, 1);
assertFilterCounts(_filters[1], 1, 1, 0);
assertFilterCounts(_filters[2], 1, 1, 0);
verify(_mockFilterChainCallback).onRequestSuccess(eq(_mockRestLiRequestData), any(RestLiCallback.class));
verify(_mockFilterChainCallback).onResponseSuccess(eq(_mockRestLiResponseData), eq(_mockResponseAttachments));
verify(_mockFilterRequestContext).getRequestData();
verify(_mockFilterResponseContext, times(3)).getResponseData();
verifyNoMoreInteractions(_mockFilterChainCallback, _mockFilterRequestContext, _mockRestLiRequestData);
}
Aggregations