Package org.springframework.data.domain

Examples of org.springframework.data.domain.Sort


  }

  @Test
  public void handlesCamelCasePropertyCorrecty() throws Exception {

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


  @Test
  public void handlesMultipleDirectionsCorrectly() throws Exception {

    OrderBySource orderBySource = new OrderBySource("LastnameAscUsernameDesc");
    assertThat(orderBySource.toSort(), is(new Sort(new Order(ASC, "lastname"), new Order(DESC, "username"))));
  }
View Full Code Here

  @Test
  public void usesNestedPropertyCorrectly() throws Exception {

    OrderBySource source = new OrderBySource("BarNameDesc", Foo.class);
    assertThat(source.toSort(), is(new Sort(new Order(DESC, "bar.name"))));

  }
View Full Code Here

  public ExpectedException exception = ExpectedException.none();

  @Test
  public void parsesSimpleSortStringCorrectly() {

    assertSortStringParsedInto(new Sort(new Order("username")), SORT_1);
    assertSortStringParsedInto(new Sort(new Order(ASC, "username")), SORT_1);
    assertSortStringParsedInto(new Sort(new Order(ASC, "username"), //
        new Order(DESC, "lastname"), new Order(DESC, "firstname")), SORT_2);
    assertSortStringParsedInto(new Sort("firstname", "lastname"), SORT_3);
  }
View Full Code Here

  }

  private static void assertSortStringParsedInto(Sort expected, String... source) {

    SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
    Sort sort = resolver.parseParameterIntoSort(source, ",");

    assertThat(sort, is(expected));
  }
View Full Code Here

    assertSupportedAndResolvedTo(getParameterOfMethod("supportedMethod"), null);
  }

  @Test
  public void discoversSimpleDefault() throws Exception {
    assertSupportedAndResolvedTo(getParameterOfMethod("simpleDefault"), new Sort(Direction.ASC, SORT_FIELDS));
  }
View Full Code Here

  @Test
  public void discoversContaineredDefault() throws Exception {

    MethodParameter parameter = getParameterOfMethod("containeredDefault");
    Sort reference = new Sort("foo", "bar");

    assertSupportedAndResolvedTo(parameter, reference);
  }
View Full Code Here

  public void ensureInteroperabilityWithSort() {

    QUser user = QUser.user;
    QSort qsort = new QSort(user.firstname.asc(), user.lastname.desc());

    Sort sort = qsort;

    assertThat(sort.getOrderFor("firstname"), is(new Sort.Order(Sort.Direction.ASC, "firstname")));
    assertThat(sort.getOrderFor("lastname"), is(new Sort.Order(Sort.Direction.DESC, "lastname")));
  }
View Full Code Here

  }

  @Test
  public void returnsSortIfAvailable() {

    Sort sort = new Sort("foo");
    ParameterAccessor accessor = new ParametersParameterAccessor(sortParameters, new Object[] { "test", sort });
    assertThat(accessor.getSort(), is(sort));
    assertThat(accessor.getPageable(), is(nullValue()));
  }
View Full Code Here

  public void concatenatesPlainSortCorrectly() {

    QUser user = QUser.user;
    QSort sort = new QSort(user.firstname.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, "firstname")));
  }
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.