@Test public void passesValidation() throws Exception { Try<User> validate = underTest.validate(new User("a", 1)); assertThat(validate.isSuccess(), is(true)); }
public <T> Try<T> validate(T underTest) { Set<ConstraintViolation<T>> violations = validator.validate(underTest); if (violations.isEmpty()) { return Try.success(underTest); } else { Exception failure = createFailure(violations, underTest); return Try.failure(failure); } }
RequestValidator { public <T> Try<T> validate(T underTest) { Set<ConstraintViolation<T>> violations = validator.validate(underTest); if (violations.isEmpty()) { return Try.success(underTest); } else { Exception failure = createFailure(violations, underTest); return Try.failure(failure); } } }
RequestValidator { public <T> Try<T> validate(T underTest) { Set<ConstraintViolation<T>> violations = validator.validate(underTest); if (violations.isEmpty()) { return Try.success(underTest); } else { Exception failure = createFailure(violations, underTest); return Try.failure(failure); } } RequestValidator(Validator validator, ObjectMapper mapper); }
RequestValidator { public <T> Try<T> validate(T underTest) { Set<ConstraintViolation<T>> violations = validator.validate(underTest); if (violations.isEmpty()) { return Try.success(underTest); } else { Exception failure = createFailure(violations, underTest); return Try.failure(failure); } } RequestValidator(Validator validator, ObjectMapper mapper); Try<T> validate(T underTest); }
RequestValidator { public <T> Try<T> validate(T underTest) { Set<ConstraintViolation<T>> violations = validator.validate(underTest); if (violations.isEmpty()) { return Try.success(underTest); } else { Exception failure = createFailure(violations, underTest); return Try.failure(failure); } } RequestValidator(Validator validator, ObjectMapper mapper); Try<T> validate(T underTest);  }