### Question:
SamlProxyDuplicateRequestExceptionMapper extends AbstractContextExceptionMapper<SamlDuplicateRequestIdException> { @Override protected Response handleException(SamlDuplicateRequestIdException exception) { UUID errorId = UUID.randomUUID(); eventSinkMessageSender.audit(exception, errorId, getSessionId().orElse(SessionId.NO_SESSION_CONTEXT_IN_ERROR)); levelLogger.log(ExceptionType.INVALID_SAML_DUPLICATE_REQUEST_ID.getLevel(), exception, errorId); return Response.status(BAD_REQUEST) .entity(ErrorStatusDto.createAuditedErrorStatus(errorId, INVALID_SAML_DUPLICATE_REQUEST_ID)) .build(); } @Inject  SamlProxyDuplicateRequestExceptionMapper(
            Provider<HttpServletRequest> contextProvider,
            EventSinkMessageSender eventSinkMessageSender,
            LevelLoggerFactory<SamlProxyDuplicateRequestExceptionMapper> levelLoggerFactory);   }### Answer:
@Test public void shouldCreateAuditedErrorResponseForDuplicateRequestIdError() throws Exception { SamlDuplicateRequestIdException exception = new SamlDuplicateRequestIdException("error", new RuntimeException(), Level.DEBUG); SessionId sessionId = SessionId.createNewSessionId(); when(httpServletRequest.getParameter(Urls.SharedUrls.SESSION_ID_PARAM)).thenReturn(sessionId.getSessionId()); Response response = exceptionMapper.handleException(exception); ErrorStatusDto responseEntity = (ErrorStatusDto) response.getEntity(); assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode()); assertThat(responseEntity.isAudited()).isTrue(); assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML_DUPLICATE_REQUEST_ID); verify(eventSinkMessageSender).audit(eq(exception), any(UUID.class), eq(sessionId)); }