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
Encode Pageable.Sort with percent encoded comma. Fixes gh-440. #467
Conversation
@KENNYSOFT Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@KENNYSOFT Thank you for signing the Contributor License Agreement! |
Codecov Report
@@ Coverage Diff @@
## master #467 +/- ##
=========================================
Coverage 76.91% 76.91%
Complexity 438 438
=========================================
Files 54 54
Lines 1633 1633
Branches 242 242
=========================================
Hits 1256 1256
Misses 256 256
Partials 121 121
|
Fixes gh-440. |
assertThat(pageable.getPageSize()).isEqualTo(response.getBody().getSize()); | ||
assertThat(response.getBody().getPageable().getSort()).hasSize(2); | ||
List<Sort.Order> orderList = response.getBody().getPageable().getSort().toList(); | ||
if (!orderList.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd replace if
with assert, something like
assertThat(orderList).hasSize(2);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 86785dc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's rebased, now in c08b873
assertThat(pageable.getPageSize()).isEqualTo(response.getBody().getSize()); | ||
assertThat(response.getBody().getPageable().getSort()).hasSize(1); | ||
Optional<Sort.Order> optionalOrder = response.getBody().getPageable().getSort().get().findFirst(); | ||
if (optionalOrder.isPresent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd replace if with assert, something like
assertThat(optionalOrder.isPresent()).isTrue();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it's guaranteed because we asserted that ...getSort()
has size 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But yeah changed. 86785dc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's rebased, now in c08b873
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KENNYSOFT Other than some minor formatting issues, the PR looks good. However, similarly as with the previous one, please submit it against 2.2.x
so that the changes are included in the Hoxton
release train as well.
@@ -87,6 +89,66 @@ public void testPageable() { | |||
|
|||
} | |||
|
|||
@Test | |||
public void testPageableWithDescDirection() { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the unnecessary empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 364be92
Sort.Order order = optionalOrder.get(); | ||
assertThat(order.getDirection()).isEqualTo(Sort.Direction.DESC); | ||
assertThat(order.getProperty()).isEqualTo("sortProperty"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the unnecessary empty line.
|
||
@Test | ||
public void testPageableWithMultipleSort() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the unnecessary empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 364be92
Sort.Order secondOrder = orderList.get(1); | ||
assertThat(secondOrder.getDirection()).isEqualTo(Sort.Direction.ASC); | ||
assertThat(secondOrder.getProperty()).isEqualTo("sortProperty2"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the unnecessary empty line.
Test fails as well but I saw the comments 🙃 Lines 83 to 84 in f6cf14f
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I've modified https://github.com/spring-cloud/spring-cloud-openfeign/blob/faff6aef8acdf2367c1b5596a384cbe86e1200c5/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageableSpringEncoder.java as suggested in #440 along with corresponding tests.
spring-cloud-openfeign/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageableSpringEncoder.java
Line 119 in faff6ae
If you run tests which I add without the patch of
PageSpringEncoder.java
and you'll be able to see the test fails.