@Test public void testConstraintViolationException() { ParsecValidationExceptionMapper mapper = new ParsecValidationExceptionMapper(); Set<ConstraintViolation<Entity>> violations = getViolations(); @SuppressWarnings({ "rawtypes", "unchecked" }) ConstraintViolationException cve = new ConstraintViolationException(violations); Response response = mapper.toResponse(cve); ParsecErrorResponse e = (ParsecErrorResponse) response.getEntity(); Assert.assertEquals(e.getError().getCode(), 0); Assert.assertEquals(e.getError().getMessage(), "constraint violation validate error"); Assert.assertEquals(e.getError().getDetail().size(), 1); }
@Override public Response toResponse(ConstraintViolationException e) { int code = DEFAULT_CODE; String message = DEFAULT_MSG; if (this.config != null) { Object propErrorCode = this.config.getProperty(PROP_VALIDATION_DEFAULT_ERROR_CODE); if (propErrorCode != null) { code = Integer.valueOf(propErrorCode.toString()); } Object propErrorMsg = this.config.getProperty(PROP_VALIDATION_DEFAULT_ERROR_MSG); if (propErrorMsg != null) { message = propErrorMsg.toString(); } } return toResponse(e, code, message); }
ParsecValidationExceptionMapper implements ExceptionMapper<ConstraintViolationException> { @Override public Response toResponse(ConstraintViolationException e) { int code = DEFAULT_CODE; String message = DEFAULT_MSG; if (this.config != null) { Object propErrorCode = this.config.getProperty(PROP_VALIDATION_DEFAULT_ERROR_CODE); if (propErrorCode != null) { code = Integer.valueOf(propErrorCode.toString()); } Object propErrorMsg = this.config.getProperty(PROP_VALIDATION_DEFAULT_ERROR_MSG); if (propErrorMsg != null) { message = propErrorMsg.toString(); } } return toResponse(e, code, message); } }
ParsecValidationExceptionMapper implements ExceptionMapper<ConstraintViolationException> { @Override public Response toResponse(ConstraintViolationException e) { int code = DEFAULT_CODE; String message = DEFAULT_MSG; if (this.config != null) { Object propErrorCode = this.config.getProperty(PROP_VALIDATION_DEFAULT_ERROR_CODE); if (propErrorCode != null) { code = Integer.valueOf(propErrorCode.toString()); } Object propErrorMsg = this.config.getProperty(PROP_VALIDATION_DEFAULT_ERROR_MSG); if (propErrorMsg != null) { message = propErrorMsg.toString(); } } return toResponse(e, code, message); }  }
ParsecValidationExceptionMapper implements ExceptionMapper<ConstraintViolationException> { @Override public Response toResponse(ConstraintViolationException e) { int code = DEFAULT_CODE; String message = DEFAULT_MSG; if (this.config != null) { Object propErrorCode = this.config.getProperty(PROP_VALIDATION_DEFAULT_ERROR_CODE); if (propErrorCode != null) { code = Integer.valueOf(propErrorCode.toString()); } Object propErrorMsg = this.config.getProperty(PROP_VALIDATION_DEFAULT_ERROR_MSG); if (propErrorMsg != null) { message = propErrorMsg.toString(); } } return toResponse(e, code, message); }  @Override Response toResponse(ConstraintViolationException e); }
ParsecValidationExceptionMapper implements ExceptionMapper<ConstraintViolationException> { @Override public Response toResponse(ConstraintViolationException e) { int code = DEFAULT_CODE; String message = DEFAULT_MSG; if (this.config != null) { Object propErrorCode = this.config.getProperty(PROP_VALIDATION_DEFAULT_ERROR_CODE); if (propErrorCode != null) { code = Integer.valueOf(propErrorCode.toString()); } Object propErrorMsg = this.config.getProperty(PROP_VALIDATION_DEFAULT_ERROR_MSG); if (propErrorMsg != null) { message = propErrorMsg.toString(); } } return toResponse(e, code, message); }  @Override Response toResponse(ConstraintViolationException e); static final String PROP_VALIDATION_DEFAULT_ERROR_CODE; static final String PROP_VALIDATION_DEFAULT_ERROR_MSG; }