Package javax.validation

Examples of javax.validation.Validator.validateProperty()


      @SpecAssertion(section = "4.1.2", id = "b")
  })
  public void testCorrectGroupsAreAppliedForValidateProperty() {
    Validator validator = TestUtil.getValidatorUnderTest();

    Set<ConstraintViolation<Address>> constraintViolations = validator.validateProperty( new Address(), "city" );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    assertCorrectConstraintTypes( constraintViolations, NotNull.class );
    assertCorrectPropertyPaths( constraintViolations, "city" );

    constraintViolations = validator.validateProperty( new Address(), "city", Default.class );
View Full Code Here


    Set<ConstraintViolation<Address>> constraintViolations = validator.validateProperty( new Address(), "city" );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    assertCorrectConstraintTypes( constraintViolations, NotNull.class );
    assertCorrectPropertyPaths( constraintViolations, "city" );

    constraintViolations = validator.validateProperty( new Address(), "city", Default.class );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    assertCorrectConstraintTypes( constraintViolations, NotNull.class );
    assertCorrectPropertyPaths( constraintViolations, "city" );

    constraintViolations = validator.validateProperty( new Address(), "city", Address.Minimal.class );
View Full Code Here

    constraintViolations = validator.validateProperty( new Address(), "city", Default.class );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    assertCorrectConstraintTypes( constraintViolations, NotNull.class );
    assertCorrectPropertyPaths( constraintViolations, "city" );

    constraintViolations = validator.validateProperty( new Address(), "city", Address.Minimal.class );
    assertCorrectNumberOfViolations( constraintViolations, 0 );

    constraintViolations = validator.validateProperty( new Address(), "street", Address.Minimal.class );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    assertCorrectConstraintTypes( constraintViolations, NotEmpty.class );
View Full Code Here

    assertCorrectPropertyPaths( constraintViolations, "city" );

    constraintViolations = validator.validateProperty( new Address(), "city", Address.Minimal.class );
    assertCorrectNumberOfViolations( constraintViolations, 0 );

    constraintViolations = validator.validateProperty( new Address(), "street", Address.Minimal.class );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    assertCorrectConstraintTypes( constraintViolations, NotEmpty.class );
    assertCorrectPropertyPaths( constraintViolations, "street" );
  }
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

  @Test
  @SpecAssertion(section = "4.1.1", id = "e")
  public void testIllegalArgumentExceptionIsThrownForNullValue() {
    Validator validator = TestUtil.getValidatorUnderTest();
    try {
      validator.validateProperty( null, "firstName" );
      fail();
    }
    catch ( IllegalArgumentException e ) {
      // success
    }
View Full Code Here

  public void testValidatePropertyWithInvalidPropertyPath() {
    Validator validator = TestUtil.getValidatorUnderTest();

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

    }


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

    Validator validator = TestUtil.getValidatorUnderTest();

    Customer customer = new Customer();

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

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

    try {
      validator.validateProperty( customer, "" );
      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.