Package br.com.caelum.vraptor.validator

Examples of br.com.caelum.vraptor.validator.ValidationException


    Method specifiedWhereToGo = AnyController.class.getMethod("specifiedWhereToGo");
    ResourceMethod method = DefaultResourceMethod.instanceFor(AnyController.class, specifiedWhereToGo);
    AnyController controller = new AnyController(validator);
   
    when(info.getParameters()).thenReturn(new Object[0]);
    doThrow(new ValidationException(Collections.<Message> emptyList())).when(validator).onErrorUse(nothing());
    when(validator.hasErrors()).thenReturn(true);
       
    interceptor.intercept(stack, method, controller);
  }
View Full Code Here


  public void validate(Object object) {
  }

  public <T extends View> T onErrorUse(Class<T> view) {
    if(!this.errors.isEmpty()) {
      throw new ValidationException(errors);
    }
    return new MockResult().use(view);
  }
View Full Code Here

    this.proxifier = proxifier;
  }

  public <T extends View> T instanceFor(final Class<T> view, final List<Message> errors) {
    if (view.equals(EmptyResult.class)) {
      throw new ValidationException(errors);
    }

    return proxifier.proxify(view, throwValidationErrorOnFinalMethods(view, errors, result.use(view)));

  }
View Full Code Here

      final T viewInstance) {
    return new MethodInvocation<T>() {
      public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
        final Object instance = new Mirror().on(viewInstance).invoke().method(method).withArgs(args);
        if (method.getReturnType() == void.class) {
          throw new ValidationException(errors);
        }

        if (view.isAssignableFrom(method.getReturnType())) {
          return proxy;
        }
View Full Code Here

      final T instance) {
    return new MethodInvocation<T>() {
      public Object intercept(Object proxy, Method method, Object[] args, SuperMethod superMethod) {
        new Mirror().on(instance).invoke().method(method).withArgs(args);

        throw new ValidationException(errors);
      }
    };
  }
View Full Code Here

    }
    result.include("errors", errors);
    if (Info.isOldComponent(resource.getResource())) {
      info.setResult("invalid");
      result.use(Results.page()).forward();
      throw new ValidationException(new ArrayList<Message>());
    } else {
      return viewsFactory.instanceFor(view, new ArrayList<Message>());
    }
  }
View Full Code Here

  }

  @Override
  public <T extends View> T onErrorUse(Class<T> view) {
    if(!this.errors.isEmpty()) {
      throw new ValidationException(errors);
    }
    return new MockResult().use(view);
  }
View Full Code Here

    this.errors.addAll(validations.getErrors());
  }

  public <T extends View> T onErrorUse(Class<T> view) {
    if(!this.errors.isEmpty()) {
      throw new ValidationException(errors);
    }
    return new MockResult().use(view);
  }
View Full Code Here

    this.proxifier = proxifier;
  }

  public <T extends View> T instanceFor(final Class<T> view, final List<Message> errors) {
    if (view.equals(EmptyResult.class)) {
      throw new ValidationException(errors);
    }

    return proxifier.proxify(view, throwValidationErrorOnFinalMethods(view, errors, result.use(view)));

  }
View Full Code Here

      final T viewInstance) {
    return new MethodInvocation<T>() {
      public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
        final Object instance = new Mirror().on(viewInstance).invoke().method(method).withArgs(args);
        if (method.getReturnType() == void.class) {
          throw new ValidationException(errors);
        }

        if (view.isAssignableFrom(method.getReturnType())) {
          return proxy;
        }
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.validator.ValidationException

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.