Package javax.validation.metadata

Examples of javax.validation.metadata.ConstructorDescriptor


  }

  @Test
  @SpecAssertion(section = "8.1.1.4", id = "k")
  public void testIgnoreAnnotationsOnReturnValueParameterAndCrossParameter() {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor(
        IgnoreAnnotations.class,
        String.class,
        String.class
    );
    CrossParameterDescriptor crossParameterDescriptor = descriptor.getCrossParameterDescriptor();
    assertFalse( crossParameterDescriptor.hasConstraints(), "Cross parameter constraints should be ignored." );

    ReturnValueDescriptor returnValueDescriptor = descriptor.getReturnValueDescriptor();
    assertFalse( returnValueDescriptor.hasConstraints(), "Return value constraints should be ignored." );

    ParameterDescriptor parameterDescriptor = descriptor.getParameterDescriptors().get( 0 );
    assertFalse( parameterDescriptor.hasConstraints(), "First parameter constraints should be ignored." );

    parameterDescriptor = descriptor.getParameterDescriptors().get( 1 );
    assertTrue( parameterDescriptor.hasConstraints(), "Second parameter constraints should be applied." );
  }
View Full Code Here


      @SpecAssertion(section = "8.1.1.4", id = "l"),
      @SpecAssertion(section = "8.1.1.4", id = "m"),
      @SpecAssertion(section = "8.1.1.4", id = "o")
  })
  public void testIgnoreAnnotationsOnConstructorLevel() {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor(
        IgnoreAnnotations.class,
        String.class,
        String.class
    );
    CrossParameterDescriptor crossParameterDescriptor = descriptor.getCrossParameterDescriptor();
    assertFalse( crossParameterDescriptor.hasConstraints(), "Cross parameter constraints should be ignored." );

    ReturnValueDescriptor returnValueDescriptor = descriptor.getReturnValueDescriptor();
    assertFalse( returnValueDescriptor.hasConstraints(), "Return value constraints should be ignored." );
    assertTrue( returnValueDescriptor.getGroupConversions().isEmpty(), "Group conversions should be ignored" );

    ParameterDescriptor parameterDescriptor = descriptor.getParameterDescriptors().get( 0 );
    assertFalse( parameterDescriptor.hasConstraints(), "First parameter constraints should be ignored." );
    assertTrue( parameterDescriptor.getGroupConversions().isEmpty(), "Group conversions should be ignored" );

    parameterDescriptor = descriptor.getParameterDescriptors().get( 1 );
    assertTrue( parameterDescriptor.hasConstraints(), "Second parameter constraints should be applied." );
    assertEquals( parameterDescriptor.getGroupConversions().size(), 2, "All group conversions should be combined" );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "8.1.1.4", id = "n")
  public void testValidAnnotationIsIgnored() throws Exception {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor( Cascaded.class, String.class );
    assertNotNull( descriptor, "the specified constructor should be configured in xml" );

    ReturnValueDescriptor returnValueDescriptor = descriptor.getReturnValueDescriptor();
    assertFalse( returnValueDescriptor.isCascaded(), "Cascaded validation should disabled" );

    ParameterDescriptor parameterDescriptor = descriptor.getParameterDescriptors().get( 0 );
    assertFalse( parameterDescriptor.isCascaded(), "Cascaded validation should disabled" );
  }
View Full Code Here

      @SpecAssertion(section = "8.1.1.4", id = "a"),
      @SpecAssertion(section = "8.1.1.4", id = "c"),
      @SpecAssertion(section = "8.1.1.4", id = "e")
  })
  public void testXmlConfiguredConstructors() throws Exception {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor( CustomerRepository.class );
    assertNotNull( descriptor, "the specified constructor should be configured in xml" );
    assertTrue( descriptor.hasConstrainedReturnValue() );

    descriptor = TestUtil.getConstructorDescriptor( CustomerRepository.class, String.class );
    assertNotNull( descriptor, "the specified constructor should be configured in xml" );
    assertTrue( descriptor.hasConstrainedParameters() );

    descriptor = TestUtil.getConstructorDescriptor( CustomerRepository.class, CustomerRepository.class );
    assertNotNull( descriptor, "the specified constructor should be configured in xml" );
    assertTrue( descriptor.hasConstrainedParameters() );
  }
View Full Code Here

      @SpecAssertion(section = "8.1.1.4", id = "a"),
      @SpecAssertion(section = "8.1.1.4", id = "b"),
      @SpecAssertion(section = "8.1.1.4", id = "c")
  })
  public void testVarargsConstructorParameter() throws Exception {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor(
        CustomerRepository.class,
        String.class,
        Customer[].class
    );
    assertNotNull( descriptor, "the specified constructor should be configured in xml" );
    assertTrue( descriptor.hasConstrainedParameters() );
  }
View Full Code Here

      @SpecAssertion(section = "8.1.1.4", id = "c"),
      @SpecAssertion(section = "8.1.1.4", id = "f"),
      @SpecAssertion(section = "8.1.1.4", id = "j")
  })
  public void testConstructorCrossParameterConstraint() throws Exception {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor(
        CustomerRepository.class,
        CustomerRepository.class,
        CustomerRepository.class
    );
    assertNotNull( descriptor, "the specified constructor should be configured in xml" );
    CrossParameterDescriptor crossParameterDescriptor = descriptor.getCrossParameterDescriptor();
    assertTrue( crossParameterDescriptor.hasConstraints() );

    Set<ConstraintDescriptor<?>> constraintDescriptors = crossParameterDescriptor.getConstraintDescriptors();
    assertTrue( constraintDescriptors.size() == 1 );
View Full Code Here

  @SpecAssertions({
      @SpecAssertion(section = "6.11", id = "a"),
      @SpecAssertion(section = "8.1.1.4", id = "g")
  })
  public void testConstraintOnConstructorReturnValueAndParameter() throws Exception {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor(
        CustomerRepository.class,
        String.class
    );
    assertNotNull( descriptor, "the specified constructor should be configured in xml" );

    ReturnValueDescriptor returnValueDescriptor = descriptor.getReturnValueDescriptor();
    Set<ConstraintDescriptor<?>> constraintDescriptors = returnValueDescriptor.getConstraintDescriptors();
    assertTrue( constraintDescriptors.size() == 1 );

    ConstraintDescriptor<?> constraintDescriptor = constraintDescriptors.iterator().next();
    assertEquals(
        constraintDescriptor.getAnnotation().annotationType(),
        NotNull.class,
        "Unexpected constraint type"
    );

    List<ParameterDescriptor> parameterDescriptors = descriptor.getParameterDescriptors();
    assertTrue( parameterDescriptors.size() == 1 );

    ParameterDescriptor parameterDescriptor = parameterDescriptors.get( 0 );
    constraintDescriptors = parameterDescriptor.getConstraintDescriptors();
    assertTrue( constraintDescriptors.size() == 1 );
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "8.1.1.4", id = "h")
  public void testCascadingOnReturnValueAndParameter() throws Exception {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor(
        CustomerRepository.class,
        CustomerRepository.class
    );
    assertNotNull( descriptor, "the specified constructor should be configured in xml" );

    ReturnValueDescriptor returnValueDescriptor = descriptor.getReturnValueDescriptor();
    assertTrue( returnValueDescriptor.isCascaded(), "<valid/> is used to configure cascading" );


    List<ParameterDescriptor> parameterDescriptors = descriptor.getParameterDescriptors();
    assertTrue( parameterDescriptors.size() == 1 );

    ParameterDescriptor parameterDescriptor = parameterDescriptors.get( 0 );
    assertTrue( parameterDescriptor.isCascaded(), "<valid/> is used to configure cascading" );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "8.1.1.4", id = "i")
  public void testGroupConversionOnReturnValueAndParameter() throws Exception {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor(
        CustomerRepository.class,
        CustomerRepository.class
    );
    assertNotNull( descriptor, "the specified constructor should be configured in xml" );

    ReturnValueDescriptor returnValueDescriptor = descriptor.getReturnValueDescriptor();
    Set<GroupConversionDescriptor> groupConversionDescriptors = returnValueDescriptor.getGroupConversions();
    assertTrue( groupConversionDescriptors.size() == 1 );

    GroupConversionDescriptor groupConversionDescriptor = groupConversionDescriptors.iterator().next();
    assertEquals( groupConversionDescriptor.getFrom(), Default.class, "Wrong from class for group conversion" );

    List<ParameterDescriptor> parameterDescriptors = descriptor.getParameterDescriptors();
    assertTrue( parameterDescriptors.size() == 1 );

    ParameterDescriptor parameterDescriptor = parameterDescriptors.get( 0 );
    groupConversionDescriptors = parameterDescriptor.getGroupConversions();
    assertTrue( groupConversionDescriptors.size() == 1 );
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "8.1.1.4", id = "n")
  public void testValidaAnnotationIsApplied() throws Exception {
    ConstructorDescriptor descriptor = TestUtil.getConstructorDescriptor( Cascaded.class, String.class );
    assertNotNull( descriptor, "the specified constructor should be configured in xml" );

    ReturnValueDescriptor returnValueDescriptor = descriptor.getReturnValueDescriptor();
    assertTrue( returnValueDescriptor.isCascaded(), "Cascaded validation should be applied" );

    ParameterDescriptor parameterDescriptor = descriptor.getParameterDescriptors().get( 0 );
    assertTrue( parameterDescriptor.isCascaded(), "Cascaded validation should be applied" );
  }
View Full Code Here

TOP

Related Classes of javax.validation.metadata.ConstructorDescriptor

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.