Package org.springframework.data.domain

Examples of org.springframework.data.domain.PageRequest


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

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


    WebApplicationContext context = WebTestUtils.createApplicationContext(Config.class);
    SampleController controller = context.getBean(SampleController.class);

    assertThat(controller.assembler, is(notNullValue()));

    PagedResources<Resource<Person>> resources = controller.sample(new PageRequest(1, 1));

    assertThat(resources.getLink(Link.REL_PREVIOUS), is(notNullValue()));
    assertThat(resources.getLink(Link.REL_NEXT), is(notNullValue()));
    assertThat(resources.getLink(Link.REL_SELF), is(notNullValue()));
  }
View Full Code Here

  @Test
  public void createsRepositoryInstanceWithCustomIntermediateRepository() {

    CustomRepository repository = factory.getRepository(CustomRepository.class);
    Pageable pageable = new PageRequest(0, 10);
    repository.findAll(pageable);

    verify(backingRepo, times(1)).findAll(pageable);
  }
View Full Code Here

        PropertyFilters.get("EQI_state", "1")
    )),new Sort(Direction.DESC, "loginName","realName"));
    Assert.assertEquals(userList.size(), 5);
   
   
    Pageable pageable = new PageRequest(1, 2);
    Page<User> page = userRepository.findAll(Specifications.get(Lists.newArrayList(PropertyFilters.get("EQI_state", "1"))),pageable);
    Assert.assertEquals(page.getContent().size(), 2);
    Assert.assertEquals(page.getTotalPages(), 4);
    Assert.assertEquals(page.getTotalElements(), 8);
  }
View Full Code Here

        for (int i = 0; i < 35; i++) {
            createProfessional(firstName, lastName, companyName, ADDR);
        }
       
        Page<Person> pageResult = personRepository.findByAddress(ADDR, new PageRequest(page, size));
        List<Person> persons = pageResult.getContent();
       
        int expectedCount = size;
       
        assertNotNull("Person list is null.", persons);
        assertEquals("Number of persons should be " + expectedCount + ".", expectedCount, persons.size());

        // query last page
        page = pageResult.getTotalPages() - 1;
        pageResult = personRepository.findByAddress(ADDR, new PageRequest(page, size));
        persons = pageResult.getContent();
       
        // created 35 records with the same address, one existing
        expectedCount = 6;
       
View Full Code Here

        for (int i = 0; i < 35; i++) {
            createProfessional(firstName, lastName, companyName, ADDR);
        }
       
        Page<Person> pageResult = personRepository.findByAddress(ADDR, new PageRequest(page, size));
        List<Person> persons = pageResult.getContent();
       
        int expectedCount = size;
       
        assertNotNull("Person list is null.", persons);
        assertEquals("Number of persons should be " + expectedCount + ".", expectedCount, persons.size());

        // query last page
        page = pageResult.getTotalPages() - 1;
        pageResult = personRepository.findByAddress(ADDR, new PageRequest(page, size));
        persons = pageResult.getContent();
       
        // created 35 records with the same address, one existing
        expectedCount = 6;
       
View Full Code Here

        return createFindResponse(results);
    }

    @Override
    public FR find(int page, int pageSize) {
        Page<T> pageResults = repository.findAll(new PageRequest(page, pageSize, createDefaultSort()));

        List<V> results = converter.convertListTo(pageResults.getContent());

        return createFindResponse(results, pageResults.getTotalElements());
    }
View Full Code Here

   
    System.out.println("App context initialized successfully");
   
    EntryService entryService = ctx.getBean("entryService", EntryService.class);
   
    PageRequest pageRequest = new PageRequest(0, 10);

    String subject = "%";
    String categoryId = "Spring";
    DateTime fromPostDate = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime("1900-01-01");
    DateTime toPostDate = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime("2011-12-18");
View Full Code Here

        sort = new Sort(Sort.Direction.ASC, orderBy);
    }
   
    // Constructs page request for current page
    // Note: page number for Spring Data JPA starts with 0, while jqGrid starts with 1
    PageRequest pageRequest = null;
   
    if (sort != null) {
      pageRequest = new PageRequest(page - 1, rows, sort);
    } else {
      pageRequest = new PageRequest(page - 1, rows);
    }
       
    //Page<Entry> entryPage = entryService.findAllByPage(pageRequest);
    Page<Entry> entryPage = entryService.findEntryByCriteria(searchCriteria, pageRequest);
   
View Full Code Here

  @Test
  public void shouldReturnEmptyPageWhenNoEntitiesInDatabase() {
    //given

    //when
    Page<User> firstPage = repository.findAll(new PageRequest(0, 20));

    //then
    assertThat(firstPage).isEmpty();
    assertThat(firstPage.getTotalElements()).isZero();
    assertThat(firstPage.getSize()).isEqualTo(20);
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.