File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
main/java/org/springframework/data/domain
test/java/org/springframework/data/domain Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ public String toString() {
277277 */
278278 private Sort withDirection (Direction direction ) {
279279
280- return Sort .by (stream ().map (it -> new Order ( direction , it .getProperty () )).collect (Collectors .toList ()));
280+ return Sort .by (stream ().map (it -> it .with ( direction )).collect (Collectors .toList ()));
281281 }
282282
283283 /**
Original file line number Diff line number Diff line change @@ -104,9 +104,12 @@ void handlesAdditionalNullSort() {
104104 assertThat (sort ).containsExactly (Order .by ("foo" ));
105105 }
106106
107- @ Test // DATACMNS-281, DATACMNS-1021
107+ @ Test // DATACMNS-281, DATACMNS-1021, GH-2585
108108 void configuresIgnoreCaseForOrder () {
109+
109110 assertThat (Order .asc ("foo" ).ignoreCase ().isIgnoreCase ()).isTrue ();
111+ assertThat (Sort .by (Order .by ("foo" ).ignoreCase ()).descending ().iterator ().next ().isIgnoreCase ()).isTrue ();
112+ assertThat (Sort .by (Order .by ("foo" ).ignoreCase ()).ascending ().iterator ().next ().isIgnoreCase ()).isTrue ();
110113 }
111114
112115 @ Test // DATACMNS-281, DATACMNS-1021
@@ -154,6 +157,15 @@ void orderWithDefaultNullHandlingHint() {
154157 assertThat (Order .by ("foo" ).getNullHandling ()).isEqualTo (NATIVE );
155158 }
156159
160+ @ Test // GH-2585
161+ void retainsNullHandlingAfterChangingDirection () {
162+
163+ assertThat (Sort .by (Order .by ("foo" ).with (NULLS_FIRST )).ascending ().iterator ().next ().getNullHandling ())
164+ .isEqualTo (NULLS_FIRST );
165+ assertThat (Sort .by (Order .by ("foo" ).with (NULLS_FIRST )).descending ().iterator ().next ().getNullHandling ())
166+ .isEqualTo (NULLS_FIRST );
167+ }
168+
157169 @ Test // DATACMNS-908
158170 void createsNewOrderForDifferentProperty () {
159171
You can’t perform that action at this time.
0 commit comments