Package javax.validation.metadata

Examples of javax.validation.metadata.MethodDescriptor


      @SpecAssertion(section = "8.1.1.5", id = "m"),
      @SpecAssertion(section = "8.1.1.5", id = "n"),
      @SpecAssertion(section = "8.1.1.5", id = "p")
  })
  public void testIgnoreAnnotationsOnMethodLevel() {
    MethodDescriptor descriptor = TestUtil.getMethodDescriptor(
        IgnoreAnnotations.class,
        "foobar",
        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


  @SpecAssertions({
      @SpecAssertion(section = "8.1.1.7", id = "a"),
      @SpecAssertion(section = "8.1.1.7", id = "b")
  })
  public void testGroupConversionsAppliedOnMethod() throws Exception {
    MethodDescriptor methodDescriptor = TestUtil.getMethodDescriptor(
        Groups.class,
        "convert",
        String.class
    );
    assertNotNull( methodDescriptor, "the specified method should be configured in xml" );

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

    List<ParameterDescriptor> parameterDescriptors = methodDescriptor.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.5", id = "o")
  public void testValidAnnotationIsIgnored() throws Exception {
    MethodDescriptor descriptor = TestUtil.getMethodDescriptor(
        org.hibernate.beanvalidation.tck.tests.xmlconfiguration.methodvalidation.Cascaded.class,
        "cascade",
        String.class
    );
    assertNotNull( descriptor, "the specified method should be configured in xml" );

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

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

  }

  @Test
  @SpecAssertion(section = "8.1.1.5", id = "o")
  public void testValidaAnnotationIsApplied() throws Exception {
    MethodDescriptor descriptor = TestUtil.getMethodDescriptor( Cascaded.class, "cascade", String.class );
    assertNotNull( descriptor, "the specified method 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

  }

  @Test
  @SpecAssertion(section = "6.7", id = "h")
  public void testMethodDescriptorCanBeRetrievedAlsoIfValidateExecutableIsSetToNONEOnTypeLevel() {
    MethodDescriptor descriptor = getMethodDescriptor(
        OrderLine.class,
        "setItem",
        String.class
    );

    assertNotNull( descriptor );
    assertEquals( descriptor.getName(), "setItem" );
    assertEquals( descriptor.getParameterDescriptors().get( 0 ).getConstraintDescriptors().size(), 1 );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.7", id = "h")
  public void testMethodDescriptorCanBeRetrievedAlsoIfValidateExecutableIsSetToNONEOnMethodLevel() {
    MethodDescriptor descriptor = getMethodDescriptor(
        Item.class,
        "setName",
        String.class
    );

    assertNotNull( descriptor );
    assertEquals( descriptor.getName(), "setName" );
    assertEquals( descriptor.getParameterDescriptors().get( 0 ).getConstraintDescriptors().size(), 1 );
  }
View Full Code Here

        this.methodValidator = methodValidator;
    }

    public boolean accepts(ResourceMethod method) {
        BeanDescriptor bean = methodValidator.getConstraintsForClass(method.getResource().getType());
        MethodDescriptor descriptor = bean.getConstraintsForMethod(method.getMethod().getName(), method.getMethod().getParameterTypes());
        return descriptor != null && descriptor.hasConstrainedParameters();
    }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.2", id = "a")
  public void testGetElementClassForMethod() {
    MethodDescriptor descriptor = Executables.returnValueConstrainedMethod();
    assertEquals( descriptor.getElementClass(), int.class );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.2", id = "a")
  public void testGetElementClassForVoidMethod() {
    MethodDescriptor descriptor = Executables.parameterConstrainedMethod();
    assertEquals( descriptor.getElementClass(), void.class );
  }
View Full Code Here

  }

  @Test
  @SpecAssertion(section = "6.7", id = "a")
  public void testGetNameForMethod() {
    MethodDescriptor descriptor = Executables.parameterConstrainedMethod();
    assertEquals( descriptor.getName(), "createCustomer" );
  }
View Full Code Here

TOP

Related Classes of javax.validation.metadata.MethodDescriptor

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.