Package javax.validation.metadata

Examples of javax.validation.metadata.PropertyDescriptor.findConstraints()


     */
    public void testConstraintFinderLookingAt() {
        Validator validator = getValidator();
       
        PropertyDescriptor nameDescriptor = validator.getConstraintsForClass( Woman.class ).getConstraintsForProperty("name");
        Set<ConstraintDescriptor<?>> constraints = nameDescriptor.findConstraints().lookingAt(Scope.HIERARCHY).getConstraintDescriptors();
        Assert.assertEquals("Incorrect number of descriptors", 1, constraints.size());
       
        constraints = nameDescriptor.findConstraints().lookingAt(Scope.LOCAL_ELEMENT).getConstraintDescriptors();
        Assert.assertEquals("Incorrect number of descriptors", 0, constraints.size());
        TestUtils.failOnModifiable(constraints, "constraintFinder constraintDescriptors");
View Full Code Here


       
        PropertyDescriptor nameDescriptor = validator.getConstraintsForClass( Woman.class ).getConstraintsForProperty("name");
        Set<ConstraintDescriptor<?>> constraints = nameDescriptor.findConstraints().lookingAt(Scope.HIERARCHY).getConstraintDescriptors();
        Assert.assertEquals("Incorrect number of descriptors", 1, constraints.size());
       
        constraints = nameDescriptor.findConstraints().lookingAt(Scope.LOCAL_ELEMENT).getConstraintDescriptors();
        Assert.assertEquals("Incorrect number of descriptors", 0, constraints.size());
        TestUtils.failOnModifiable(constraints, "constraintFinder constraintDescriptors");
        //verify that changes to one ConstraintFinder don't affect the base:
        constraints = nameDescriptor.getConstraintDescriptors();
        Assert.assertEquals("Incorrect number of descriptors", 1, constraints.size());
View Full Code Here

    Collection<ValidatorDescriptor> processBeanAttribute(FacesContext context, ValueDescriptor descriptor, String msg,
        Class<?>... groups) {
        PropertyDescriptor constraintsForProperty = getValidator(context).getConstraintsForClass(descriptor.getBeanType())
            .getConstraintsForProperty(descriptor.getName());
        if (null != constraintsForProperty) {
            ConstraintFinder propertyConstraints = constraintsForProperty.findConstraints();
            if (null != groups && groups.length > 0) {
                // Filter groups, if required
                propertyConstraints = propertyConstraints.unorderedAndMatchingGroups(groups);
            }
            Set<ConstraintDescriptor<?>> constraints = propertyConstraints // or the requested list of groups)
View Full Code Here

    {
      PropertyDescriptor propDesc = beanDesc.getConstraintsForProperty(property.getName());
      if (propDesc != null)
      {
        // TODO use hasConstraintDesc to optimize...?
        Set<ConstraintDescriptor<?>> constraints = propDesc.findConstraints()
          .unorderedAndMatchingGroups(groups)
          .getConstraintDescriptors();
        if (constraints != null)
        {
          stack.add(constraints.iterator());
View Full Code Here

     */
    public void testConstraintFinderLookingAt() {
        Validator validator = getValidator();
       
        PropertyDescriptor nameDescriptor = validator.getConstraintsForClass( Woman.class ).getConstraintsForProperty("name");
        Set<ConstraintDescriptor<?>> constraints = nameDescriptor.findConstraints().lookingAt(Scope.HIERARCHY).getConstraintDescriptors();
        Assert.assertEquals("Incorrect number of descriptors", 1, constraints.size());
       
        constraints = nameDescriptor.findConstraints().lookingAt(Scope.LOCAL_ELEMENT).getConstraintDescriptors();
        Assert.assertEquals("Incorrect number of descriptors", 0, constraints.size());
    }
View Full Code Here

       
        PropertyDescriptor nameDescriptor = validator.getConstraintsForClass( Woman.class ).getConstraintsForProperty("name");
        Set<ConstraintDescriptor<?>> constraints = nameDescriptor.findConstraints().lookingAt(Scope.HIERARCHY).getConstraintDescriptors();
        Assert.assertEquals("Incorrect number of descriptors", 1, constraints.size());
       
        constraints = nameDescriptor.findConstraints().lookingAt(Scope.LOCAL_ELEMENT).getConstraintDescriptors();
        Assert.assertEquals("Incorrect number of descriptors", 0, constraints.size());
    }
   
    public static class Form {
        @NotNull
View Full Code Here

    public static Set<ConstraintDescriptor<?>> extractConstraintDescriptors(FacesContext context, RequestContext requestContext, ValueExpression ve, Class... groups) {

        PropertyDescriptor propertyDescriptor = extractPropertyDescriptor(context, requestContext, ve);

        if (propertyDescriptor != null) {
            return propertyDescriptor.findConstraints().unorderedAndMatchingGroups(groups).getConstraintDescriptors();
        }
       
        return null;
    }
View Full Code Here

    Validator validator = TestUtil.getValidatorUnderTest();
    BeanDescriptor descriptor = validator.getConstraintsForClass( MiniaturePart.class );

    //  PreManufacturing belongs implicitly to All
    PropertyDescriptor propertyDescriptor = descriptor.getConstraintsForProperty( "partNumber" );
    Set<ConstraintDescriptor<?>> descriptorsForGroup = propertyDescriptor.findConstraints()
        .unorderedAndMatchingGroups( All.class )
        .getConstraintDescriptors();
    assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
    assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), Digits.class );
View Full Code Here

    assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
    assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), Digits.class );

    //  PostManufacturing belongs implicitly to All
    propertyDescriptor = descriptor.getConstraintsForProperty( "qaChecked" );
    descriptorsForGroup = propertyDescriptor.findConstraints()
        .unorderedAndMatchingGroups( All.class )
        .getConstraintDescriptors();
    assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
    assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), AssertTrue.class );
View Full Code Here

        .getConstraintDescriptors();
    assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
    assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), AssertTrue.class );

    propertyDescriptor = descriptor.getConstraintsForProperty( "size" );
    descriptorsForGroup = propertyDescriptor.findConstraints()
        .unorderedAndMatchingGroups( All.class )
        .getConstraintDescriptors();
    assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
    assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), Max.class );
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.