Package org.springframework.data.domain.Sort

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


    QUser user = QUser.user;
    QSort sort = new QSort(user.dateOfBirth.yearMonth().asc());

    Sort result = sort.and(new Sort(Direction.ASC, "lastname"));
    assertThat(result, is(Matchers.<Order> iterableWithSize(2)));
    assertThat(result, hasItems(new Order(Direction.ASC, "lastname"), new Order(Direction.ASC, user.dateOfBirth.yearMonth().toString())));
  }
View Full Code Here


  /**
   * @see DATACMNS-491
   */
  @Test
  public void orderWithNullHandlingHintNullsFirst() {
    assertThat(new Order("foo").nullsFirst().getNullHandling(), is(NULLS_FIRST));
  }
View Full Code Here

  /**
   * @see DATACMNS-491
   */
  @Test
  public void orderWithNullHandlingHintNullsLast() {
    assertThat(new Order("foo").nullsLast().getNullHandling(), is(NULLS_LAST));
  }
View Full Code Here

  /**
   * @see DATACMNS-491
   */
  @Test
  public void orderWithNullHandlingHintNullsNative() {
    assertThat(new Order("foo").nullsNative().getNullHandling(), is(NATIVE));
  }
View Full Code Here

  /**
   * @see DATACMNS-491
   */
  @Test
  public void orderWithDefaultNullHandlingHint() {
    assertThat(new Order("foo").getNullHandling(), is(NATIVE));
  }
View Full Code Here

  public void shouldReturnPageWithOneItemWithSortingAppliedOnTwoProperties() {
    //given
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john6", SOME_DATE_OF_BIRTH, SOME_REPUTATION, true);

    //when
    Page<User> page = repository.findAll(new PageRequest(0, 5, new Sort(new Order(DESC, "reputation"), new Order(ASC, "user_name"))));

    //then
    assertThat(page).hasSize(1);
    assertThat(page.getTotalElements()).isEqualTo(1);
    assertThat(page.getSize()).isEqualTo(5);
View Full Code Here

    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john13", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 2, true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john14", SOME_DATE_OF_BIRTH, SOME_REPUTATION    , true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john15", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 1, true);

    //when
    Page<User> page = repository.findAll(new PageRequest(0, 3, new Sort(new Order(DESC, "reputation"), new Order(ASC, "user_name"))));

    //then
    assertThat(page).hasSize(3);
    assertThat(page.getTotalElements()).isEqualTo(5);
    assertThat(page.getSize()).isEqualTo(3);
View Full Code Here

    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john13", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 2, true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john14", SOME_DATE_OF_BIRTH, SOME_REPUTATION    , true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john15", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 1, true);

    //when
    Page<User> page = repository.findAll(new PageRequest(1, 3, new Sort(new Order(DESC, "reputation"), new Order(ASC, "user_name"))));

    //then
    assertThat(page).hasSize(2);
    assertThat(page.getTotalElements()).isEqualTo(5);
    assertThat(page.getSize()).isEqualTo(3);
View Full Code Here

  }

  @Test
  public void shouldReturnEmptyListWhenFindAllCalledWithoutPagingButWithSortingOnMultipleProperties() throws Exception {
    //given
    final Sort sort = new Sort(new Order(DESC, "reputation"), new Order(ASC, "date_of_birth"));

    //when
    final Iterable<User> reputation = repository.findAll(sort);

    //then
View Full Code Here

  @Test
  public void shouldReturnSingleRecordWhenFindAllWithoutPagingButWithSorting() throws Exception {
    //given
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john7", SOME_DATE_OF_BIRTH, SOME_REPUTATION, true);
    final Sort sort = new Sort(new Order(DESC, "reputation"), new Order(ASC, "date_of_birth"));

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

    //then
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.