Package br.com.caelum.vraptor.core

Examples of br.com.caelum.vraptor.core.MethodInfo


  }

  @Test
  public void shouldValidateMethodWithConstraint()
  throws Exception {
  MethodInfo info = new DefaultMethodInfo();
  info.setParameters(new Object[] { null });
  info.setResourceMethod(withConstraint);

  interceptor = new MethodValidatorInterceptor(l10n, interpolator, validator, info, factory.getValidator(), provider);
  when(l10n.getLocale()).thenReturn(new Locale("pt", "br"));

  MyController controller = new MyController();
  interceptor.intercept(stack, info.getResourceMethod(), controller);
 
  assertThat(validator.getErrors(), hasSize(1));
  assertThat(validator.getErrors().get(0).getCategory(), is("withConstraint.email"));
  }
View Full Code Here


  }

  @Test
  public void shouldUseDefaultLocale()
  throws Exception {
  MethodInfo info = new DefaultMethodInfo();
  info.setParameters(new Object[] { null });
  info.setResourceMethod(withConstraint);

  interceptor = new MethodValidatorInterceptor(l10n, interpolator, validator, info, factory.getValidator(), provider);

  MyController controller = new MyController();
  interceptor.intercept(stack, info.getResourceMethod(), controller);

  assertThat(validator.getErrors(), hasSize(1));
  assertThat(validator.getErrors().get(0).getCategory(), is("withConstraint.email"));
  assertThat(validator.getErrors().get(0).getMessage(), is("may not be null"));
  }
View Full Code Here

  }

  @Test
  public void shouldValidateMethodWithTwoConstraints()
  throws Exception {
  MethodInfo info = new DefaultMethodInfo();
  info.setParameters(new Object[] { null, new Customer(null, null) });
  info.setResourceMethod(withTwoConstraints);

  interceptor = new MethodValidatorInterceptor(l10n, interpolator, validator, info, factory.getValidator(), provider);
  when(l10n.getLocale()).thenReturn(new Locale("pt", "br"));

  MyController controller = new MyController();
  interceptor.intercept(stack, info.getResourceMethod(), controller);
  String messages = validator.getErrors().toString();

  assertThat(validator.getErrors(), hasSize(3));
 
  assertThat(messages, containsString("não pode ser nulo"));
View Full Code Here

  public void setUp() throws Exception {
    when(request.getParameterNames()).thenReturn(Collections.<String> emptyEnumeration());
    when(deserializers.deserializerFor("application/xml", container)).thenReturn(deserializer);
    when(request.getContentType()).thenReturn("application/xml");
   
    methodInfo = new MethodInfo(new ParanamerNameProvider());
    instantiator = new ParametersInstantiator(provider, methodInfo, validator, request, flash);
    deserializing = new DeserializingObserver(deserializers, container);
   
    controllerMethod = new DefaultControllerMethod(null, DeserializingObserverTest
        .DummyResource.class.getDeclaredMethod("consumeXml", String.class, String.class));
View Full Code Here

  @Before
  public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    methodInfo = new MethodInfo(new ParanamerNameProvider());

    observer = new DeserializingObserver(deserializers, container);
    consumeXml = new DefaultControllerMethod(null, DummyResource.class.getDeclaredMethod("consumeXml", String.class, String.class));
    doesntConsume = new DefaultControllerMethod(null, DummyResource.class.getDeclaredMethod("doesntConsume"));
  }
View Full Code Here

  @Before
  public void setup() {
    MockitoAnnotations.initMocks(this);
    method = DefaultControllerMethod.instanceFor(AnyResource.class, AnyResource.class.getDeclaredMethods()[0]);
    proxifier = new JavassistProxifier();
    methodInfo = new MethodInfo(new ParanamerNameProvider());
    methodInfo.setControllerMethod(method);
    fixedResolver = new PathResolver() {
      @Override
      public String pathFor(ControllerMethod method) {
        return "fixed";
View Full Code Here

  @Before
  public void setup() {
    MockitoAnnotations.initMocks(this);

    proxifier = new JavassistProxifier();
    methodInfo = new MethodInfo(new ParanamerNameProvider());
    this.logicResult = new DefaultLogicResult(proxifier, router, request, response, container,
        resolver, extractor, flash, methodInfo);
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.core.MethodInfo

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.