Package br.com.caelum.vraptor.events

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


    methodInfo.setControllerMethod(controllerMethod);

    when(request.getHeader("X-MyApp-Password")).thenReturn(null);
    when(parametersProvider.getParametersFor(controllerMethod, errors)).thenReturn(new Object[] { "" });

    instantiator.instantiate(new InterceptorsReady(controllerMethod));
    verify(request, never()).setParameter(anyString(), anyString());
  }
View Full Code Here


  public void shouldNotAddHeaderInformationToRequestWhenHeaderParamAnnotationIsNotPresent() throws Exception {
    Object[] values = new Object[] { "bazinga" };
    when(parametersProvider.getParametersFor(otherMethod, errors)).thenReturn(values);

    methodInfo.setControllerMethod(otherMethod);
    instantiator.instantiate(new InterceptorsReady(otherMethod));

    verify(request, never()).setParameter(anyString(), anyString());
    verify(validator).addAll(Collections.<Message>emptyList());
  }
View Full Code Here

    public void doesntConsume() {}
  }

  @Test
  public void shouldOnlyAcceptMethodsWithConsumesAnnotation() throws Exception {
    observer.deserializes(new InterceptorsReady(doesntConsume), request, methodInfo, status);
    verifyZeroInteractions(request);
  }
View Full Code Here

  @Test
  public void willSetHttpStatusCode415IfTheControllerMethodDoesNotSupportTheGivenMediaTypes() throws Exception {
    when(request.getContentType()).thenReturn("image/jpeg");

    observer.deserializes(new InterceptorsReady(consumeXml), request, methodInfo, status);

    verify(status).unsupportedMediaType("Request with media type [image/jpeg]. Expecting one of [application/xml].");
  }
View Full Code Here

  @Test
  public void willSetHttpStatusCode415IfThereIsNoDeserializerButIsAccepted() throws Exception {
    when(request.getContentType()).thenReturn("application/xml");
    when(deserializers.deserializerFor("application/xml", container)).thenReturn(null);

    observer.deserializes(new InterceptorsReady(consumeXml), request, methodInfo, status);

    verify(status).unsupportedMediaType("Unable to handle media type [application/xml]: no deserializer found.");
  }
View Full Code Here

    when(request.getContentType()).thenReturn("application/xml");
    when(deserializer.deserialize(null, consumeXml)).thenReturn(new Object[] {"abc", "def"});
    when(deserializers.deserializerFor("application/xml", container)).thenReturn(deserializer);

    observer.deserializes(new InterceptorsReady(consumeXml), request, methodInfo, status);

    assertEquals(methodInfo.getValuedParameters()[0].getValue(), "abc");
    assertEquals(methodInfo.getValuedParameters()[1].getValue(), "def");
  }
View Full Code Here

    when(request.getContentType()).thenReturn("application/xml; charset=UTF-8");
    when(deserializer.deserialize(null, consumeXml)).thenReturn(new Object[] {"abc", "def"});
    when(deserializers.deserializerFor("application/xml", container)).thenReturn(deserializer);

    observer.deserializes(new InterceptorsReady(consumeXml), request, methodInfo, status);

    assertEquals(methodInfo.getValuedParameters()[0].getValue(), "abc");
    assertEquals(methodInfo.getValuedParameters()[1].getValue(), "def");
  }
View Full Code Here

    final Deserializer deserializer = mock(Deserializer.class);
    when(deserializer.deserialize(null, consumesAnything)).thenReturn(new Object[] {"abc", "def"});

    when(deserializers.deserializerFor("application/xml", container)).thenReturn(deserializer);
    observer.deserializes(new InterceptorsReady(consumesAnything), request, methodInfo, status);

    assertEquals(methodInfo.getValuedParameters()[0].getValue(), "abc");
    assertEquals(methodInfo.getValuedParameters()[1].getValue(), "def");
  }
View Full Code Here

  public void shouldNotDeserializeIfHasNoContentType() throws Exception {
    final ControllerMethod consumesAnything = new DefaultControllerMethod(null, DummyResource.class.getDeclaredMethod("consumesAnything", String.class, String.class));

    when(request.getContentType()).thenReturn(null);
    methodInfo.setControllerMethod(consumesAnything);
    observer.deserializes(new InterceptorsReady(consumesAnything), request, methodInfo, status);

    assertEquals(methodInfo.getValuedParameters()[0].getValue(), null);
    assertEquals(methodInfo.getValuedParameters()[1].getValue(), null);
  }
View Full Code Here

    when(request.getContentType()).thenReturn("application/xml");
    when(deserializer.deserialize(null, consumeXml)).thenReturn(new Object[] {null, "deserialized"});

    when(deserializers.deserializerFor("application/xml", container)).thenReturn(deserializer);
    observer.deserializes(new InterceptorsReady(consumeXml), request, methodInfo, status);

    assertEquals(methodInfo.getValuedParameters()[0].getValue(), "original1");
    assertEquals(methodInfo.getValuedParameters()[1].getValue(), "deserialized");
  }
View Full Code Here

TOP

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

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.