Skip to content
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

Set default values for sort fields in PagingRequest #809

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/main/java/org/kiwiproject/spring/data/PagingRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class PagingRequest implements PagingParams {
*/
@QueryParam("primaryDirection")
@DefaultValue("ASC")
private Sort.Direction primaryDirection;
private Sort.Direction primaryDirection = Sort.Direction.ASC;

/**
* The secondary sort property. Default is null.
Expand All @@ -82,5 +82,5 @@ public class PagingRequest implements PagingParams {
*/
@QueryParam("secondaryDirection")
@DefaultValue("ASC")
private Sort.Direction secondaryDirection;
private Sort.Direction secondaryDirection = Sort.Direction.ASC;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ void shouldCreateInstanceWithExpectedDefaults(SoftAssertions softly) {
softly.assertThat(pagingRequest.getPage()).isZero();
softly.assertThat(pagingRequest.getLimit()).isEqualTo(100);
softly.assertThat(pagingRequest.getPrimarySort()).isNull();
softly.assertThat(pagingRequest.getPrimaryDirection()).isNull();
softly.assertThat(pagingRequest.getPrimaryDirection()).isEqualTo(Sort.Direction.ASC);
softly.assertThat(pagingRequest.getSecondarySort()).isNull();
softly.assertThat(pagingRequest.getSecondaryDirection()).isNull();
softly.assertThat(pagingRequest.getSecondaryDirection()).isEqualTo(Sort.Direction.ASC);
}

@Test
Expand Down