Package org.springframework.data.domain

Examples of org.springframework.data.domain.Sort


  }

  @Test
  public void hasSortIfOrderByIsGiven() throws Exception {
    PartTree partTree = partTree("firstnameOrderByLastnameDesc");
    assertThat(partTree.getSort(), is(new Sort(Direction.DESC, "lastname")));
  }
View Full Code Here


    hasSortIfOrderByIsGivenWithAllIgnoreCase("firstnameAllIgnoreCaseOrderByLastnameDesc");
  }

  private void hasSortIfOrderByIsGivenWithAllIgnoreCase(String source) throws Exception {
    PartTree partTree = partTree(source);
    assertThat(partTree.getSort(), is(new Sort(Direction.DESC, "lastname")));
  }
View Full Code Here

      detectsDistinctCorrectly(prefix + "UsersByLastname", false);
      detectsDistinctCorrectly(prefix + "ByLastname", false);
      // Check it's non-greedy (would strip everything until Order*By*
      // otherwise)
      PartTree tree = detectsDistinctCorrectly(prefix + "ByLastnameOrderByFirstnameDesc", false);
      assertThat(tree.getSort(), is(new Sort(Direction.DESC, "firstname")));
    }
  }
View Full Code Here

  public void buildsPartTreeFromEmptyPredicateCorrectly() {

    PartTree tree = new PartTree("findAllByOrderByLastnameAsc", User.class);

    assertThat(tree.getParts(), is(emptyIterable()));
    assertThat(tree.getSort(), is(new Sort(Direction.ASC, "lastname")));
  }
View Full Code Here

  @Test
  public void buildsUpRequestParameters() throws Exception {

    assertUriStringFor(SORT, "sort=firstname,lastname,desc");
    assertUriStringFor(new Sort(ASC, "foo").and(new Sort(DESC, "bar").and(new Sort(ASC, "foobar"))),
        "sort=foo,asc&sort=bar,desc&sort=foobar,asc");
    assertUriStringFor(new Sort(ASC, "foo").and(new Sort(ASC, "bar").and(new Sort(DESC, "foobar"))),
        "sort=foo,bar,asc&sort=foobar,desc");
  }
View Full Code Here

public class OrderBySourceUnitTests {

  @Test
  public void handlesSingleDirectionAndPropertyCorrectly() throws Exception {

    assertThat(new OrderBySource("UsernameDesc").toSort(), is(new Sort(DESC, "username")));
  }
View Full Code Here

   *
   * @return
   */
  public T createQuery() {

    Sort dynamicSort = parameters != null ? parameters.getSort() : null;
    return createQuery(dynamicSort);
  }
View Full Code Here

   * @param dynamicSort
   * @return
   */
  public T createQuery(Sort dynamicSort) {

    Sort staticSort = tree.getSort();
    Sort sort = staticSort != null ? staticSort.and(dynamicSort) : dynamicSort;

    return complete(createCriteria(tree), sort);
  }
View Full Code Here

   */
  @Test
  public void exposesPageableParameter() throws Exception {

    this.method = SampleRepo.class.getMethod("findByFirstname", String.class, Pageable.class);
    PageRequest pageable = new PageRequest(2, 3, new Sort(Direction.DESC, "lastname"));

    assertThat(evaluateExpression("#pageable.offset", new Object[] { "test", pageable }), is((Object) 6));
    assertThat(evaluateExpression("#pageable.pageSize", new Object[] { "test", pageable }), is((Object) 3));
    assertThat(evaluateExpression("#pageable.sort.toString()", new Object[] { "test", pageable }),
        is((Object) "lastname: DESC"));
View Full Code Here

   */
  @Test
  public void exposesSortParameter() throws Exception {

    this.method = SampleRepo.class.getMethod("findByFirstname", String.class, Sort.class);
    Sort sort = new Sort(Direction.DESC, "lastname");

    assertThat(evaluateExpression("#sort.toString()", new Object[] { "test", sort }), is((Object) "lastname: DESC"));
  }
View Full Code Here

TOP

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

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.