Package javax.validation.metadata

Examples of javax.validation.metadata.ReturnValueDescriptor


    assertFalse( elementDescriptor.isCascaded() );
  }

  @Test
  public void testHasConstraints() {
    ReturnValueDescriptor unconstrainedReturnValueDescriptor = getMethodReturnValueDescriptor(
        CustomerRepository.class,
        "foo"
    );
    assertFalse( unconstrainedReturnValueDescriptor.hasConstraints() );

    ReturnValueDescriptor constrainedReturnDescriptor = getMethodReturnValueDescriptor(
        CustomerRepository.class,
        "bar"
    );
    assertTrue( constrainedReturnDescriptor.hasConstraints() );
  }
View Full Code Here


    assertTrue( constrainedReturnDescriptor.hasConstraints() );
  }

  @Test
  public void testHasConstraintsConsidersConstraintsFromSuperType() {
    ReturnValueDescriptor constrainedReturnDescriptor = getMethodReturnValueDescriptor(
        CustomerRepositoryExt.class,
        "bar"
    );
    assertTrue( constrainedReturnDescriptor.hasConstraints() );
  }
View Full Code Here

    assertTrue( constrainedReturnDescriptor.hasConstraints() );
  }

  @Test
  public void testGetConstraintDescriptors() {
    ReturnValueDescriptor unconstrainedReturnValueDescriptor = getMethodReturnValueDescriptor(
        CustomerRepository.class,
        "foo"
    );
    assertTrue( unconstrainedReturnValueDescriptor.getConstraintDescriptors().isEmpty() );

    ReturnValueDescriptor constrainedReturnValueDescriptor = getMethodReturnValueDescriptor(
        CustomerRepository.class,
        "bar"
    );
    assertConstraintTypes(
        constrainedReturnValueDescriptor.getConstraintDescriptors(),
        NotNull.class
    );
  }
View Full Code Here

    );
  }

  @Test
  public void testGetConstraintDescriptorsConsidersConstraintsFromSuperType() {
    ReturnValueDescriptor returnValueDescriptor = getMethodReturnValueDescriptor(
        CustomerRepositoryExt.class,
        "baz"
    );
    assertConstraintTypes(
        returnValueDescriptor.getConstraintDescriptors(),
        Min.class,
        NotNull.class
    );
  }
View Full Code Here

  }

  @TestForIssue(jiraKey = "HV-443")
  @Test
  public void testConstraintsLookingAt() {
    ReturnValueDescriptor returnValueDescriptor = getMethodReturnValueDescriptor(
        CustomerRepositoryExt.class,
        "baz"
    );

    assertConstraintTypes(
        returnValueDescriptor.findConstraints()
            .lookingAt( Scope.LOCAL_ELEMENT )
            .getConstraintDescriptors(), Min.class
    );
    assertConstraintTypes(
        returnValueDescriptor.findConstraints()
            .lookingAt( Scope.HIERARCHY )
            .getConstraintDescriptors(), Min.class, NotNull.class
    );
  }
View Full Code Here

    );
  }

  @Test
  public void testFindConstraintMatchingGroups() {
    ReturnValueDescriptor returnValueDescriptor = getMethodReturnValueDescriptor(
        CustomerRepositoryExt.class,
        "baz"
    );
    assertConstraintTypes(
        returnValueDescriptor.findConstraints()
            .unorderedAndMatchingGroups( ValidationGroup.class )
            .getConstraintDescriptors(), NotNull.class
    );
  }
View Full Code Here

    );
  }

  @Test
  public void testGetGroupConversions() {
    ReturnValueDescriptor returnValueDescriptor = getMethodReturnValueDescriptor(
        CustomerRepositoryExt.class, "modifyCustomer", Customer.class
    );

    Set<GroupConversionDescriptor> groupConversions = returnValueDescriptor.getGroupConversions();

    assertThat( groupConversions ).hasSize( 2 );
    assertThat( groupConversions ).containsConversion(
        CustomerRepositoryExtBasic.class,
        CustomerBasic.class
View Full Code Here

    );
  }

  @Test
  public void testDescriptorForVoidMethod() {
    ReturnValueDescriptor returnValueDescriptor = getMethodReturnValueDescriptor(
        CustomerRepositoryExt.class, "saveCustomer", Customer.class
    );

    assertThat( returnValueDescriptor.getElementClass() ).isSameAs( void.class );
    assertThat( returnValueDescriptor.hasConstraints() ).isFalse();
    assertThat( returnValueDescriptor.isCascaded() ).isFalse();
    assertThat( returnValueDescriptor.getConstraintDescriptors() ).isEmpty();
    assertThat( returnValueDescriptor.getGroupConversions() ).isEmpty();
    assertThat( returnValueDescriptor.findConstraints().getConstraintDescriptors() ).isEmpty();
  }
View Full Code Here

    ConstructorDescriptor constructorDescriptor = getConstructorDescriptor(
        CustomerRepositoryExt.class,
        String.class
    );

    ReturnValueDescriptor returnValueDescriptor = constructorDescriptor.getReturnValueDescriptor();
    assertThat( returnValueDescriptor ).isNotNull();
    assertThat( returnValueDescriptor.getElementClass() ).isEqualTo( CustomerRepositoryExt.class );
    assertThat( returnValueDescriptor.hasConstraints() ).isTrue();
    assertThat( returnValueDescriptor.isCascaded() ).isTrue();

    Set<ConstraintDescriptor<?>> constraintDescriptors = returnValueDescriptor.getConstraintDescriptors();
    assertThat( constraintDescriptors ).hasSize( 1 );
    ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next();
    assertThat( descriptor.getAnnotation().annotationType() ).isEqualTo( ValidB2BRepository.class );
  }
View Full Code Here

    BeanDescriptor beanDescriptor = validator.getConstraintsForClass( RentalStation.class );

    assertTrue( beanDescriptor.isBeanConstrained() );

    ConstructorDescriptor constructorDescriptor = beanDescriptor.getConstraintsForConstructor();
    ReturnValueDescriptor returnValueDescriptor = constructorDescriptor.getReturnValueDescriptor();
    Set<ConstraintDescriptor<?>> constraintDescriptors = returnValueDescriptor.getConstraintDescriptors();
    assertCorrectConstraintTypes( constraintDescriptors, ValidRentalStation.class );

    constructorDescriptor = beanDescriptor.getConstraintsForConstructor( String.class );
    List<ParameterDescriptor> parameterDescriptors = constructorDescriptor.getParameterDescriptors();
    constraintDescriptors = parameterDescriptors.get( 0 ).getConstraintDescriptors();
    assertCorrectConstraintTypes( constraintDescriptors, NotNull.class );

    MethodDescriptor methodDescriptor = beanDescriptor.getConstraintsForMethod( "getCustomers" );
    returnValueDescriptor = methodDescriptor.getReturnValueDescriptor();
    constraintDescriptors = returnValueDescriptor.getConstraintDescriptors();
    assertCorrectConstraintTypes( constraintDescriptors, NotNull.class, Size.class );

    methodDescriptor = beanDescriptor.getConstraintsForMethod( "rentCar", Customer.class, Date.class, int.class );
    parameterDescriptors = methodDescriptor.getParameterDescriptors();
View Full Code Here

TOP

Related Classes of javax.validation.metadata.ReturnValueDescriptor

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.