Package javax.validation.metadata

Examples of javax.validation.metadata.PropertyDescriptor


      @SpecAssertion(section = "8.1.1.2", id = "f")
  })
  public void testGroupConversionsAreAdditiveAndExceptionIsThrownForMultipleConversionWithSameSource() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstCreditCard" );
    propDescriptor.getGroupConversions();
  }
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 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

      @SpecAssertion(section = "8.1.1.3", id = "f")
  })
  public void testGroupConversionsAreAdditiveAndExceptionIsThrownForMultipleConversionWithSameSource() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
    PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstCreditCard" );
    propDescriptor.getGroupConversions();
  }
View Full Code Here

  @SpecAssertion(section = "6.1", id = "a")
  public void testConstraintDescriptorWithoutExplicitGroup() {
    Validator validator = TestUtil.getValidatorUnderTest();

    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
    PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
    Set<ConstraintDescriptor<?>> descriptors = propertyDescriptor.getConstraintDescriptors();

    assertEquals( descriptors.size(), 1, "There should be only one constraint descriptor" );
    ConstraintDescriptor<?> descriptor = descriptors.iterator().next();
    Set<Class<?>> groups = descriptor.getGroups();
    assertTrue( groups.size() == 1, "There should be only one group" );
View Full Code Here

  @SpecAssertions({
      @SpecAssertion(section = "8.1.1.7", id = "a"),
      @SpecAssertion(section = "8.1.1.7", id = "b")
  })
  public void testGroupConversionsAppliedOnField() throws Exception {
    PropertyDescriptor propertyDescriptor = TestUtil.getPropertyDescriptor(
        Groups.class, "foo"
    );
    assertNotNull( propertyDescriptor, "the specified property should be configured in xml" );

    Set<GroupConversionDescriptor> groupConversionDescriptors = propertyDescriptor.getGroupConversions();
    assertTrue( groupConversionDescriptors.size() == 2 );
  }
View Full Code Here

  @SpecAssertions({
      @SpecAssertion(section = "8.1.1.7", id = "a"),
      @SpecAssertion(section = "8.1.1.7", id = "b")
  })
  public void testGroupConversionsAppliedOnGetter() throws Exception {
    PropertyDescriptor propertyDescriptor = TestUtil.getPropertyDescriptor(
        Groups.class, "snafu"
    );
    assertNotNull( propertyDescriptor, "the specified property should be configured in xml" );

    Set<GroupConversionDescriptor> groupConversionDescriptors = propertyDescriptor.getGroupConversions();
    assertTrue( groupConversionDescriptors.size() == 3 );
  }
View Full Code Here

  public <T extends Annotation> void testExcludeExistingValidators() {
    Configuration<?> config = TestUtil.getConfigurationUnderTest();
    config.addMapping( TestUtil.getInputStreamForPath( packageName + mappingFile1 ) );
    Validator validator = config.buildValidatorFactory().getValidator();

    PropertyDescriptor propDescriptor = validator.getConstraintsForClass( Name.class )
        .getConstraintsForProperty( "name" );

    Set<ConstraintDescriptor<?>> descriptors = propDescriptor.getConstraintDescriptors();
    assertEquals( descriptors.size(), 1, "There should only be one constraint." );

    @SuppressWarnings("unchecked")
    ConstraintDescriptor<T> descriptor = (ConstraintDescriptor<T>) descriptors.iterator().next();
    List<Class<? extends ConstraintValidator<T, ?>>> validators = descriptor.getConstraintValidatorClasses();
View Full Code Here

  public <T extends Annotation> void testIncludeExistingValidators() {
    Configuration<?> config = TestUtil.getConfigurationUnderTest();
    config.addMapping( TestUtil.getInputStreamForPath( packageName + mappingFile2 ) );
    Validator validator = config.buildValidatorFactory().getValidator();

    PropertyDescriptor propDescriptor = validator.getConstraintsForClass( Name.class )
        .getConstraintsForProperty( "name" );


    Set<ConstraintDescriptor<?>> descriptors = propDescriptor.getConstraintDescriptors();
    assertEquals( descriptors.size(), 1, "There should only be one constraint." );

    @SuppressWarnings("unchecked")
    ConstraintDescriptor<T> descriptor = (ConstraintDescriptor<T>) descriptors.iterator().next();
    List<Class<? extends ConstraintValidator<T, ?>>> validators = descriptor.getConstraintValidatorClasses();
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.