Package org.springframework.data.domain

Examples of org.springframework.data.domain.Pageable


        request.setParameter("sort2.id", "desc");
        request.setParameter("sort1.baseInfo.realname", "asc");

        MethodParameter parameter = new MethodParameter(parameterDefaultPageable, 0);
        NativeWebRequest webRequest = new ServletWebRequest(request);
        Pageable pageable = (Pageable) new PageableMethodArgumentResolver().resolveArgument(parameter, null, webRequest, null);

        assertEquals(Controller.DEFAULT_PAGENUMBER, pageable.getPageNumber());
        assertEquals(Controller.DEFAULT_PAGESIZE, pageable.getPageSize());
        Sort expectedSort = new Sort(Sort.Direction.ASC, "baseInfo.realname").and(new Sort(Sort.Direction.DESC, "id"));
        assertEquals(expectedSort, pageable.getSort());
    }
View Full Code Here


        request.setParameter("foo_sort2.id", "desc");
        request.setParameter("foo_sort1.baseInfo.realname", "asc");

        MethodParameter parameter = new MethodParameter(customNamePrefixPageableAndSort, 0);
        NativeWebRequest webRequest = new ServletWebRequest(request);
        Pageable pageable = (Pageable) new PageableMethodArgumentResolver().resolveArgument(parameter, null, webRequest, null);

        //内部会自动-1,从0开始
        assertEquals(pn - 1, pageable.getPageNumber());
        assertEquals(pageSize, pageable.getPageSize());
        Sort expectedSort = new Sort(Sort.Direction.ASC, "baseInfo.realname").and(new Sort(Sort.Direction.DESC, "id"));
        assertEquals(expectedSort, pageable.getSort());
    }
View Full Code Here

        request.setParameter("foo_sort2.id$", "desc");
        request.setParameter("foo_sort1.baseInfo.realname", "asc");

        MethodParameter parameter = new MethodParameter(customNamePrefixPageableAndSort, 0);
        NativeWebRequest webRequest = new ServletWebRequest(request);
        Pageable pageable = (Pageable) new PageableMethodArgumentResolver().resolveArgument(parameter, null, webRequest, null);

    }
View Full Code Here

   */
  @Override
  public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
      NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

    Pageable pageable = resolver.resolveArgument(parameter, mavContainer, webRequest, binderFactory);
    return new DefaultedPageable(pageable, resolver.isFallbackPageable(pageable));
  }
View Full Code Here

    createPerfTest("new Test2", Status.FINISHED, new Date());

    PerfTest candidate = testService.getNextRunnablePerfTestPerfTestCandidate();
    assertThat(candidate, nullValue());

    Pageable pageable = new PageRequest(0, 10);
    Page<PerfTest> testList = testService.getPagedAll(getTestUser(), null, null, null, pageable);
    assertThat(testList.getContent().size(), is(2));
    testList = testService.getPagedAll(getTestUser(), null, null, "F", pageable);
    assertThat(testList.getContent().size(), is(1));
View Full Code Here

    createPerfTest(strangeName, Status.READY, new Date());

    ModelMap model = new ModelMap();

    Sort sort = new Sort("testName");
    Pageable pageable = new PageRequest(0, 10, sort);
    controller.getAll(getTestUser(), strangeName, null, null, pageable, model);
    Page<PerfTest> testPage = (Page<PerfTest>) model.get("testListPage");
    List<PerfTest> testList = testPage.getContent();
    assertThat(testList.size(), is(1));
View Full Code Here

        ArgumentCaptor<Pageable> pageArgument = ArgumentCaptor.forClass(Pageable.class);
        verify(personRepositoryMock, times(1)).findAll(any(Specification.class), pageArgument.capture());
        verifyNoMoreInteractions(personRepositoryMock);

        Pageable pageSpecification = pageArgument.getValue();

        assertEquals(PAGE_INDEX, pageSpecification.getPageNumber());
        assertEquals(RepositoryPersonService.NUMBER_OF_PERSONS_PER_PAGE, pageSpecification.getPageSize());
        assertEquals(Sort.Direction.ASC, pageSpecification.getSort().getOrderFor("lastName").getDirection());
       
        assertEquals(expected, actual);
    }
View Full Code Here

        List<Post> posts = new ArrayList<>();
        post = PostBuilder.post().title("post title").build();
        posts.add(post);
        Page<Post> postsPage = new PageImpl<>(posts, new PageRequest(TEST_PAGE, 10), 20);
        Pageable testPageable = PageableFactory.forLists(TEST_PAGE);

        page = new PageImpl<>(new ArrayList<>(), testPageable, 1);

        given(blogService.getPublishedBroadcastPosts(eq(testPageable))).willReturn(postsPage);
        request.setServletPath("/blog");
View Full Code Here

        controller = new BlogController(blogService, dateFactory);

        List<Post> posts = new ArrayList<>();
        posts.add(PostBuilder.post().title("post title").build());
        Page<Post> postsPage = new PageImpl<>(posts, new PageRequest(TEST_PAGE, 10), 20);
        Pageable testPageable = PageableFactory.forLists(TEST_PAGE);

        page = new PageImpl<>(new ArrayList<>(), testPageable, 1);

        given(blogService.getPublishedPosts(eq(testPageable))).willReturn(postsPage);
        request.setServletPath("/blog");
View Full Code Here

        JsonParser jsonParser = new JsonParser();
        searchResultParser = new SearchResultParser();
        JestResult jestResult = new JestResult();
        jestResult.setJsonObject(jsonParser.parse(RESULT_STRING).getAsJsonObject());

        Pageable pageable = new PageRequest(3, 12);
        searchResults = searchResultParser.parseResults(jestResult, pageable, "search term");
        content = searchResults.getPage().getContent();
    }
View Full Code Here

TOP

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

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.