Skip to content

Commit 4d974f1

Browse files
Thomas Darimontodrotbohm
Thomas Darimont
authored andcommitted
DATACMNS-366 - Test for SortHandlerMethodArgumentResolver and property lists.
Added test case to show SortHandlerMethodArgumentResolver can deal with property lists. Original pull request: #45.
1 parent 93899f7 commit 4d974f1

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/test/java/org/springframework/data/web/SortHandlerMethodArgumentResolverUnitTests.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@
4040
*/
4141
public class SortHandlerMethodArgumentResolverUnitTests extends SortDefaultUnitTests {
4242

43-
static final String SORT_0 = "username";
44-
static final String SORT_1 = "username,asc";
45-
static final String[] SORT_2 = new String[] { "username,ASC", "lastname,firstname,DESC" };
46-
static final String SORT_3 = "firstname,lastname";
47-
4843
/**
4944
* @see DATACMNS-351
5045
*/
@@ -114,6 +109,23 @@ public void returnsNullForSortParameterSetToNothing() throws Exception {
114109
assertThat(result, is(nullValue()));
115110
}
116111

112+
/**
113+
* @see DATACMNS-366
114+
* @throws Exception
115+
*/
116+
@Test
117+
public void requestForMultipleSortPropertiesIsUnmarshalledCorrectly() throws Exception {
118+
119+
MethodParameter parameter = getParameterOfMethod("supportedMethod");
120+
121+
MockHttpServletRequest request = new MockHttpServletRequest();
122+
request.addParameter("sort", SORT_3);
123+
124+
SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
125+
Sort result = resolver.resolveArgument(parameter, null, new ServletWebRequest(request), null);
126+
assertThat(result, is(new Sort(Direction.ASC, "firstname", "lastname")));
127+
}
128+
117129
private static void assertSupportedAndResolvedTo(NativeWebRequest request, MethodParameter parameter, Sort sort) {
118130

119131
SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();

0 commit comments

Comments
 (0)