Package org.springframework.core

Examples of org.springframework.core.MethodParameter


  static MethodParameter PARAMETER;

  @BeforeClass
  public static void setUp() throws Exception {
    PARAMETER = new MethodParameter(Controller.class.getMethod("supportedMethod", Sort.class), 0);
  }
View Full Code Here


   * @see DATACMNS-351
   */
  @Test
  public void fallbackToGivenDefaultSort() throws Exception {

    MethodParameter parameter = TestUtils.getParameterOfMethod(getControllerClass(), "unsupportedMethod", String.class);
    SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
    Sort fallbackSort = new Sort(Direction.ASC, "ID");
    resolver.setFallbackSort(fallbackSort);

    Sort sort = resolver.resolveArgument(parameter, null, new ServletWebRequest(new MockHttpServletRequest()), null);
View Full Code Here

   * @see DATACMNS-351
   */
  @Test
  public void fallbackToDefaultDefaultSort() throws Exception {

    MethodParameter parameter = TestUtils.getParameterOfMethod(getControllerClass(), "unsupportedMethod", String.class);
    SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();

    Sort sort = resolver.resolveArgument(parameter, null, new ServletWebRequest(new MockHttpServletRequest()), null);
    assertThat(sort, is(nullValue()));
  }
View Full Code Here

  }

  @Test
  public void discoversSimpleSortFromRequest() {

    MethodParameter parameter = getParameterOfMethod("simpleDefault");
    Sort reference = new Sort("bar", "foo");
    NativeWebRequest request = getRequestWithSort(reference);

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

  }

  @Test
  public void discoversComplexSortFromRequest() {

    MethodParameter parameter = getParameterOfMethod("simpleDefault");
    Sort reference = new Sort("bar", "foo").and(new Sort("fizz", "buzz"));

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

  }

  @Test
  public void discoversQualifiedSortFromRequest() {

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

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

  }

  @Test
  public void returnsNullForSortParameterSetToNothing() throws Exception {

    MethodParameter parameter = getParameterOfMethod("supportedMethod");

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("sort", (String) null);

    SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
View Full Code Here

   * @throws Exception
   */
  @Test
  public void requestForMultipleSortPropertiesIsUnmarshalledCorrectly() throws Exception {

    MethodParameter parameter = getParameterOfMethod("supportedMethod");

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("sort", SORT_3);

    SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
View Full Code Here

        return getMethodParameter("showUserAnnotation", Object.class);
    }

    private MethodParameter getMethodParameter(String methodName, Class<?>... paramTypes) {
        Method method = ReflectionUtils.findMethod(TestController.class, methodName,paramTypes);
        return new MethodParameter(method,0);
    }
View Full Code Here

        return getMethodParameter("showUserAnnotation", Object.class);
    }

    private MethodParameter getMethodParameter(String methodName, Class<?>... paramTypes) {
        Method method = ReflectionUtils.findMethod(TestController.class, methodName,paramTypes);
        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.