### Question:
AbstractContextExceptionMapper implements ExceptionMapper<TException> { @Override public final Response toResponse(TException exception) { if (exception instanceof NotFoundException) { return Response.status(Response.Status.NOT_FOUND).build(); } else if (noSessionIdInQueryString() && inARequestWhereWeExpectContext()) { LOG.error(MessageFormat.format("No Session Id found for request to: {0}", context.get().getRequestURI()), exception); return Response .status(Response.Status.INTERNAL_SERVER_ERROR) .entity(ErrorStatusDto.createUnauditedErrorStatus(UUID.randomUUID(), ExceptionType.UNKNOWN, exception.getMessage())) .build(); } return handleException(exception); } AbstractContextExceptionMapper(Provider<HttpServletRequest> context); @Override final Response toResponse(TException exception);  }### Answer:
@Test public void shouldReturnInternalServerErrorWhenThereIsNoSessionIdAndTheRequestUriIsNotAKnownNoContextPath() { when(servletRequest.getParameter(Urls.SharedUrls.SESSION_ID_PARAM)).thenReturn(""); when(servletRequest.getParameter(Urls.SharedUrls.RELAY_STATE_PARAM)).thenReturn(""); String unknownUri = UUID.randomUUID().toString(); when(servletRequest.getRequestURI()).thenReturn(unknownUri); Response response = mapper.toResponse(new RuntimeException("We don't expect to see this message")); assertThat(response.getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); assertThat(response.getEntity()).isInstanceOf(ErrorStatusDto.class); }
@Test public void shouldReturnResponseStatusOfNotFoundWhenANotFoundExceptionIsThrown() { Response response = mapper.toResponse(new NotFoundException()); assertThat(response.getStatus()).isEqualTo(Response.Status.NOT_FOUND.getStatusCode()); }