Examples of validateProperty()


Examples of javax.validation.Validator.validateProperty()

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

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

    superwoman.setHiddenName( null );
    violations = validator.validateProperty( superwoman, "lastName" );
    assertCorrectNumberOfViolations( violations, 1 );
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

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

    superwoman.setHiddenName( null );
    violations = validator.validateProperty( superwoman, "lastName" );
    assertCorrectNumberOfViolations( violations, 1 );
    assertCorrectConstraintTypes( violations, NotNull.class );
  }

  @Test
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

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

    validator.validateProperty( shoe, "size" );
    assertTrue(
        BoundariesConstraintValidator.isValidCalls > nbrOfValidCalls,
        "Ensure is valid has been called."
    );
    nbrOfValidCalls = BoundariesConstraintValidator.isValidCalls;
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

  @Test
  @SpecAssertion(section = "4.6.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

Examples of javax.validation.Validator.validateProperty()

      @SpecAssertion(section = "5.3.1.3", id = "e")
  })
  public void testInterpolationWithFormatterUsesDefaultLocaleInElExpression() {
    Locale.setDefault( Locale.GERMAN );
    Validator validator = TestUtil.getValidatorUnderTest();
    Set<ConstraintViolation<TestBean>> violations = validator.validateProperty( new TestBean(), "longitude" );
    assertCorrectConstraintViolationMessages( violations, "98,12 must be larger than 100" );
  }

  private interface CustomPayload extends Payload {
  }
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

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

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

Examples of javax.validation.Validator.validateProperty()

  @Test
  @SpecAssertion(section = "4.3.1", id = "d")
  public void testMessagesCanBeOverriddenAtConstraintLevel() {
    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()

  @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

Examples of javax.validation.Validator.validateProperty()

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

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

Examples of javax.validation.Validator.validateProperty()

    catch ( IllegalArgumentException e ) {
      // success
    }

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