### Question:
ValidationExceptionMapper implements ExceptionMapper<ConstraintViolationException> { @Override public Response toResponse(final ConstraintViolationException e) { LOG.debug(e.getMessage()); List<ValidationErrorDTO> errors = e.getConstraintViolations() .stream() .map(ValidationErrorDTO::new) .collect(Collectors.toList()); LOG.warn("Validation failed. {} constraint violation(s) occurred.", errors.size()); return Response.status(Response.Status.BAD_REQUEST) .entity(new ApplicationErrorsDTO(errors)) .build(); }  @Override Response toResponse(final ConstraintViolationException e);  }### Answer:
@Test public void toResponse() { ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); Validator validator = validatorFactory.getValidator(); TestEntity entity = new TestEntity(); Set<ConstraintViolation<TestEntity>> constraintViolations = validator.validate(entity); ConstraintViolationException exception = new ConstraintViolationException(constraintViolations); ValidationExceptionMapper exceptionMapper = new ValidationExceptionMapper(); Response response = exceptionMapper.toResponse(exception); assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode()); ApplicationErrorsDTO applicationErrors = (ApplicationErrorsDTO) response.getEntity(); assertThat(applicationErrors.getUuid()).isNotNull(); assertThat(applicationErrors.getTimestamp()).isNotNull(); List<ErrorDTO> validationErrors = applicationErrors.getErrors(); assertThat(validationErrors).hasSize(2); Collections.sort(validationErrors, Comparator.comparing(ErrorDTO::getCode)); ErrorDTO validationError1 = validationErrors.get(0); Assertions.assertThat(validationError1.getCode()).isEqualTo("UNKNOWN"); Assertions.assertThat(validationError1.getMessage()).isEqualTo("must not be null"); ErrorDTO validationError2 = validationErrors.get(1); Assertions.assertThat(validationError2.getCode()).isEqualTo("VALUE_IS_NULL"); Assertions.assertThat(validationError2.getMessage()).isEqualTo("value must not be null"); }