DATACMNS-1021 - Add Order.asc(…) and Order.desc(…) factory methods.
We now support Order creation with Order.asc(String) and Order.desc(String) factory methods as shortcut to constructor creation via new Order(Direction, String).
Sort.by(Order.asc("age"), Order.desc("name"));
Deprecated Order(String) constructor in favor of the Order.by(String) factory method. Replace references to new Order(String) with Order.by(String).
Original pull request: #211.
This commit is contained in:
committed by
Oliver Gierke
parent
78374f3cb7
commit
14647f9192
@@ -28,6 +28,7 @@ import org.springframework.data.domain.Sort.Order;
|
||||
* @author Oliver Gierke
|
||||
* @author Kevin Raymond
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class SortUnitTests {
|
||||
|
||||
@@ -99,14 +100,24 @@ public class SortUnitTests {
|
||||
assertThat(sort).containsExactly(new Sort.Order("foo"));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-281
|
||||
@Test // DATACMNS-281, DATACMNS-1021
|
||||
public void configuresIgnoreCaseForOrder() {
|
||||
assertThat(new Order(Direction.ASC, "foo").ignoreCase().isIgnoreCase()).isTrue();
|
||||
assertThat(Order.asc("foo").ignoreCase().isIgnoreCase()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-281
|
||||
@Test // DATACMNS-281, DATACMNS-1021
|
||||
public void orderDoesNotIgnoreCaseByDefault() {
|
||||
|
||||
assertThat(new Order(Direction.ASC, "foo").isIgnoreCase()).isFalse();
|
||||
assertThat(Order.asc("foo").isIgnoreCase()).isFalse();
|
||||
assertThat(Order.desc("foo").isIgnoreCase()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1021
|
||||
public void createsOrderWithDirection() {
|
||||
|
||||
assertThat(Order.asc("foo").getDirection()).isEqualTo(Direction.ASC);
|
||||
assertThat(Order.desc("foo").getDirection()).isEqualTo(Direction.DESC);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-436
|
||||
|
||||
Reference in New Issue
Block a user