List of usage examples for org.springframework.data.domain Pageable getPageNumber
int getPageNumber();
From source file:com.trenako.web.controllers.admin.AdminRailwaysControllerMappingTests.java
@Test public void shouldShowTheFirstPageOfRailwaysByDefault() throws Exception { ArgumentCaptor<Pageable> arg = ArgumentCaptor.forClass(Pageable.class); mockMvc().perform(get("/admin/railways")).andExpect(status().isOk()); verify(mockService, times(1)).findAll(arg.capture()); Pageable p = arg.getValue(); assertEquals(0, p.getPageNumber()); assertEquals(10, p.getPageSize());//from w w w .ja v a2s. c om }
From source file:com.ushahidi.swiftriver.core.solr.repository.DropDocumentRepositoryImpl.java
private SolrQuery getPreparedSolrQuery(String searchTerm, Pageable pageable) { // Calculate the start row Integer start = pageable.getPageNumber() * pageable.getPageSize(); SolrQuery solrQuery = new SolrQuery(); solrQuery.set("q", searchTerm); solrQuery.set("defType", "edismax"); solrQuery.set("stopwords", true); solrQuery.set("lowercaseOperators", true); solrQuery.setStart(start);/*from w w w . ja va 2 s . c o m*/ solrQuery.setRows(pageable.getPageSize()); return solrQuery; }
From source file:io.curly.advisor.command.ReviewHystrixCommands.java
private Page<Review> defaultFindAllByOwner(User user, Pageable pageable) { log.warn("User {} requested all its reviews but we fell back, current page is {}", user, pageable.getPageNumber()); return new PageImpl<>(Collections.<Review>emptyList(), pageable, 0); }
From source file:io.curly.artifact.service.DefaultArtifactService.java
@Loggable @Override// w w w .ja v a 2 s . c o m @Cacheable("artifacts") public Page<Artifact> findAll(Pageable pageable) { Assert.notNull(pageable, "Page information must be not null!"); log.debug("Finding for page {}", pageable.getPageNumber()); return repository.findAll(pageable); }
From source file:com.trenako.web.controllers.admin.AdminBrandsControllerMappingTests.java
@Test public void shouldProcessBrandsPagingParameters() throws Exception { ArgumentCaptor<Pageable> arg = ArgumentCaptor.forClass(Pageable.class); mockMvc().perform(get("/admin/brands").param("page.page", "2").param("page.size", "25") .param("page.sort", "name").param("page.sort.dir", "desc")).andExpect(status().isOk()); verify(mockService, times(1)).findAll(arg.capture()); Pageable p = arg.getValue(); assertEquals(1, p.getPageNumber()); assertEquals(25, p.getPageSize());/* www . j av a 2 s . c o m*/ assertNotNull("Sort is null", p.getSort().getOrderFor("name")); assertEquals(Sort.Direction.DESC, p.getSort().getOrderFor("name").getDirection()); }
From source file:com.trenako.web.controllers.admin.AdminRailwaysControllerMappingTests.java
@Test public void shouldProcessRailwaysPagingParameters() throws Exception { ArgumentCaptor<Pageable> arg = ArgumentCaptor.forClass(Pageable.class); mockMvc().perform(get("/admin/railways").param("page.page", "2").param("page.size", "25") .param("page.sort", "name").param("page.sort.dir", "desc")).andExpect(status().isOk()); verify(mockService, times(1)).findAll(arg.capture()); Pageable p = arg.getValue(); assertEquals(1, p.getPageNumber()); assertEquals(25, p.getPageSize());//from w w w. j a v a 2 s. c o m assertNotNull("Sort is null", p.getSort().getOrderFor("name")); assertEquals(Sort.Direction.DESC, p.getSort().getOrderFor("name").getDirection()); }
From source file:com.epam.ta.reportportal.ws.resolver.PagingHandlerMethodArgumentResolver.java
@Override public Pageable resolveArgument(MethodParameter methodParameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { Pageable pageable = super.resolveArgument(methodParameter, mavContainer, webRequest, binderFactory); if (0 == pageable.getPageSize()) { return new PageRequest(pageable.getPageNumber(), DEFAULT_PAGE_SIZE, pageable.getSort()); } else if (MAX_PAGE_SIZE < pageable.getPageSize()) { return new PageRequest(pageable.getPageNumber(), MAX_PAGE_SIZE, pageable.getSort()); }/*from ww w. jav a 2 s . c o m*/ return pageable; }
From source file:io.curly.artifact.service.DefaultArtifactCommand.java
@Loggable @SuppressWarnings("unused") @HystrixCommand/*from w w w. j ava 2 s .c o m*/ private Optional<Page<Artifact>> defaultFindAllOwned(Pageable pageable, User user) { log.warn("Default find all owned triggered for user {} on page {}", user.getId(), pageable.getPageNumber()); return Optional.of(new PageImpl<>(Collections.emptyList())); }
From source file:com.frank.search.solr.core.query.SolrPageRequest.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }/* ww w .j a v a2s .c om*/ if (obj == null || !(obj instanceof Pageable)) { return false; } Pageable other = (Pageable) obj; if (page != other.getPageNumber()) { return false; } if (size != other.getPageSize()) { return false; } if (sort == null) { if (other.getSort() != null) { return false; } } else if (!sort.equals(other.getSort())) { return false; } return true; }
From source file:com.searchbox.framework.web.admin.AdminController.java
@ModelAttribute("users") public List<UserEntity> getUsers(@Qualifier("userTable") Pageable page, ModelAndView model) { model.addObject("userTable", page); model.addObject("userCount", userService.countAll()); LOGGER.info("Getting page {} of user", page.getPageNumber()); return userService.findAll(page); }