Package br.com.caelum.vraptor

Examples of br.com.caelum.vraptor.Result


  }

  @Test
  public void returnsDependenciesIfContainerCanProvide() throws Exception {
    thereAreNoParameters();
    Result result = mock(Result.class);

    when(container.canProvide(Result.class)).thenReturn(true);
    when(container.instanceFor(Result.class)).thenReturn(result);

    Result returned = getParameters(dependency);
    assertThat(returned, is(result));
  }
View Full Code Here


  @Test
  public void returnsDependenciesIfRequestCanProvide() throws Exception {
    thereAreNoParameters();
    when(nameProvider.parameterNamesFor(dependency.getMethod())).thenReturn(new String[] {"result"});
    Result result = mock(Result.class);

    when(request.getAttribute("result")).thenReturn(result);

    Result returned = getParameters(dependency);
    assertThat(returned, is(result));
  }
View Full Code Here

    userInfo = new UserInfo();

    // for Result and Validator, there are helpful mocked implementations
    // that you can use if you want to just ignore them or perform simple
    // assertions
    Result result = new MockResult();
    Validator validator = new MockValidator();

    controller = new HomeController(dao, userInfo, result, validator);
  }
View Full Code Here

    executeInsideRequest(new WhatToDo<Void>() {
      public Void execute(final RequestInfo request, int counter) {
        return provider.provideForRequest(request, new Execution<Void>() {

          public Void insideRequest(Container container) {
            Result result = container.instanceFor(Result.class);
            HttpServletRequest request = container.instanceFor(HttpServletRequest.class);
            assertSame(result, Objects.firstNonNull(request.getAttribute("result"), request.getAttribute("defaultResult")));
            return null;
          }
        });
View Full Code Here

  /**
   * @bug #337
   */
  @Test
  public void shouldForwardToTheRightDefaultValue() throws Exception {
    Result result = mock(Result.class);
    PageResult pageResult = new DefaultPageResult(request, response, methodInfo, resolver, proxifier);
    when(result.use(PageResult.class)).thenReturn(pageResult);
    when(container.instanceFor(TheComponent.class)).thenReturn(new TheComponent(result));
    when(resolver.pathFor(argThat(sameMethodAs(TheComponent.class.getDeclaredMethod("method"))))).thenReturn("controlled!");
    when(request.getRequestDispatcher(anyString())).thenThrow(new AssertionError("should have called with the right method!"));
    doReturn(dispatcher).when(request).getRequestDispatcher("controlled!");

View Full Code Here

        //TODO: find a better alternative
        } catch (Exception e) {
          applicationError = e.getCause();
          response.setStatus(500);
        }
        Result vraptorResult = (Result) ((TargetInstanceProxy) result.get()).getTargetInstance();
        Validator vraptorValidator = (Validator) ((TargetInstanceProxy) validator.get()).getTargetInstance();
        vRaptorTestResult = new VRaptorTestResult(vraptorResult, response, request, vraptorValidator);
        vRaptorTestResult.setApplicationError(applicationError);
        return vRaptorTestResult;
      }
View Full Code Here

  /**
   * @bug #337
   */
  @Test
  public void shouldForwardToTheRightDefaultValue() throws Exception {
    Result result = mock(Result.class);
    PageResult pageResult = new DefaultPageResult(request, response, methodInfo, resolver, proxifier);
    when(result.use(PageResult.class)).thenReturn(pageResult);
    when(container.instanceFor(TheComponent.class)).thenReturn(new TheComponent(result));
    when(resolver.pathFor(argThat(sameMethodAs(TheComponent.class.getDeclaredMethod("method"))))).thenReturn("controlled!");
    when(request.getRequestDispatcher(anyString())).thenThrow(new AssertionError("should have called with the right method!"));
    doReturn(dispatcher).when(request).getRequestDispatcher("controlled!");
   
View Full Code Here

  }

  @Test
  public void returnsDependenciesIfContainerCanProvide() throws Exception {
    thereAreNoParameters();
    Result result = mock(Result.class);

    when(container.canProvide(Result.class)).thenReturn(true);
    when(container.instanceFor(Result.class)).thenReturn(result);

    Result returned = getFirstParameterFor(method("dependency", Result.class));
    assertThat(returned, is(result));
  }
View Full Code Here

  }

  @Test
  public void returnsDependenciesIfRequestCanProvide() throws Exception {
    thereAreNoParameters();
    Result result = mock(Result.class);

    when(request.getAttribute("result")).thenReturn(result);

    Result returned = getFirstParameterFor(method("dependency", Result.class));
    assertThat(returned, is(result));
  }
View Full Code Here

    assertThat(abc.iterator().next().getX(), is(1l));
  }

  @Test
  public void shouldInjectOnlyAttributesWithSameType() throws Exception {
    Result result = mock(Result.class);
    when(request.getAttribute("result")).thenReturn(result);
    when(request.getParameterMap()).thenReturn(singletonMap("result", new String[] { "buggy" }));

    ControllerMethod method = method(OtherResource.class, OtherResource.class, "logic", String.class);
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.Result

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.