Package org.springframework.data.domain

Examples of org.springframework.data.domain.PageRequest


    // Read side
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("page", "0");
    request.addParameter("size", "200");

    assertSupportedAndResult(supportedMethodParameter, new PageRequest(0, 100), request);
  }
View Full Code Here


    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("foo_page", "2");
    request.addParameter("foo_size", "10");

    assertSupportedAndResult(parameter, new PageRequest(2, 10), request);
  }
View Full Code Here

  }

  @Test
  public void returnsPageableIfAvailable() {

    Pageable pageable = new PageRequest(0, 10);
    ParameterAccessor accessor = new ParametersParameterAccessor(pageableParameters, new Object[] { "test", pageable });
    assertThat(accessor.getPageable(), is(pageable));
    assertThat(accessor.getSort(), is(nullValue()));
  }
View Full Code Here

  @Test
  public void returnsSortFromPageableIfAvailable() throws Exception {

    Sort sort = new Sort("foo");
    Pageable pageable = new PageRequest(0, 10, sort);
    ParameterAccessor accessor = new ParametersParameterAccessor(pageableParameters, new Object[] { "test", pageable });
    assertThat(accessor.getPageable(), is(pageable));
    assertThat(accessor.getSort(), is(sort));
  }
View Full Code Here

  public void invokesFindAllWithPageableByDefault() throws Exception {

    Repository repository = mock(Repository.class);
    Method method = PagingAndSortingRepository.class.getMethod("findAll", Pageable.class);

    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(new PageRequest(0, 10));
    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll((Pageable) null);
  }
View Full Code Here

  public void invokesRedeclaredFindAllWithPageable() throws Exception {

    RepositoryWithRedeclaredFindAllWithPageable repository = mock(RepositoryWithRedeclaredFindAllWithPageable.class);
    Method method = RepositoryWithRedeclaredFindAllWithPageable.class.getMethod("findAll", Pageable.class);

    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(new PageRequest(0, 10));
    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll((Pageable) null);
  }
View Full Code Here

  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();

    List<String> page = params.get("page");
    assertThat(page.size(), is(1));
View Full Code Here

  /**
   * @see DATACMNS-335
   */
  @Test
  public void preventsPageSizeFromExceedingMayValueIfConfiguredOnWrite() throws Exception {
    assertUriStringFor(new PageRequest(0, 200), "page=0&size=100");
  }
View Full Code Here

    Method method = ManualCrudRepository.class.getMethod("findAll");
    ManualCrudRepository repository = mock(ManualCrudRepository.class);

    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll((Pageable) null);
    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(new PageRequest(0, 10));
    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll((Sort) null);
    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(new Sort("foo"));
  }
View Full Code Here

    Method method = RepoWithFindAllWithSort.class.getMethod("findAll", Sort.class);
    RepoWithFindAllWithSort repository = mock(RepoWithFindAllWithSort.class);

    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll((Pageable) null);
    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(new PageRequest(0, 10));
    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll((Sort) null);
    getInvokerFor(repository, expectInvocationOf(method)).invokeFindAll(new Sort("foo"));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.domain.PageRequest

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.