@Test public void validateAnnotatedNOk() { product.setPrice(BigDecimal.TEN.negate()); try { validator.validate(product); Assert.fail("price is 0, validation should have failed"); } catch (ValidationException e) { } }
public void validate(T value) throws ValidationException { Set<ConstraintViolation<T>> violations = validator.validate(value); if(!violations.isEmpty()) { throw new ValidationException("Validation failed for " + value + ": " + violationsToString(violations)); } }
BeanValidationValidator implements Validator<T> { public void validate(T value) throws ValidationException { Set<ConstraintViolation<T>> violations = validator.validate(value); if(!violations.isEmpty()) { throw new ValidationException("Validation failed for " + value + ": " + violationsToString(violations)); } } }
BeanValidationValidator implements Validator<T> { public void validate(T value) throws ValidationException { Set<ConstraintViolation<T>> violations = validator.validate(value); if(!violations.isEmpty()) { throw new ValidationException("Validation failed for " + value + ": " + violationsToString(violations)); } }  }
BeanValidationValidator implements Validator<T> { public void validate(T value) throws ValidationException { Set<ConstraintViolation<T>> violations = validator.validate(value); if(!violations.isEmpty()) { throw new ValidationException("Validation failed for " + value + ": " + violationsToString(violations)); } }  void validate(T value); }
BeanValidationValidator implements Validator<T> { public void validate(T value) throws ValidationException { Set<ConstraintViolation<T>> violations = validator.validate(value); if(!violations.isEmpty()) { throw new ValidationException("Validation failed for " + value + ": " + violationsToString(violations)); } }  void validate(T value);  }