Package br.com.caelum.vraptor.events

Examples of br.com.caelum.vraptor.events.InterceptorsExecuted


  @Override
  public void next(ControllerMethod method, Object controllerInstance) throws InterceptionException {
    Iterator<InterceptorHandler> iterator = internalStack.peek();

    if (!iterator.hasNext()) {
      interceptorsExecutedEvent.fire(new InterceptorsExecuted(controllerMethod.get(), controllerInstance));
      logger.debug("All registered interceptors have been called. End of VRaptor Request Execution.");
      return;
    }
    InterceptorHandler handler = iterator.next();
    handler.execute(this, method, controllerInstance);
View Full Code Here


  @Test
  public void shouldInvokeTheMethodAndNotProceedWithInterceptorStack() throws Exception {
    ControllerMethod method = new DefaultControllerMethod(null, DogAlike.class.getMethod("bark"));
    DogAlike auau = mock(DogAlike.class);
    when(methodInfo.getParametersValues()).thenReturn(new Object[0]);
    observer.execute(new InterceptorsExecuted(method, auau));
    verify(auau).bark();
    verify(messages).assertAbsenceOfErrors();
  }
View Full Code Here

  @Test
  public void shouldUseTheProvidedArguments() throws Exception {
    ControllerMethod method = new DefaultControllerMethod(null, DogAlike.class.getMethod("bark", int.class));
    DogAlike auau = mock(DogAlike.class);
    when(methodInfo.getParametersValues()).thenReturn(new Object[] { 3 });
    observer.execute(new InterceptorsExecuted(method, auau));
    verify(auau).bark(3);
    verify(messages).assertAbsenceOfErrors();
  }
View Full Code Here

  @Test
  public void shouldSetResultReturnedValueFromInvokedMethod() throws Exception {
    ControllerMethod method = new DefaultControllerMethod(null, XController.class.getMethod("method", Object.class));
    final XController controller = new XController();
    when(methodInfo.getParametersValues()).thenReturn(new Object[] { "string" });
    observer.execute(new InterceptorsExecuted(method, controller));
    verify(messages).assertAbsenceOfErrors();
  }
View Full Code Here

  @Test
  public void shouldSetNullWhenNullReturnedFromInvokedMethod() throws Exception {
    ControllerMethod method = new DefaultControllerMethod(null, XController.class.getMethod("method", Object.class));
    final XController controller = new XController();
    when(methodInfo.getParametersValues()).thenReturn(new Object[] { null });
    observer.execute(new InterceptorsExecuted(method, controller));
    verify(methodInfo).setResult(null);
    verify(messages).assertAbsenceOfErrors();
  }
View Full Code Here

    Method specifiedWhereToGo = AnyController.class.getMethod("specifiedWhereToGo");
    ControllerMethod method = DefaultControllerMethod.instanceFor(AnyController.class, specifiedWhereToGo);
    AnyController controller = new AnyController(validator);
    when(methodInfo.getParametersValues()).thenReturn(new Object[0]);
    doThrow(new ValidationException(Collections.<Message> emptyList())).when(validator).onErrorUse(nothing());
    observer.execute(new InterceptorsExecuted(method, controller));
  }
View Full Code Here

    final ControllerMethod method = DefaultControllerMethod.instanceFor(AnyController.class, didntSpecifyWhereToGo);
    final AnyController controller = new AnyController(validator);
    doThrow(new IllegalStateException()).when(messages).assertAbsenceOfErrors();
    when(methodInfo.getParametersValues()).thenReturn(new Object[0]);

    observer.execute(new InterceptorsExecuted(method, controller));
  }
View Full Code Here

    ControllerMethod controllerMethod = instanceFor(AnyController.class, method);
    AnyController controller = new AnyController(validator);

    expected.expect(ApplicationLogicException.class);
    expected.expectCause(any(TestException.class));
    observer.execute(new InterceptorsExecuted(controllerMethod, controller));
    verify(messages).assertAbsenceOfErrors();
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.events.InterceptorsExecuted

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.