Package javax.validation.metadata

Examples of javax.validation.metadata.MethodDescriptor


      logger.debug("method {} has no parameters, skipping", method);
      return false;
    }
   
    BeanDescriptor bean = bvalidator.getConstraintsForClass(method.getController().getType());
    MethodDescriptor descriptor = bean.getConstraintsForMethod(method.getMethod().getName(), method.getMethod()
        .getParameterTypes());
   
    return descriptor != null && descriptor.hasConstrainedParameters();
  }
View Full Code Here


    }
    BeanDescriptor bean = bvalidator.getConstraintsForClass(controllerMethod.getController().getType());
    if(bean == null) {
      return false;
    }
    MethodDescriptor descriptor = bean.getConstraintsForMethod(method.getName(), method.getParameterTypes());
    return descriptor != null && descriptor.hasConstrainedParameters();
  }
View Full Code Here

    );
    CrossParameterDescriptor crossParameterDescriptor = constructorDescriptor.getCrossParameterDescriptor();
    assertTrue( crossParameterDescriptor.hasConstraints(), "There should be cross parameter constraints." );

    // check that the test method has a cross parameter constraint
    MethodDescriptor methodDescriptor = beanDescriptor.getConstraintsForMethod(
        "snafu",
        String.class,
        String.class
    );
    crossParameterDescriptor = methodDescriptor.getCrossParameterDescriptor();
    assertTrue( crossParameterDescriptor.hasConstraints(), "There should be cross parameter constraints." );
  }
View Full Code Here

    );
    CrossParameterDescriptor crossParameterDescriptor = constructorDescriptor.getCrossParameterDescriptor();
    assertFalse( crossParameterDescriptor.hasConstraints(), "There should be no cross parameter constraints." );

    // check that the test method has no cross parameter constraint
    MethodDescriptor methodDescriptor = beanDescriptor.getConstraintsForMethod(
        "snafu",
        String.class,
        String.class
    );
    crossParameterDescriptor = methodDescriptor.getCrossParameterDescriptor();
    assertFalse( crossParameterDescriptor.hasConstraints(), "There should be no cross parameter constraints." );
  }
View Full Code Here

    for ( Class<?> primitive : primitives ) {
      char[] stringArray = primitive.getName().toCharArray();
      stringArray[0] = Character.toUpperCase( stringArray[0] );
      String tmp = new String( stringArray );

      MethodDescriptor methodDescriptor = beanDescriptor.getConstraintsForMethod(
          "set" + tmp,
          primitive
      );

      assertNotNull(
View Full Code Here

        Validator validator = ValidatorUtil.getValidator();
        BootstrapConfiguration bootstrapConfiguration = ValidatorUtil.getConfiguration()
            .getBootstrapConfiguration();

        //when
        MethodDescriptor methodDescriptor = validator.getConstraintsForClass( CustomerService.class )
            .getConstraintsForMethod( "createCustomer", Customer.class );

        //then
        assertEquals(
            bootstrapConfiguration.getParameterNameProviderClassName(),
            CustomParameterNameProvider.class.getName()
        );

        assertEquals( methodDescriptor.getParameterDescriptors().get( 0 ).getName(), "param0" );
      }
    }
    );
  }
View Full Code Here

   * @param parameterTypes The method parameter types.
   *
   * @return an instance of {@code ReturnValueDescriptor} for the given method signature or {@code null} if no such method exists.
   */
  public static ReturnValueDescriptor getMethodReturnValueDescriptor(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
    MethodDescriptor methodDescriptor = getBeanDescriptor( clazz ).getConstraintsForMethod(
        methodName,
        parameterTypes
    );
    return methodDescriptor != null ? methodDescriptor.getReturnValueDescriptor() : null;
  }
View Full Code Here

*/
public class MethodDescriptorTest {

  @Test
  public void testGetMethod() throws Exception {
    MethodDescriptor methodDescriptor = getMethodDescriptor(
        CustomerRepositoryExt.class,
        "foo"
    );
    assertEquals( methodDescriptor.getName(), "foo" );
  }
View Full Code Here

    assertEquals( methodDescriptor.getName(), "foo" );
  }

  @Test
  public void testIsCascaded() {
    MethodDescriptor cascadingMethodDescriptor = getMethodDescriptor(
        CustomerRepositoryExt.class,
        "foo"
    );
    assertTrue( cascadingMethodDescriptor.getReturnValueDescriptor().isCascaded() );

    MethodDescriptor nonCascadingMethodDescriptor = getMethodDescriptor(
        CustomerRepositoryExt.class,
        "baz"
    );
    assertFalse( nonCascadingMethodDescriptor.getReturnValueDescriptor().isCascaded() );
  }
View Full Code Here

    assertFalse( nonCascadingMethodDescriptor.getReturnValueDescriptor().isCascaded() );
  }

  @Test
  public void testHasConstraints() {
    MethodDescriptor descriptor = getMethodDescriptor(
        CustomerRepository.class,
        "bar"
    );
    assertFalse(
        descriptor.hasConstraints(),
        "Method has no constraints."
    );

    descriptor = getMethodDescriptor(
        CustomerRepository.class,
        "methodWithCrossParameterConstraint",
        DateMidnight.class,
        DateMidnight.class
    );
    assertFalse(
        descriptor.hasConstraints(),
        "Cross-parameter constraints shouldn't be reported on MethodDescriptor."
    );
  }
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.