Package javax.validation.metadata

Examples of javax.validation.metadata.PropertyDescriptor


  public void testIgnoreAnnotations() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    assertNotNull( beanDescriptor );

    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" );
    assertNull( propDescriptor, "The annotation defined constraints should be ignored." );
  }
View Full Code Here


  public void testIncludeAnnotations() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    assertNotNull( beanDescriptor );

    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "lastname" );
    assertNotNull( propDescriptor );

    Set<ConstraintDescriptor<?>> constraintDescriptors = propDescriptor.getConstraintDescriptors();
    assertEquals( constraintDescriptors.size(), 2, "There should be two constraints" );

    boolean foundNotNullConstraint = false;
    boolean foundPatternConstraint = false;
    for ( ConstraintDescriptor<?> descriptor : constraintDescriptors ) {
View Full Code Here

  public void testCascadedConfiguration() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    assertNotNull( beanDescriptor );

    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstCreditCard" );
    assertNotNull( propDescriptor );
    assertTrue( propDescriptor.isCascaded(), "Cascaded validation is configured via xml." );

    propDescriptor = beanDescriptor.getConstraintsForProperty( "secondCreditCard" );
    assertNull( propDescriptor, "The @Valid annotation should be ignored." );
  }
View Full Code Here

  public void testAnnotationsIncluded() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    assertNotNull( beanDescriptor );

    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" );
    assertNotNull( propDescriptor );

    Set<ConstraintDescriptor<?>> constraintDescriptors = propDescriptor.getConstraintDescriptors();
    assertEquals( constraintDescriptors.size(), 1, "There should be two constraints" );
    ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next();
    assertTrue( descriptor.getAnnotation() instanceof NotNull, "Wrong constraint annotation." );
  }
View Full Code Here

  public void testAnnotationsIncluded() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    assertNotNull( beanDescriptor );

    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" );
    assertNotNull( propDescriptor );

    Set<ConstraintDescriptor<?>> constraintDescriptors = propDescriptor.getConstraintDescriptors();
    assertEquals( constraintDescriptors.size(), 1, "There should be two constraints" );
    ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next();
    assertTrue( descriptor.getAnnotation() instanceof NotNull, "Wrong constraint annotation." );
  }
View Full Code Here

  public void testIgnoreAnnotations() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    assertNotNull( beanDescriptor );

    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" );
    assertNull( propDescriptor, "The annotation defined constraints should be ignored." );
  }
View Full Code Here

  public void testIgnoreAnnotations() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    assertNotNull( beanDescriptor );

    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" );
    assertNull( propDescriptor, "The annotation defined constraints should be ignored." );
  }
View Full Code Here

  public void testConstraintWithNoExplicitlySpecifiedGroupBelongsToDefault() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    assertTrue( beanDescriptor.isBeanConstrained() );

    PropertyDescriptor propDesc = beanDescriptor.getConstraintsForProperty( "firstname" );
    assertTrue( propDesc.getConstraintDescriptors().size() == 1 );

    ConstraintDescriptor descriptor = propDesc.getConstraintDescriptors().iterator().next();
    assertTrue( descriptor.getGroups().size() == 1 );
    assertEquals(
        descriptor.getGroups().iterator().next(),
        Default.class,
        "Constraint should implicitly belong to the Default group."
View Full Code Here

  public void testConstraintCanBelongToMoreThanOneGroup() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    assertTrue( beanDescriptor.isBeanConstrained() );

    PropertyDescriptor propDesc = beanDescriptor.getConstraintsForProperty( "defaultCreditCard" );
    assertTrue( propDesc.getConstraintDescriptors().size() == 1 );

    ConstraintDescriptor descriptor = propDesc.getConstraintDescriptors().iterator().next();
    assertTrue( descriptor.getGroups().size() == 2 );
  }
View Full Code Here

  public void testIgnoreAnnotations() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    assertNotNull( beanDescriptor );

    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" );
    assertNull( propDescriptor, "The annotation defined constraints should be ignored." );
  }
View Full Code Here

TOP

Related Classes of javax.validation.metadata.PropertyDescriptor

Copyright © 2018 www.massapicom. 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.