Package org.springframework.data.domain

Examples of org.springframework.data.domain.Pageable


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

        Pageable pageable = new PageRequest(1, 10);
        searchResults = searchResultParser.parseResults(jestResult, pageable, "search term");
    }
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(TEST_CATEGORY), eq(testPageable))).willReturn(postsPage);
View Full Code Here

        this.searchService = searchService;
    }

    @RequestMapping(method = { GET, HEAD, POST })
    public String search(SearchForm searchForm, @RequestParam(defaultValue = "1") int page, Model model) {
        Pageable pageable = PageableFactory.forSearch(page);
        SearchResults searchResults = searchService.search(searchForm.getQ(), pageable, searchForm.getFilters());
        Page<SearchResult> entries = searchResults.getPage();
        model.addAttribute("totalResultsCount", entries.getTotalElements());
        model.addAttribute("results", entries.getContent());
        model.addAttribute("paginationInfo", new PaginationInfo(entries));
View Full Code Here

        searchService.saveToIndex(entry1);

        SearchEntry entry2 = builder.path("item2").title("Item 2").build();
        searchService.saveToIndex(entry2);

        Pageable page1 = new PageRequest(0, 1);
        Page<SearchResult> searchEntries1 =
                searchService.search("content", page1, Collections.<String> emptyList()).getPage();
        assertThat(searchEntries1.getContent().get(0).getId(), equalTo(entry1.getId()));

        Pageable page2 = new PageRequest(1, 1);
        Page<SearchResult> searchEntries2 =
                searchService.search("content", page2, Collections.<String> emptyList()).getPage();
        assertThat(searchEntries2.getContent().get(0).getId(), equalTo(entry2.getId()));
    }
View Full Code Here

            SearchEntry entry = builder.path("item" + i).title("Item " + i).build();
            searchService.saveToIndex(entry);
        }

        int page = 1;
        Pageable pageable = new PageRequest(page, 10);
        Page<SearchResult> searchEntries =
                searchService.search("", pageable, Collections.<String> emptyList()).getPage();
        assertThat(searchEntries.getContent().size(), equalTo(10));
        assertThat(searchEntries.getTotalPages(), equalTo(3));
        assertThat(searchEntries.getNumber(), equalTo(page));
View Full Code Here

    }

    @Test
    public void searchThatReturnsNoResultsIsEmpty() throws ParseException {
        indexSingleEntry();
        Pageable page = new PageRequest(0, 10);
        Page<SearchResult> searchEntries = searchService.search(
                "somethingthatwillneverappearsupercalifragilousIcantspelltherest", page,
                Collections.<String> emptyList()).getPage();
        assertThat(searchEntries.getContent().size(), equalTo(0));
        assertThat(searchEntries.getTotalPages(), equalTo(0));
View Full Code Here

        return "blog/show";
    }

    @RequestMapping(value = "", method = { GET, HEAD })
    public String listPublishedPosts(Model model, @RequestParam(defaultValue = "1") int page) {
        Pageable pageRequest = PageableFactory.forLists(page);
        Page<Post> result = service.getPublishedPosts(pageRequest);
        return renderListOfPosts(result, model, "All Posts");
    }
View Full Code Here

    }

    @RequestMapping(value = "/category/{category}", method = { GET, HEAD })
    public String listPublishedPostsForCategory(@PathVariable("category") PostCategory category, Model model,
                                                @RequestParam(defaultValue = "1", value = "page") int page) {
        Pageable pageRequest = PageableFactory.forLists(page);
        Page<Post> result = service.getPublishedPosts(category, pageRequest);
        return renderListOfPosts(result, model, category.getDisplayName());
    }
View Full Code Here

        return renderListOfPosts(result, model, category.getDisplayName());
    }

    @RequestMapping(value = "/broadcasts", method = { GET, HEAD })
    public String listPublishedBroadcasts(Model model, @RequestParam(defaultValue = "1", value = "page") int page) {
        Pageable pageRequest = PageableFactory.forLists(page);
        Page<Post> result = service.getPublishedBroadcastPosts(pageRequest);
        return renderListOfPosts(result, model, "Broadcasts");
    }
View Full Code Here

    @RequestMapping(value = "/{year:\\d+}/{month:\\d+}/{day:\\d+}", method = { GET, HEAD })
    public String listPublishedPostsForDate(@PathVariable int year, @PathVariable int month, @PathVariable int day,
                                            @RequestParam(defaultValue = "1", value = "page") int page, Model model) {

        Pageable pageRequest = PageableFactory.forLists(page);
        Page<Post> result = service.getPublishedPostsByDate(year, month, day, pageRequest);

        LocalDate date = new LocalDate(year, month, day);
        model.addAttribute("title", "Archive for " + date.toString("MMMM dd, yyyy"));
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.