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

Encode Pageable.Sort with percent encoded comma. Fixes gh-440. #467

Merged
merged 2 commits into from Feb 8, 2021

Conversation

KENNYSOFT
Copy link
Contributor

@KENNYSOFT KENNYSOFT commented Jan 23, 2021

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.

If you run tests which I add without the patch of PageSpringEncoder.java and you'll be able to see the test fails.

@pivotal-issuemaster
Copy link

@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.

@pivotal-issuemaster
Copy link

@KENNYSOFT Thank you for signing the Contributor License Agreement!

@codecov
Copy link

codecov bot commented Jan 23, 2021

Codecov Report

Merging #467 (4a08f2f) into master (252f118) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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           
Impacted Files Coverage Δ Complexity Δ
...cloud/openfeign/support/PageableSpringEncoder.java 78.57% <100.00%> (ø) 14.00 <0.00> (ø)

@OlgaMaciaszek
Copy link
Collaborator

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()) {
Copy link
Contributor

@nkonev nkonev Feb 8, 2021

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);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in 86785dc

Copy link
Contributor Author

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()) {
Copy link
Contributor

@nkonev nkonev Feb 8, 2021

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();

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yeah changed. 86785dc

Copy link
Contributor Author

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

Copy link
Collaborator

@OlgaMaciaszek OlgaMaciaszek left a 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() {

Copy link
Collaborator

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.

Copy link
Contributor Author

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");

Copy link
Collaborator

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() {

Copy link
Collaborator

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.

Copy link
Contributor Author

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");

Copy link
Collaborator

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.

@KENNYSOFT KENNYSOFT changed the base branch from master to 2.2.x February 8, 2021 17:20
@KENNYSOFT
Copy link
Contributor Author

Test fails as well but I saw the comments 🙃

// TODO: not sure how to verify retry happens. Debugging through it, it works
// maybe the assertEquals above is enough because of the bogus servers

@OlgaMaciaszek OlgaMaciaszek added bug Something isn't working and removed waiting for feedback labels Feb 8, 2021
Copy link
Collaborator

@OlgaMaciaszek OlgaMaciaszek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@OlgaMaciaszek OlgaMaciaszek merged commit d87375e into spring-cloud:2.2.x Feb 8, 2021
@KENNYSOFT KENNYSOFT deleted the gh-440 branch February 8, 2021 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants