Package javax.validation.metadata

Examples of javax.validation.metadata.ConstraintDescriptor


        Assert.assertEquals(2, propertyDescriptor.getConstraintDescriptors().size());
        Assert.assertTrue("title".equals(propertyDescriptor.getPropertyName()));
        //assuming the implementation returns the NotEmpty constraint first
        Iterator<ConstraintDescriptor<?>> iter =
              propertyDescriptor.getConstraintDescriptors().iterator();
        ConstraintDescriptor constraintDescriptor = null;
        while (iter.hasNext()) {
            constraintDescriptor = iter.next();
            if (constraintDescriptor.getAnnotation().annotationType()
                  .equals(NotNull.class)) {
                break;
            }

        }
        Assert.assertTrue(constraintDescriptor != null);
        Assert.assertTrue(constraintDescriptor.getGroups().size() == 1); //"first"
        Assert.assertEquals(NotNullValidator.class,
              constraintDescriptor.getConstraintValidatorClasses().get(0));
        //assuming the implementation returns the Size constraint first
        propertyDescriptor = bookBeanDescriptor.getConstraintsForProperty("subtitle");
        Iterator<ConstraintDescriptor<?>> iterator =
              propertyDescriptor.getConstraintDescriptors().iterator();
        constraintDescriptor = iterator.next();
        Assert.assertTrue(
              constraintDescriptor.getAnnotation().annotationType().equals(Size.class));
        Assert.assertTrue(
              ((Integer) constraintDescriptor.getAttributes().get("max")) == 30);
        Assert.assertTrue(constraintDescriptor.getGroups().size() == 1);
        propertyDescriptor = bookBeanDescriptor.getConstraintsForProperty("author");
        Assert.assertTrue(propertyDescriptor.getConstraintDescriptors().size() == 1);
        Assert.assertTrue(propertyDescriptor.isCascaded());
    }
View Full Code Here


    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

    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

    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

    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

    private static class ContextResourceBundle extends ResourceBundle {
        ResourceBundle contextBundle;
        ResourceBundle userBundle;

        ContextResourceBundle(Context context, Locale locale) {
            ConstraintDescriptor descriptor = context.getConstraintDescriptor();
            Set<Class<? extends Payload>> payload = descriptor.getPayload();

            // Load the LogStrings.properties for the argument Locale, from the ClassLoader
            // of the payload.
            if (!payload.isEmpty()) {
                final Class payloadClass = payload.iterator().next();
View Full Code Here

    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

    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

    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

    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

TOP

Related Classes of javax.validation.metadata.ConstraintDescriptor

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.