Package org.springframework.core

Examples of org.springframework.core.MethodParameter


      Object result = doInvoke(invocation);

      Method method = invocation.getMethod();

      // Looking up the TypeDescriptor for the return type - yes, this way o.O
      MethodParameter parameter = new MethodParameter(method, -1);
      TypeDescriptor methodReturnTypeDescriptor = TypeDescriptor.nested(parameter, 0);

      Class<?> expectedReturnType = method.getReturnType();

      if (result != null && expectedReturnType.isInstance(result)) {
View Full Code Here


  MethodParameter supportedMethodParameter;

  @Before
  public void setUp() throws Exception {
    this.supportedMethodParameter = new MethodParameter(Sample.class.getMethod("supportedMethod", Pageable.class), 0);
  }
View Full Code Here

  }

  @Test
  public void qualifierIsUsedInParameterLookup() throws Exception {

    MethodParameter parameter = new MethodParameter(Sample.class.getMethod("validQualifier", Pageable.class), 0);

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("foo_page", "2");
    request.addParameter("foo_size", "10");
View Full Code Here

   * @see DATACMNS-377
   */
  @Test
  public void rejectsInvalidCustomDefaultForPageSize() throws Exception {

    MethodParameter parameter = new MethodParameter(Sample.class.getMethod("invalidDefaultPageSize", Pageable.class), 0);

    exception.expect(IllegalStateException.class);
    exception.expectMessage("invalidDefaultPageSize");

    assertSupportedAndResult(parameter, DEFAULT_PAGE_REQUEST);
View Full Code Here

  }

  @Test
  public void rejectsNonSortParameter() {

    MethodParameter parameter = TestUtils.getParameterOfMethod(getControllerClass(), "unsupportedMethod", String.class);
    assertThat(getResolver().supportsParameter(parameter), is(false));
  }
View Full Code Here

  }

  @Test
  public void rejectsDoubleAnnotatedMethod() throws Exception {

    MethodParameter parameter = getParameterOfMethod("invalid");

    HandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
    assertThat(resolver.supportsParameter(parameter), is(true));

    exception.expect(IllegalArgumentException.class);
    exception.expectMessage(SortDefault.class.getSimpleName());
    exception.expectMessage(SortDefaults.class.getSimpleName());
    exception.expectMessage(parameter.toString());

    resolver.resolveArgument(parameter, null, TestUtils.getWebRequest(), null);
  }
View Full Code Here

  }

  @Test
  public void discoversContaineredDefault() throws Exception {

    MethodParameter parameter = getParameterOfMethod("containeredDefault");
    Sort reference = new Sort("foo", "bar");

    assertSupportedAndResolvedTo(parameter, reference);
  }
View Full Code Here

   * @see DATACMNS-343
   */
  @Test
  public void replacesExistingPaginationInformation() throws Exception {

    MethodParameter parameter = new MethodParameter(Sample.class.getMethod("supportedMethod", Pageable.class), 0);
    UriComponentsContributor resolver = new HateoasPageableHandlerMethodArgumentResolver();
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080?page=0&size=10");
    resolver.enhance(builder, parameter, new PageRequest(1, 20));

    MultiValueMap<String, String> params = builder.build().getQueryParams();
View Full Code Here

  }

  protected void assertUriStringFor(Pageable pageable, String expected) {

    UriComponentsBuilder builder = UriComponentsBuilder.fromPath("/");
    MethodParameter parameter = getParameterOfMethod("supportedMethod");

    getResolver().enhance(builder, parameter, pageable);

    assertThat(builder.build().toUriString(), endsWith(expected));
  }
View Full Code Here

  }

  public static MethodParameter getParameterOfMethod(Class<?> controller, String name, Class<?>... argumentTypes) {

    Method method = getMethod(controller, name, argumentTypes);
    return new MethodParameter(method, 0);
  }
View Full Code Here

TOP

Related Classes of org.springframework.core.MethodParameter

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.