Package javax.validation

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


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

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

  @Test
  @SpecAssertion(section = "4.1.1", id = "g")
View Full Code Here

    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

  @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

  @SpecAssertion(section = "3.5", id = "b")
  public void testOnlyFirstGroupInSequenceGetEvaluated() {
    Validator validator = TestUtil.getValidatorUnderTest();
    Car car = new Car( "USd-298" );

    Set<ConstraintViolation<Car>> violations = validator.validateProperty(
        car, "licensePlateNumber", First.class, Second.class
    );
    assertCorrectNumberOfViolations( violations, 1 );

    car.setLicensePlateNumber( "USD-298" );
View Full Code Here

        car, "licensePlateNumber", First.class, Second.class
    );
    assertCorrectNumberOfViolations( violations, 1 );

    car.setLicensePlateNumber( "USD-298" );
    violations = validator.validateProperty(
        car, "licensePlateNumber", First.class, Second.class
    );
    assertCorrectNumberOfViolations( violations, 0 );
  }
View Full Code Here

  @Test
  @SpecAssertion(section = "3.5.1", id = "c")
  public void testNullReferencesGetIgnored() {
    Parent p = new Parent();
    Validator validator = TestUtil.getValidatorUnderTest();
    Set<ConstraintViolation<Parent>> errors = validator.validateProperty( p, "child" );
    assertCorrectNumberOfViolations( errors, 0 );
  }
}
View Full Code Here

  })
  public void testFieldAccess() {
    SuperWoman superwoman = new SuperWoman();

    Validator validator = TestUtil.getValidatorUnderTest();
    Set<ConstraintViolation<SuperWoman>> violations = validator.validateProperty( superwoman, "firstName" );
    assertCorrectNumberOfViolations( violations, 0 );
  }

  @Test
  @SpecAssertions({
View Full Code Here

  })
  public void testPropertyAccess() {
    SuperWoman superwoman = new SuperWoman();

    Validator validator = TestUtil.getValidatorUnderTest();
    Set<ConstraintViolation<SuperWoman>> violations = validator.validateProperty( superwoman, "firstName" );
    assertCorrectNumberOfViolations( violations, 0 );
  }

  @Test
  @SpecAssertions({
View Full Code Here

  public void testPassingNullAsGroup() {
    Validator validator = TestUtil.getValidatorUnderTest();
    Customer customer = new Customer();

    try {
      validator.validateProperty( customer, "firstName", null );
      fail();
    }
    catch ( IllegalArgumentException e ) {
      // success
    }
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.