Examples of findConstraints()


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

    @Override
    public List<ConstraintViolation> validateClassConstraint(Object bean) {
        final List<ConstraintViolation> list = new LinkedList<ConstraintViolation>();
        if (validator != null && bean != null) {
            BeanDescriptor beanDescriptor = validator.getConstraintsForClass(bean.getClass());
            Set<ConstraintDescriptor<?>> classLevelConstraints = beanDescriptor.findConstraints().declaredOn(ElementType.TYPE).getConstraintDescriptors();
            Set<ConstraintViolation<Object>> constraintViolations = validator.validate(bean);
            for (ConstraintViolation constraintViolation : constraintViolations) {
                if (classLevelConstraints.contains(constraintViolation.getConstraintDescriptor())) {
                    list.add(constraintViolation);
                }
View Full Code Here

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

   
    //create empty constraint violation set
    Set<ConstraintViolation<T>> violations = new HashSet<ConstraintViolation<T>>();
   
    //validate class level properties
    for(ConstraintDescriptor<?> descriptor : bean.findConstraints().declaredOn(ElementType.TYPE).unorderedAndMatchingGroups(groups).getConstraintDescriptors()) {
      violations.addAll(this.validateConstraint((Class<T>)object.getClass(), descriptor, object));
    }
   
    //validate each constrained property individually
    for(PropertyDescriptor property : bean.getConstrainedProperties()) {
View Full Code Here

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

      @SpecAssertion(section = "6.7", id = "g")
  })
  public void testFindConstraintsForConstructor() {
    ConstructorDescriptor parameterConstrainedDescriptor = Executables.parameterConstrainedConstructor();
    assertTrue(
        parameterConstrainedDescriptor.findConstraints()
            .getConstraintDescriptors()
            .isEmpty(),
        "Should have no constraints"
    );
View Full Code Here

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

        "Should have no constraints"
    );

    ConstructorDescriptor returnValueConstrainedDescriptor = Executables.returnValueConstrainedConstructor();
    assertTrue(
        returnValueConstrainedDescriptor.findConstraints()
            .getConstraintDescriptors()
            .isEmpty(),
        "Should have no constraints"
    );
    ConstructorDescriptor crossParameterConstrainedDescriptor = Executables.crossParameterConstrainedConstructor();
View Full Code Here

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

            .isEmpty(),
        "Should have no constraints"
    );
    ConstructorDescriptor crossParameterConstrainedDescriptor = Executables.crossParameterConstrainedConstructor();
    assertTrue(
        crossParameterConstrainedDescriptor.findConstraints()
            .getConstraintDescriptors()
            .isEmpty(),
        "Should have no constraints"
    );
  }
View Full Code Here

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

  })
  public void testFindConstraintsForMethod() {
    CrossParameterDescriptor descriptor = Executables.crossParameterConstrainedMethod()
        .getCrossParameterDescriptor();

    Set<ConstraintDescriptor<?>> constraints = descriptor.findConstraints().getConstraintDescriptors();
    assertEquals( constraints.size(), 1, "Should have constraints" );

    ConstraintDescriptor<?> constraint = constraints.iterator().next();
    assertEquals(
        constraint.getAnnotation().annotationType(),
View Full Code Here

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

  })
  public void testFindConstraintsForMethodLookingAt() {
    CrossParameterDescriptor descriptor = Executables.methodOverridingCrossParameterConstrainedMethod()
        .getCrossParameterDescriptor();

    Set<ConstraintDescriptor<?>> constraints = descriptor.findConstraints()
        .lookingAt( Scope.LOCAL_ELEMENT )
        .getConstraintDescriptors();
    assertEquals(
        constraints.size(),
        0,
View Full Code Here

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

        constraints.size(),
        0,
        "Should have no local constraints"
    );

    constraints = descriptor.findConstraints()
        .lookingAt( Scope.HIERARCHY )
        .getConstraintDescriptors();
    assertEquals( constraints.size(), 1, "Should have constraints" );

    ConstraintDescriptor<?> constraint = constraints.iterator().next();
View Full Code Here

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

  })
  public void testFindConstraintsForMethodDefinedOnSuperTypeLookingAt() {
    CrossParameterDescriptor descriptor = Executables.crossParameterConstrainedMethodFromSuperType()
        .getCrossParameterDescriptor();

    Set<ConstraintDescriptor<?>> constraints = descriptor.findConstraints()
        .lookingAt( Scope.LOCAL_ELEMENT )
        .getConstraintDescriptors();
    assertEquals(
        constraints.size(),
        0,
View Full Code Here

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

        constraints.size(),
        0,
        "Should have no local constraints"
    );

    constraints = descriptor.findConstraints()
        .lookingAt( Scope.HIERARCHY )
        .getConstraintDescriptors();
    assertEquals( constraints.size(), 1, "Should have constraints" );

    ConstraintDescriptor<?> constraint = constraints.iterator().next();
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.