1
1
/*
2
- * Copyright 2013-2014 the original author or authors.
2
+ * Copyright 2013-2015 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
15
15
*/
16
16
package org .springframework .data .querydsl ;
17
17
18
- import static org .hamcrest .Matchers .hasItems ;
19
- import static org .hamcrest .Matchers .is ;
20
- import static org .junit .Assert .assertThat ;
18
+ import static org .hamcrest .Matchers .*;
19
+ import static org .junit .Assert .*;
21
20
22
21
import java .util .List ;
23
22
34
33
*
35
34
* @author Thomas Darimont
36
35
* @author Oliver Gierke
36
+ * @author Christoph Strobl
37
37
*/
38
38
public class QSortUnitTests {
39
39
@@ -147,7 +147,7 @@ public void concatenatesPlainSortCorrectly() {
147
147
assertThat (result , is (Matchers .<Order > iterableWithSize (2 )));
148
148
assertThat (result , hasItems (new Order (Direction .ASC , "lastname" ), new Order (Direction .ASC , "firstname" )));
149
149
}
150
-
150
+
151
151
/**
152
152
* @see DATACMNS-566
153
153
*/
@@ -159,6 +159,44 @@ public void shouldSupportSortByOperatorExpressions() {
159
159
160
160
Sort result = sort .and (new Sort (Direction .ASC , "lastname" ));
161
161
assertThat (result , is (Matchers .<Order > iterableWithSize (2 )));
162
- assertThat (result , hasItems (new Order (Direction .ASC , "lastname" ), new Order (Direction .ASC , user .dateOfBirth .yearMonth ().toString ())));
162
+ assertThat (
163
+ result ,
164
+ hasItems (new Order (Direction .ASC , "lastname" ),
165
+ new Order (Direction .ASC , user .dateOfBirth .yearMonth ().toString ())));
166
+ }
167
+
168
+ /**
169
+ * @see DATACMNS-621
170
+ */
171
+ @ Test
172
+ public void shouldCreateSortForNestedPathCorrectly () {
173
+
174
+ QSort sort = new QSort (QUserWrapper .userWrapper .user .firstname .asc ());
175
+
176
+ assertThat (sort , hasItems (new Order (Direction .ASC , "user.firstname" )));
177
+ }
178
+
179
+ /**
180
+ * @see DATACMNS-621
181
+ */
182
+ @ Test
183
+ public void shouldCreateSortForDeepNestedPathCorrectly () {
184
+
185
+ QSort sort = new QSort (QWrapperForUserWrapper .wrapperForUserWrapper .wrapper .user .firstname .asc ());
186
+
187
+ assertThat (sort , hasItems (new Order (Direction .ASC , "wrapper.user.firstname" )));
188
+ }
189
+
190
+ /**
191
+ * @see DATACMNS-621
192
+ */
193
+ @ Test
194
+ public void shouldCreateSortForReallyDeepNestedPathCorrectly () {
195
+
196
+ QSort sort = new QSort (
197
+ QWrapperToWrapWrapperForUserWrapper .wrapperToWrapWrapperForUserWrapper .wrapperForUserWrapper .wrapper .user .firstname
198
+ .asc ());
199
+
200
+ assertThat (sort , hasItems (new Order (Direction .ASC , "wrapperForUserWrapper.wrapper.user.firstname" )));
163
201
}
164
202
}
0 commit comments