Package org.springframework.data.domain.Sort

Examples of org.springframework.data.domain.Sort.Order


    //given
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john3", SOME_DATE_OF_BIRTH, SOME_REPUTATION, true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john5", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 1, true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john4", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 1, true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john6", SOME_DATE_OF_BIRTH, SOME_REPUTATION - 1, true);
    final Sort sort = new Sort(new Order(DESC, "reputation"), new Order(ASC, "user_name"));

    //when
    final List<User> all = repository.findAll(sort);

    //then
View Full Code Here


    repository.save(new BoardingPass("BAR-100", 1, "Gordon", "D03"));

    //when
    final List<BoardingPass> all = repository.findAll(
        new Sort(
            new Order(ASC, "flight_no"),
            new Order(DESC, "seq_no")
        )
    );

    //then
    assertThat(all).containsExactly(
View Full Code Here

    //when
    final Page<BoardingPass> page = repository.findAll(
        new PageRequest(0, 3,
            new Sort(
                new Order(ASC, "flight_no"),
                new Order(DESC, "seq_no")
            )
        ));

    //then
    assertThat(page.getTotalElements()).isEqualTo(4);
View Full Code Here

    //when
    final Page<BoardingPass> page = repository.findAll(
        new PageRequest(1, 3,
            new Sort(
                new Order(ASC, "flight_no"),
                new Order(DESC, "seq_no")
            )
        ));

    //then
    assertThat(page.getContent()).containsExactly(new BoardingPass("FOO-100", 1, "Smith", "B01"));
View Full Code Here

  @Test
  public void returnsAllIgnoreCaseSortedCorrectly() throws Exception {

    flushTestUsers();

    Order order = new Order(ASC, "firstname").ignoreCase();
    List<User> result = repository.findAll(new Sort(order));

    assertThat(result, is(notNullValue()));
    assertThat(result.size(), is(4));
    assertThat(result.get(0), is(thirdUser));
View Full Code Here

   * @see DATAJPA-296
   */
  @Test
  public void appliesIgnoreCaseOrdering() {

    Sort sort = new Sort(new Order(Direction.DESC, "lastname").ignoreCase(), new Order(Direction.ASC, "firstname"));

    Page<User> result = repository.findAll(user.lastname.contains("e"), new PageRequest(0, 2, sort));

    assertThat(result.getContent(), hasSize(2));
    assertThat(result.getContent().get(0), is(dave));
View Full Code Here

  @Test
  public void findBySpecificationWithSortByOrderIgnoreCaseBySingularPropertyInPageableShouldUseSortNullValuesFirst() {

    QUser user = QUser.user;

    Page<User> page = repository.findAll(user.firstname.isNotNull(), new PageRequest(0, 10, new Sort(new Order(
        Sort.Direction.ASC, "firstname").ignoreCase())));

    assertThat(page.getContent(), hasSize(3));
    assertThat(page.getContent(), hasItems(carter, dave, oliver));
  }
View Full Code Here

  public void shouldBuildSpringDataSortFromSortColumnAndSortAscending() throws Exception {
    given(this.delegate.getSortColumn()).willReturn("column");
    given(this.delegate.isSortAscending()).willReturn(true);
    Sort sort = this.request.getSort();
    Iterator<Order> orderIterator = sort.iterator();
    Order order = orderIterator.next();
    assertThat("Sort should only conain a single item", orderIterator.hasNext(), is(false));
    assertThat(order.getDirection(), is(Sort.Direction.ASC));
    assertThat(order.getProperty(), is("column"));
  }
View Full Code Here

    if(user==null){
      throw new RuntimeException("Invalid user id : " + id);
    }
    Pageable pageable = new PageRequest(Math.max(no, 0),
        ApplicationConfig.masonryPageSize,
        new Sort(new Order(Direction.DESC, "updatedAt")));
    Page<FollowShip> fss = followShipRepository.findByTargetAndStatus(id, 0, pageable);
    pageable = new PageRequest(Math.max(no, 0),
        ApplicationConfig.masonryThumbPageSize,
        new Sort(new Order(Direction.DESC, "updatedAt")));
    List<PinUserVo> pins = new ArrayList<PinUserVo>();
    if(fss!=null){
      for(FollowShip fs : fss){
        if(fs.getFollowed()==null) continue;
        Page<Spot> spots = spotRepository.findByCreatedBy(fs.getFollowed().getId(), pageable);
View Full Code Here

    if(user==null){
      throw new RuntimeException("Invalid user id : " + id);
    }
    Pageable pageable = new PageRequest(Math.max(no, 0),
        ApplicationConfig.masonryPageSize,
        new Sort(new Order(Direction.DESC, "updatedAt")));
    Page<FollowShip> fss = followShipRepository.findByFollowedAndStatus(id, 0, pageable);
    pageable = new PageRequest(Math.max(no, 0),
        ApplicationConfig.masonryThumbPageSize,
        new Sort(new Order(Direction.DESC, "updatedAt")));
    List<PinUserVo> pins = new ArrayList<PinUserVo>();
    if(fss!=null){
      for(FollowShip fs : fss){
        if(fs.getFollowed()==null) continue;
        Page<Spot> spots = spotRepository.findByCreatedBy(fs.getTarget().getId(), pageable);
View Full Code Here

TOP

Related Classes of org.springframework.data.domain.Sort.Order

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.