Retain case-sensitivity and null-handling when changing Sort direction.

We now retain case-sensitivity and null-handling configuration when changing the entire Sort direction.

Closes #2585
This commit is contained in:
Mark Paluch
2022-03-25 13:35:49 +01:00
parent 83a1e74945
commit ef5defe405
2 changed files with 14 additions and 2 deletions

View File

@@ -104,9 +104,12 @@ class SortUnitTests {
assertThat(sort).containsExactly(Order.by("foo"));
}
@Test // DATACMNS-281, DATACMNS-1021
@Test // DATACMNS-281, DATACMNS-1021, GH-2585
void configuresIgnoreCaseForOrder() {
assertThat(Order.asc("foo").ignoreCase().isIgnoreCase()).isTrue();
assertThat(Sort.by(Order.by("foo").ignoreCase()).descending().iterator().next().isIgnoreCase()).isTrue();
assertThat(Sort.by(Order.by("foo").ignoreCase()).ascending().iterator().next().isIgnoreCase()).isTrue();
}
@Test // DATACMNS-281, DATACMNS-1021
@@ -154,6 +157,15 @@ class SortUnitTests {
assertThat(Order.by("foo").getNullHandling()).isEqualTo(NATIVE);
}
@Test // GH-2585
void retainsNullHandlingAfterChangingDirection() {
assertThat(Sort.by(Order.by("foo").with(NULLS_FIRST)).ascending().iterator().next().getNullHandling())
.isEqualTo(NULLS_FIRST);
assertThat(Sort.by(Order.by("foo").with(NULLS_FIRST)).descending().iterator().next().getNullHandling())
.isEqualTo(NULLS_FIRST);
}
@Test // DATACMNS-908
void createsNewOrderForDifferentProperty() {