use of org.baeldung.javaxval.methodvalidation.model.ReservationManagement in project tutorials by eugenp.
the class ValidationIntegrationTest method whenValidationWithInvalidMethodParameters_thenCorrectNumberOfVoilations.
@Test
public void whenValidationWithInvalidMethodParameters_thenCorrectNumberOfVoilations() throws NoSuchMethodException {
ReservationManagement object = new ReservationManagement();
Method method = ReservationManagement.class.getMethod("createReservation", LocalDate.class, int.class, Customer.class);
Object[] parameterValues = { LocalDate.now(), 0, null };
Set<ConstraintViolation<ReservationManagement>> violations = executableValidator.validateParameters(object, method, parameterValues);
assertEquals(3, violations.size());
}
use of org.baeldung.javaxval.methodvalidation.model.ReservationManagement in project tutorials by eugenp.
the class ValidationIntegrationTest method whenValidationWithInvalidReturnValue_thenCorrectNumberOfVoilations.
@Test
public void whenValidationWithInvalidReturnValue_thenCorrectNumberOfVoilations() throws NoSuchMethodException {
ReservationManagement object = new ReservationManagement();
Method method = ReservationManagement.class.getMethod("getAllCustomers");
Object returnValue = Collections.<Customer>emptyList();
Set<ConstraintViolation<ReservationManagement>> violations = executableValidator.validateReturnValue(object, method, returnValue);
assertEquals(1, violations.size());
}
use of org.baeldung.javaxval.methodvalidation.model.ReservationManagement in project tutorials by eugenp.
the class ValidationIntegrationTest method whenCrossParameterValidationWithValidParameters_thenZeroVoilations.
@Test
public void whenCrossParameterValidationWithValidParameters_thenZeroVoilations() throws NoSuchMethodException {
ReservationManagement object = new ReservationManagement();
Method method = ReservationManagement.class.getMethod("createReservation", LocalDate.class, LocalDate.class, Customer.class);
Object[] parameterValues = { LocalDate.now().plusDays(1), LocalDate.now().plusDays(2), new Customer("John", "Doe") };
Set<ConstraintViolation<ReservationManagement>> violations = executableValidator.validateParameters(object, method, parameterValues);
assertEquals(0, violations.size());
}
Aggregations