Package javax.validation.metadata

Examples of javax.validation.metadata.PropertyDescriptor


  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 testRightValidatorIsSlectedAndInializedCalled() {
    Validator validator = TestUtil.getValidatorUnderTest();
    Shoe shoe = new Shoe();
    shoe.size = -2;
    final PropertyDescriptor propertyDescriptor = validator.getConstraintsForClass( Shoe.class )
        .getConstraintsForProperty( "size" );
    assertNotNull( propertyDescriptor );

    BoundariesConstraintValidator.isValidCalls = 0;
    final Set<ConstraintViolation<Shoe>> constraintViolations = validator.validate( shoe );
View Full Code Here

  @SpecAssertion(section = "5.1", id = "b")
  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

  @SpecAssertion(section = "5.1", id = "b")
  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

      @SpecAssertion(section = "5.3", id = "b")
  })
  public void testGetConstraintForConstrainedProperty() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
    PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
    assertEquals(
        propertyDescriptor.getConstraintDescriptors().size(), 1, "There should be one constraint descriptor"
    );
  }
View Full Code Here

      @SpecAssertion(section = "5.4", id = "a")
  })
  public void testGetConstraintForUnConstrainedProperty() {
    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
    PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
    assertEquals(
        propertyDescriptor.getConstraintDescriptors().size(), 0, "There should be no constraint descriptors"
    );
    assertTrue( propertyDescriptor.isCascaded(), "The property should be cascaded" );
  }
View Full Code Here

public class PropertyDescriptorTest extends AbstractTest {

  @Test
  @SpecAssertion(section = "5.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 = "5.4", id = "a")
  public void testIsCascaded() {
    PropertyDescriptor descriptor = getPropertyDescriptor( Customer.class, "orderList" );
    assertTrue( descriptor.isCascaded(), "Should be cascaded" );
  }
View Full Code Here

  @Test
  @SpecAssertion(section = "5.4", id = "b")
  public void testPropertyName() {
    String propertyName = "orderList";
    PropertyDescriptor descriptor = getPropertyDescriptor( Customer.class, propertyName );
    assertEquals( descriptor.getPropertyName(), propertyName, "Wrong property name" );
  }
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.