Examples of validateConstructorParameters()


Examples of javax.validation.executable.ExecutableValidator.validateConstructorParameters()

  @Test
  public void shouldRaiseNoConstraintViolation() throws NoSuchMethodException {

    ExecutableValidator methodValidator = validator.forExecutables();
    Constructor<Book03> constructor = Book03.class.getConstructor(String.class, Float.class, String.class, String.class, Integer.class, Boolean.class);
    Set<ConstraintViolation<Book03>> violations = methodValidator.validateConstructorParameters(constructor, new Object[]{"H2G2", 12.5f, "Best IT Scifi Book", "1234-4566-9876", 247, false});
    assertEquals(0, violations.size());
  }

  @Test
  public void shouldRaiseConstraintViolationCausePriceLow() throws NoSuchMethodException {
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator.validateConstructorParameters()

  @Test
  public void shouldRaiseConstraintViolationCausePriceLow() throws NoSuchMethodException {

    ExecutableValidator methodValidator = validator.forExecutables();
    Constructor<Book03> constructor = Book03.class.getConstructor(String.class, Float.class, String.class, String.class, Integer.class, Boolean.class);
    Set<ConstraintViolation<Book03>> violations = methodValidator.validateConstructorParameters(constructor, new Object[]{"H2G2", 0.5f, "Best IT Scifi Book", "1234-4566-9876", 247, false});
    displayContraintViolations(violations);
    assertEquals(1, violations.size());
  }

  @Test
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator.validateConstructorParameters()

  @Test
  public void shouldRaiseConstraintsViolationCauseTitleAndPriceNull() throws NoSuchMethodException {

    ExecutableValidator methodValidator = validator.forExecutables();
    Constructor<Book03> constructor = Book03.class.getConstructor(String.class, Float.class, String.class, String.class, Integer.class, Boolean.class);
    Set<ConstraintViolation<Book03>> violations = methodValidator.validateConstructorParameters(constructor, new Object[]{null, null, null, null, null, null});
    displayContraintViolations(violations);
    assertEquals(2, violations.size());
  }

  private void displayContraintViolations(Set<ConstraintViolation<Book03>> constraintViolations) {
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator.validateConstructorParameters()

        Person.class
    );
    Object[] parameterValues = new Object[] { null, null };

    //when
    Set<ConstraintViolation<MovieStudio>> constraintViolations = executableValidator.validateConstructorParameters(
        constructor,
        parameterValues
    );

    //then
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator.validateConstructorParameters()

   * in case at least one constraint violation occurred either during parameter or return value validation.
   */
  @AroundConstruct
  public void validateConstructorInvocation(InvocationContext ctx) throws Exception {
    ExecutableValidator executableValidator = validator.forExecutables();
    Set<ConstraintViolation<Object>> violations = executableValidator.validateConstructorParameters(
        ctx.getConstructor(),
        ctx.getParameters()
    );

    if ( !violations.isEmpty() ) {
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator.validateConstructorParameters()

    ExecutableValidator methodValidator = validator.forExecutables();
    Constructor<MyBean2> constructor = MyBean2.class
        .getConstructor(parameter.getClass());

    Set<ConstraintViolation<MyBean2>> constraints = methodValidator
        .validateConstructorParameters(constructor, new Object[] {parameter});

    ConstraintViolation<MyBean2> violation = constraints.iterator().next();
    assertThat(constraints.size(), equalTo(1));
    assertThat(violation.getMessageTemplate(), equalTo("{javax.validation.constraints.NotNull.message}"));
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator.validateConstructorParameters()

        ExecutableValidator methodValidator = validator.forExecutables();
    Constructor<MyBean2> constructor = MyBean2.class
        .getConstructor(parameter.getClass());

    Set<ConstraintViolation<MyBean2>> constraints = methodValidator
        .validateConstructorParameters(constructor, new Object[] {parameter});

    assertThat(constraints.isEmpty(), equalTo(true));
  }
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator.validateConstructorParameters()

   */
  @AroundConstruct
  @SuppressWarnings("unchecked")
  public void validateConstructorInvocation(InvocationContext ctx) throws Exception {
    ExecutableValidator executableValidator = validator.forExecutables();
    Set<ConstraintViolation<Object>> violations = executableValidator.validateConstructorParameters(
        ctx.getConstructor(),
        ctx.getParameters()
    );

    if ( !violations.isEmpty() ) {
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator.validateConstructorParameters()

   */
  @AroundConstruct
  @SuppressWarnings("unchecked")
  public void validateConstructorInvocation(InvocationContext ctx) throws Exception {
    ExecutableValidator executableValidator = validator.forExecutables();
    Set<ConstraintViolation<Object>> violations = executableValidator.validateConstructorParameters(
        ctx.getConstructor(),
        ctx.getParameters()
    );

    if ( !violations.isEmpty() ) {
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator.validateConstructorParameters()

   * in case at least one constraint violation occurred either during parameter or return value validation.
   */
  @AroundConstruct
  public void validateConstructorInvocation(InvocationContext ctx) throws Exception {
    ExecutableValidator executableValidator = validator.forExecutables();
    Set<ConstraintViolation<Object>> violations = executableValidator.validateConstructorParameters(
        ctx.getConstructor(),
        ctx.getParameters()
    );

    if ( !violations.isEmpty() ) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.