Examples of validateProperty()


Examples of javax.validation.Validator.validateProperty()

    catch ( IllegalArgumentException e ) {
      // success
    }

    try {
      validator.validateProperty( customer, "orders[].foobar" );
      fail();
    }
    catch ( IllegalArgumentException e ) {
      // success
    }
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

      // success
    }

    // firstname exists, but the capitalisation is wrong
    try {
      validator.validateProperty( customer, "FirstName" );
      fail();
    }
    catch ( IllegalArgumentException e ) {
      // success
    }
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

    Order order = new Order();
    customer.addOrder( order );


    try {
      validator.validateProperty( customer, null );
      fail();
    }
    catch ( IllegalArgumentException e ) {
      // success
    }
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

    Customer customer = new Customer();
    Order order = new Order();
    customer.addOrder( order );

    try {
      validator.validateProperty( customer, "" );
      fail();
    }
    catch ( IllegalArgumentException e ) {
      // success
    }
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

    address.setStreet( null );
    address.setZipCode( null );
    String townInNorthWales = "Llanfairpwllgwyngyllgogerychwyrndrobwyll-llantysiliogogogoch";
    address.setCity( townInNorthWales );

    Set<ConstraintViolation<Address>> constraintViolations = validator.validateProperty( address, "city" );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    assertCorrectConstraintTypes( constraintViolations, Size.class );
    ConstraintViolation<Address> violation = constraintViolations.iterator().next();
    assertConstraintViolation( violation, Address.class, townInNorthWales, "city" );
    assertCorrectConstraintViolationMessages(
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

    assertCorrectConstraintViolationMessages(
        constraintViolations, "City name cannot be longer than 30 characters."
    );

    address.setCity( "London" );
    constraintViolations = validator.validateProperty( address, "city" );
    assertCorrectNumberOfViolations( constraintViolations, 0 );
  }

  @Test
  @SpecAssertions({
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

    morgan.addPlayedWith( charlie );
    morgan.addPlayedWith( clint );
    clint.addPlayedWith( morgan );

    String property = "playedWith[0].playedWith[1].lastName";
    Set<ConstraintViolation<ActorListBased>> constraintViolations = validator.validateProperty(
        clint, property
    );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    assertCorrectConstraintTypes( constraintViolations, NotNull.class );
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

    Customer customer = new Customer();
    Order order = new Order();
    customer.addOrder( order );

    Set<ConstraintViolation<Customer>> constraintViolations = validator.validateProperty( customer, "orders" );
    assertCorrectNumberOfViolations( constraintViolations, 0 );
  }

  @Test(expectedExceptions = ValidationException.class)
  @SpecAssertion(section = "4.1.1", id = "k")
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

  @Test(expectedExceptions = ValidationException.class)
  @SpecAssertion(section = "4.1.1", id = "k")
  public void testUnexpectedExceptionsInValidatePropertyGetWrappedInValidationExceptions() {
    Validator validator = TestUtil.getValidatorUnderTest();
    validator.validateProperty( new BadlyBehavedEntity(), "value" );
  }
}
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

        BoundariesConstraintValidator.isValidCalls > nbrOfValidCalls,
        "Ensure is valid hasbeen called."
    );
    nbrOfValidCalls = BoundariesConstraintValidator.isValidCalls;

    validator.validateProperty( shoe, "size" );
    assertTrue(
        BoundariesConstraintValidator.isValidCalls > nbrOfValidCalls,
        "Ensure is valid hasbeen called."
    );
    nbrOfValidCalls = BoundariesConstraintValidator.isValidCalls;
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.