Examples of validateProperty()


Examples of javax.validation.Validator.validateProperty()

    assertCorrectNumberOfViolations( constraintViolations, 1 );
    assertCorrectConstraintViolationMessages(
        constraintViolations, "Car type has to be betweeb 2 and 20 characters."
    );

    constraintViolations = validator.validateProperty( car, "type" );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    assertCorrectConstraintViolationMessages(
        constraintViolations, "Car type has to be betweeb 2 and 20 characters."
    );
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

  @Test
  @SpecAssertion(section = "4.3.1", id = "d")
  public void testMessagesCanBeOverrridenAtConstraintLevel() {
    Validator validator = TestUtil.getValidatorUnderTest();
    Set<ConstraintViolation<DummyEntity>> constraintViolations = validator.validateProperty(
        new DummyEntity(), "snafu"
    );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    assertCorrectConstraintViolationMessages(
        constraintViolations, "messages can also be overridden at constraint declaration."
View Full Code Here

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

Examples of javax.validation.Validator.validateProperty()

    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

Examples of javax.validation.Validator.validateProperty()

    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

Examples of javax.validation.Validator.validateProperty()

    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

Examples of javax.validation.Validator.validateProperty()

//  @SpecAssertion(section = "3.4.2", id = "j")
  public void testOnlyFirstGroupInSequenceGetEvaluated() {
    Validator validator = TestUtil.getValidatorUnderTest();
    Car car = new Car( "USd-298" );
   
    Set<ConstraintViolation<Car>> violations = validator.validateProperty(
        car, "licensePlateNumber", All.class
    );
    assertCorrectNumberOfViolations( violations, 1 );
    ConstraintViolation<Car> violation = violations.iterator().next();
  }
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

  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

Examples of javax.validation.Validator.validateProperty()

  @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

Examples of org.apache.bval.BeanValidator.validateProperty()

        assertTrue(results.hasErrorForReason(Reasons.MANDATORY));
        assertTrue(results.hasError(object, null));
        assertTrue(results.hasError(object.getAddress(), null));

        assertTrue(
              validator.validateProperty(object, info.getProperty("firstName")).hasError(
                    object, "firstName"));

        object.setUserId(1L);
        object.setFirstName("Hans");
        object.setLastName("Tester");
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.