use of io.crnk.spring.internal.AccessDeniedExceptionMapper in project crnk-framework by crnk-project.
the class SpringSecurityExceptionMapperTest method testAccessDenied.
@Test
public void testAccessDenied() {
AccessDeniedExceptionMapper mapper = new AccessDeniedExceptionMapper();
AccessDeniedException exception = new AccessDeniedException("hi");
ErrorResponse response = mapper.toErrorResponse(exception);
Iterable<ErrorData> errors = response.getErrors();
Iterator<ErrorData> iterator = errors.iterator();
ErrorData data = iterator.next();
Assert.assertFalse(iterator.hasNext());
Assert.assertEquals("403", data.getStatus());
Assert.assertEquals("hi", data.getCode());
Assert.assertTrue(mapper.accepts(response));
AccessDeniedException fromErrorResponse = mapper.fromErrorResponse(response);
Assert.assertEquals("hi", fromErrorResponse.getMessage());
}
Aggregations