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 testGroupConversionsAreAdditive() {
    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." );
    Set<GroupConversionDescriptor> groupConversionDescriptorSet = propDescriptor.getGroupConversions();

    assertTrue(
        groupConversionDescriptorSet.size() == 2,
        "There should be two group conversions. One configured via annotations and one via XML"
    );
View Full Code Here

  public void testConstraintsOnSuperClassAreInherited() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Bar.class );

    String propertyName = "foo";
    assertTrue( beanDescriptor.getConstraintsForProperty( propertyName ) != null );
    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( propertyName );

    Annotation constraintAnnotation = propDescriptor.getConstraintDescriptors()
        .iterator()
        .next().getAnnotation();
    assertTrue( constraintAnnotation.annotationType() == NotNull.class );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.2", id = "a")
  public void testGetElementClass() {
    PropertyDescriptor descriptor = getPropertyDescriptor( Order.class, "orderNumber" );
    assertEquals( descriptor.getElementClass(), Integer.class, "Wrong element class" );
  }
View Full Code Here

  public void testConstraintsOnInterfaceAreInherited() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Bar.class );

    String propertyName = "fubar";
    assertTrue( beanDescriptor.getConstraintsForProperty( propertyName ) != null );
    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( propertyName );

    Annotation constraintAnnotation = propDescriptor.getConstraintDescriptors()
        .iterator()
        .next().getAnnotation();
    assertTrue( constraintAnnotation.annotationType() == NotNull.class );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.4", id = "a")
  public void testIsNotCascaded() {
    PropertyDescriptor descriptor = getPropertyDescriptor( Order.class, "orderNumber" );
    assertFalse( descriptor.isCascaded(), "Should not be cascaded" );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.4", id = "a")
  public void testIsCascaded() {
    PropertyDescriptor descriptor = getPropertyDescriptor( Customer.class, "orderList" );
    assertTrue( descriptor.isCascaded(), "Should be cascaded" );
  }
View Full Code Here

  public void testConstraintsOnInterfaceAndImplementationAddUp() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Bar.class );

    String propertyName = "name";
    assertTrue( beanDescriptor.getConstraintsForProperty( propertyName ) != null );
    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( propertyName );

    List<Class<? extends Annotation>> constraintTypes = getConstraintTypes( propDescriptor.getConstraintDescriptors() );

    assertEquals( constraintTypes.size(), 2 );
    assertTrue( constraintTypes.contains( DecimalMin.class ) );
    assertTrue( constraintTypes.contains( Size.class ) );
  }
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.