Package javax.validation.metadata

Examples of javax.validation.metadata.BeanDescriptor


  @SpecAssertions({
      @SpecAssertion(section = "6.1", id = "a"),
      @SpecAssertion(section = "6.3", id = "a")
  })
  public void testUnconstrainedClass() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
    assertFalse(
        beanDescriptor.hasConstraints(),
        "There should be no direct constraints on the specified bean."
    );
    assertFalse( beanDescriptor.isBeanConstrained(), "Bean should be unconstrained." );
  }
View Full Code Here


  @SpecAssertions({
      @SpecAssertion(section = "6.1", id = "a"),
      @SpecAssertion(section = "6.3", id = "b")
  })
  public void testGetConstraintsForConstrainedProperty() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
    PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(
        "orderNumber"
    );
    assertEquals(
        propertyDescriptor.getConstraintDescriptors().size(),
        1,
View Full Code Here

  @SpecAssertions({
      @SpecAssertion(section = "6.3", id = "b"),
      @SpecAssertion(section = "6.4", id = "a")
  })
  public void testGetConstraintsForUnConstrainedProperty() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
    PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(
        "orderList"
    );
    assertEquals(
        propertyDescriptor.getConstraintDescriptors().size(),
        0,
View Full Code Here

  @SpecAssertions({
      @SpecAssertion(section = "6.1", id = "a"),
      @SpecAssertion(section = "6.3", id = "b")
  })
  public void testGetConstraintsForNonExistingProperty() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
    assertNull(
        beanDescriptor.getConstraintsForProperty( "foobar" ),
        "There should be no descriptor"
    );
  }
View Full Code Here

  @SpecAssertions({
      @SpecAssertion(section = "6.1", id = "a"),
      @SpecAssertion(section = "6.3", id = "d")
  })
  public void testGetConstrainedProperties() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
    Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
    assertEquals( constraintProperties.size(), 1, "There should be only one property" );
    boolean hasOrderNumber = false;
    for ( PropertyDescriptor pd : constraintProperties ) {
      hasOrderNumber |= pd.getPropertyName().equals( "orderNumber" );
    }
View Full Code Here

  @SpecAssertions({
      @SpecAssertion(section = "6.1", id = "a"),
      @SpecAssertion(section = "6.3", id = "d")
  })
  public void testGetConstrainedPropertiesForUnconstrainedEntity() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
    Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
    assertEquals( constraintProperties.size(), 0, "We should get the empty set." );
  }
View Full Code Here

  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  @SpecAssertion(section = "6.3", id = "c")
  public void testGetConstraintsForNullProperty() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
    beanDescriptor.getConstraintsForProperty( null );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.3", id = "e")
  public void testGetConstraintsForNonExistingMethod() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( CustomerService.class );
    MethodDescriptor methodDescriptor = beanDescriptor.getConstraintsForMethod( "foo" );
    assertNull( methodDescriptor, "Descriptor should be null" );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.3", id = "f")
  public void testGetConstrainedMethodsTypeNON_GETTER() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( CustomerService.class );
    Set<MethodDescriptor> methodDescriptors = beanDescriptor.getConstrainedMethods( MethodType.NON_GETTER );

    List<String> actualMethodNames = new ArrayList<String>();
    for ( MethodDescriptor methodDescriptor : methodDescriptors ) {
      actualMethodNames.add( methodDescriptor.getName() );
    }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.3", id = "f")
  public void testGetConstrainedMethodsTypeGETTER() {
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( CustomerService.class );
    Set<MethodDescriptor> methodDescriptors = beanDescriptor.getConstrainedMethods( MethodType.GETTER );

    assertEquals( methodDescriptors.size(), 1 );
    assertEquals( methodDescriptors.iterator().next().getName(), "getBestCustomer" );
  }
View Full Code Here

TOP

Related Classes of javax.validation.metadata.BeanDescriptor

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.