use of com.linkedin.restli.internal.server.filter.testfilters.CountFilter in project rest.li by linkedin.
the class TestRestLiFilterChain method testFilterInvocationSuccess.
@SuppressWarnings(value = "unchecked")
@Test
public void testFilterInvocationSuccess() throws Exception {
_restLiFilterChain = new RestLiFilterChain(Arrays.asList(_filters), _mockFilterChainDispatcher, _mockFilterChainCallback);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
_restLiFilterChain.onResponse(_mockFilterRequestContext, _mockFilterResponseContext);
return null;
}
}).when(_mockFilterChainDispatcher).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);
for (CountFilter filter : _filters) {
assertEquals(filter.getNumRequests(), 1);
assertEquals(filter.getNumResponses(), 1);
assertEquals(filter.getNumErrors(), 0);
}
verify(_mockFilterRequestContext).getRequestData();
verify(_mockFilterChainDispatcher).onRequestSuccess(eq(_mockRestLiRequestData), any(RestLiCallback.class));
verify(_mockFilterChainCallback).onResponseSuccess(_mockRestLiResponseData);
verifyNoMoreInteractions(_mockFilterChainCallback, _mockFilterRequestContext, _mockRestLiRequestData);
}
use of com.linkedin.restli.internal.server.filter.testfilters.CountFilter in project rest.li by linkedin.
the class TestRestLiFilterChain method resetMocks.
@AfterMethod
protected void resetMocks() {
reset(_mockFilterChainDispatcher, _mockFilterChainCallback, _mockFilterRequestContext, _mockFilterResponseContext, _mockRestLiRequestData, _mockRestLiResponseData);
_filters = new CountFilter[] { new CountFilter(), new CountFilter(), new CountFilter() };
}
use of com.linkedin.restli.internal.server.filter.testfilters.CountFilter in project rest.li by linkedin.
the class TestRestLiFilterChain method init.
@BeforeMethod
protected void init() {
_filters = new CountFilter[] { new CountFilter(), new CountFilter(), new CountFilter() };
when(_mockFilterResponseContextFactory.getRequestContext()).thenAnswer(invocation -> new RequestContext());
when(_method.getContext()).thenAnswer(invocation -> new ResourceContextImpl());
}
Aggregations