Skip to content

DATACMNS-366 - SortHandlerMethodArgumentResolver should be able to deal ... #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
*/
public class SortHandlerMethodArgumentResolverUnitTests extends SortDefaultUnitTests {

static final String SORT_0 = "username";
static final String SORT_1 = "username,asc";
static final String[] SORT_2 = new String[] { "username,ASC", "lastname,firstname,DESC" };
static final String SORT_3 = "firstname,lastname";

/**
* @see DATACMNS-351
*/
Expand Down Expand Up @@ -114,6 +109,23 @@ public void returnsNullForSortParameterSetToNothing() throws Exception {
assertThat(result, is(nullValue()));
}

/**
* @see DATACMNS-366
* @throws Exception
*/
@Test
public void requestForMultipleSortPropertiesIsUnmarshalledCorrectly() throws Exception {

MethodParameter parameter = getParameterOfMethod("supportedMethod");

MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("sort", SORT_3);

SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
Sort result = resolver.resolveArgument(parameter, null, new ServletWebRequest(request), null);
assertThat(result, is(new Sort(Direction.ASC, "firstname", "lastname")));
}

private static void assertSupportedAndResolvedTo(NativeWebRequest request, MethodParameter parameter, Sort sort) {

SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
Expand Down