Examples of MethodExecuted


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

                + "validator.onErrorUse(page()).of(AnyController.class).anyMethod();\n"
                + "or any view that you like.\n"
                + "If you didn't add any validation error, it is possible that a conversion error had happened.");
      }
      this.methodInfo.setResult(result);
      methodExecutedEvent.fire(new MethodExecuted(method, methodInfo));
    } catch (IllegalArgumentException e) {
      throw new InterceptionException(e);
    } catch (MethodExecutorException e) {
      throwIfNotValidationException(e,
          new ApplicationLogicException("your controller raised an exception", e.getCause()));
View Full Code Here

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

                + "validator.onErrorUse(page()).of(AnyController.class).anyMethod();\n"
                + "or any view that you like.\n"
                + "If you didn't add any validation error, it is possible that a conversion error had happened.");
      }
      this.methodInfo.setResult(result);
      methodExecutedEvent.fire(new MethodExecuted(method, methodInfo));
    } catch (IllegalArgumentException e) {
      throw new InterceptionException(e);
    } catch (ReflectionProviderException e) {
      throwIfNotValidationException(e, e.getCause());
    } catch (Exception e) {
View Full Code Here

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

                + "validator.onErrorUse(page()).of(AnyController.class).anyMethod();\n"
                + "or any view that you like.\n"
                + "If you didn't add any validation error, it is possible that a conversion error had happened.");
      }
      this.methodInfo.setResult(result);
      methodExecutedEvent.fire(new MethodExecuted(method, methodInfo));
    } catch (IllegalArgumentException e) {
      throw new InterceptionException(e);
    } catch (Exception e) {
      throwIfNotValidationException(e, new ApplicationLogicException(e));
    }
View Full Code Here

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

      Object result = new Mirror().on(instance).invoke().method(reflectionMethod).withArgs(parameters);

      messages.assertAbsenceOfErrors();
     
      this.methodInfo.setResult(result);
      methodExecutedEvent.fire(new MethodExecuted(method, methodInfo));
    } catch (IllegalArgumentException e) {
      throw new InterceptionException(e);
    } catch (ReflectionProviderException e) {
      throwIfNotValidationException(e, e.getCause());
    } catch (Exception e) {
View Full Code Here

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

  public void shouldOutjectWithASimpleTypeName() throws NoSuchMethodException {
    Method method = MyComponent.class.getMethod("returnsAString");
    when(controllerMethod.getMethod()).thenReturn(method);
    when(methodInfo.getResult()).thenReturn("myString");
    when(extractor.nameFor(String.class)).thenReturn("string");
    outjectResult.outject(new MethodExecuted(controllerMethod, methodInfo), result, methodInfo);
    verify(result).include("string", "myString");
  }
View Full Code Here

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

  public void shouldOutjectACollectionAsAList() throws NoSuchMethodException {
    Method method = MyComponent.class.getMethod("returnsStrings");
    when(controllerMethod.getMethod()).thenReturn(method);
    when(methodInfo.getResult()).thenReturn("myString");
    when(extractor.nameFor(method.getGenericReturnType())).thenReturn("stringList");
    outjectResult.outject(new MethodExecuted(controllerMethod, methodInfo), result, methodInfo);
    verify(result).include("stringList", "myString");
  }
View Full Code Here

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

  @Test
  public void whenResultIsADownloadShouldUseIt() throws Exception {
    when(controllerMethod.getMethod()).thenReturn(getMethod("download"));
    Download download = mock(Download.class);
    when(methodInfo.getResult()).thenReturn(download);
    downloadObserver.download(new MethodExecuted(controllerMethod, methodInfo), result);
    verify(download).write(response);
  }
View Full Code Here

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

  @Test
  public void whenResultIsAnInputStreamShouldCreateAInputStreamDownload() throws Exception {
    when(controllerMethod.getMethod()).thenReturn(getMethod("asByte"));
    byte[] bytes = "abc".getBytes();
    when(methodInfo.getResult()).thenReturn(new ByteArrayInputStream(bytes));
    downloadObserver.download(new MethodExecuted(controllerMethod, methodInfo), result);
    verify(outputStream).write(argThat(is(arrayStartingWith(bytes))), eq(0), eq(3));
  }
View Full Code Here

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

  @Test
  public void whenResultIsAnInputStreamShouldCreateAByteArrayDownload() throws Exception {
    when(controllerMethod.getMethod()).thenReturn(getMethod("asByte"));
    byte[] bytes = "abc".getBytes();
    when(methodInfo.getResult()).thenReturn(bytes);
    downloadObserver.download(new MethodExecuted(controllerMethod, methodInfo), result);
    verify(outputStream).write(argThat(is(arrayStartingWith(bytes))), eq(0), eq(3));
  }
View Full Code Here

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

  public void whenResultIsAFileShouldCreateAFileDownload() throws Exception {
    when(controllerMethod.getMethod()).thenReturn(getMethod("file"));
    File tmp = tmpdir.newFile();
    Files.write(tmp.toPath(), "abc".getBytes());
    when(methodInfo.getResult()).thenReturn(tmp);
    downloadObserver.download(new MethodExecuted(controllerMethod, methodInfo), result);
    verify(outputStream).write(argThat(is(arrayStartingWith("abc".getBytes()))), eq(0), eq(3));
    tmp.delete();
  }
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.