use of com.linkedin.restli.internal.server.filter.FilterResourceModelImpl in project rest.li by linkedin.
the class TestRestLiValidationFilter method testSkipRequestValidation.
/**
* Ensures that the validation filter skips request validation by feeding it with invalid data, and ensuring that it
* never throws an error.
*/
@Test(dataProvider = "invalidRequests")
@SuppressWarnings({ "unchecked" })
public void testSkipRequestValidation(ResourceModel resourceModel, ResourceMethod resourceMethod, RestLiRequestData restLiRequestData) {
when(filterRequestContext.getRequestData()).thenReturn(restLiRequestData);
when(filterRequestContext.getMethodType()).thenReturn(resourceMethod);
when(filterRequestContext.getFilterResourceModel()).thenReturn(new FilterResourceModelImpl(resourceModel));
when(filterRequestContext.getRestliProtocolVersion()).thenReturn(AllProtocolVersions.LATEST_PROTOCOL_VERSION);
RestLiValidationFilter validationFilter = new RestLiValidationFilter(Collections.emptyList(), new MockValidationErrorHandler()) {
@Override
protected boolean shouldValidateOnRequest(FilterRequestContext requestContext) {
return false;
}
};
try {
validationFilter.onRequest(filterRequestContext);
} catch (RestLiServiceException ex) {
Assert.fail("An unexpected exception was thrown on request in the validation filter.", ex);
}
}
Aggregations