Examples of ExecutableValidator


Examples of javax.validation.executable.ExecutableValidator

   * in case at least one constraint violation occurred either during parameter or return value validation.
   */
  @AroundConstruct
  @SuppressWarnings("unchecked")
  public void validateConstructorInvocation(InvocationContext ctx) throws Exception {
    ExecutableValidator executableValidator = validator.forExecutables();
    Set<ConstraintViolation<Object>> violations = executableValidator.validateConstructorParameters(
        ctx.getConstructor(),
        ctx.getParameters()
    );

    if ( !violations.isEmpty() ) {
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator

   * @throws Exception Any exception caused by the intercepted method invocation. A {@link ConstraintViolationException}
   * in case at least one constraint violation occurred either during parameter or return value validation.
   */
  @AroundInvoke
  public Object validateMethodInvocation(InvocationContext ctx) throws Exception {
    ExecutableValidator executableValidator = validator.forExecutables();
    Set<ConstraintViolation<Object>> violations = executableValidator.validateParameters(
        ctx.getTarget(),
        ctx.getMethod(),
        ctx.getParameters()
    );

    if ( !violations.isEmpty() ) {
      throw new ConstraintViolationException(
          getMessage( ctx.getMethod(), ctx.getParameters(), violations ),
          violations
      );
    }

    Object result = ctx.proceed();

    violations = executableValidator.validateReturnValue(
        ctx.getTarget(),
        ctx.getMethod(),
        result
    );

View Full Code Here

Examples of javax.validation.executable.ExecutableValidator

   * @throws Exception Any exception caused by the intercepted constructor invocation. A {@link ConstraintViolationException}
   * in case at least one constraint violation occurred either during parameter or return value validation.
   */
  @AroundConstruct
  public void validateConstructorInvocation(InvocationContext ctx) throws Exception {
    ExecutableValidator executableValidator = validator.forExecutables();
    Set<ConstraintViolation<Object>> violations = executableValidator.validateConstructorParameters(
        ctx.getConstructor(),
        ctx.getParameters()
    );

    if ( !violations.isEmpty() ) {
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator

    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Validator validator = factory
        .usingContext()
        .parameterNameProvider( new DummyParameterNameProvider() )
        .getValidator();
    ExecutableValidator executableValidator = validator.forExecutables();
    Method addOrderMethod = Customer.class.getMethod( "addOrder", Order.class );
    Set<ConstraintViolation<Customer>> constraintViolations = executableValidator.validateParameters(
        new Customer(),
        addOrderMethod,
        new Object[] { null }
    );
    assertNumberOfViolations( constraintViolations, 1 );
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator

    config.addMapping( mapping );

    Constructor<GreetingService> constructor = GreetingService.class.getConstructor();
    GreetingService createdObject = new GreetingService();

    ExecutableValidator executableValidator = getConfiguredExecutableValidator();

    Set<ConstraintViolation<GreetingService>> violations = executableValidator.validateConstructorReturnValue(
        constructor,
        createdObject
    );

    assertCorrectPropertyPaths( violations, "GreetingService.<return value>.hello" );
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator


    Constructor<GreetingService> constructor = GreetingService.class.getConstructor( User.class );
    Object[] parameterValues = new Object[] { new User( null ) };

    ExecutableValidator executableValidator = getConfiguredExecutableValidator();

    Set<ConstraintViolation<GreetingService>> violations = executableValidator.validateConstructorParameters(
        constructor,
        parameterValues
    );
    assertCorrectConstraintViolationMessages( violations, "may not be null" );
    assertCorrectPropertyPaths( violations, "GreetingService.arg0.name" );
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator


    Constructor<GreetingService> constructor = GreetingService.class.getConstructor( User.class );
    Object[] parameterValues = new Object[] { new User( null ) };

    ExecutableValidator executableValidator = getConfiguredExecutableValidator();

    Set<ConstraintViolation<GreetingService>> violations = executableValidator.validateConstructorParameters(
        constructor,
        parameterValues
    );
    assertCorrectConstraintViolationMessages( violations, "name must not be null" );
    assertCorrectPropertyPaths( violations, "GreetingService.arg0.name" );
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator

    config.addMapping( mapping );

    Constructor<GreetingService> constructor = GreetingService.class.getConstructor( User.class );
    Object[] parameterValues = new Object[] { null };

    ExecutableValidator executableValidator = getConfiguredExecutableValidator();

    Set<ConstraintViolation<GreetingService>> violations = executableValidator.validateConstructorParameters(
        constructor,
        parameterValues
    );
    assertCorrectConstraintViolationMessages( violations, "may not be null" );
    assertCorrectPropertyPaths( violations, "GreetingService.arg0" );
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator

    config.addMapping( mapping );

    Constructor<GreetingService> constructor = GreetingService.class.getConstructor( String.class );
    Object[] parameterValues = new Object[] { "" };

    ExecutableValidator executableValidator = getConfiguredExecutableValidator();

    Set<ConstraintViolation<GreetingService>> violations = executableValidator.validateConstructorParameters(
        constructor,
        parameterValues
    );

    assertCorrectConstraintViolationMessages( violations, "size must be between 1 and 10" );
View Full Code Here

Examples of javax.validation.executable.ExecutableValidator

    config.addMapping( mapping );

    Constructor<GreetingService> constructor = GreetingService.class.getConstructor( String.class );
    Object[] parameterValues = new Object[] { "" };

    ExecutableValidator executableValidator = getConfiguredExecutableValidator();

    Set<ConstraintViolation<GreetingService>> violations = executableValidator.validateConstructorParameters(
        constructor,
        parameterValues
    );

    assertCorrectConstraintViolationMessages(
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.