Skip to content

Enhance WebTestClient to support JSONPath decoding to higher level objects #31653

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
rstoyanchev opened this issue Nov 22, 2023 · 1 comment
Closed
Assignees
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@rstoyanchev
Copy link
Contributor

rstoyanchev commented Nov 22, 2023

WebTestClient supports passing a target Class in JsonPathAssertions. We should add an overloaded method that accepts ParameterizedTypeReference. Also, even with the current method, it is only possible to decode to basic types without customizing the JSONPath Configuration.

Once it is possible to customize the JSONPath Configuration in JsonPathExpectationsHelper with #31651, we can update WebTestClient to prepare a Configuration with the JsonProvider that aligns with that configured JSON encoding and decoding, and/or allow having the Configuration passed in somehow through the WebTestClient.Builder (without bring in a hard dependency).

@rstoyanchev rstoyanchev added in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Nov 22, 2023
@rstoyanchev rstoyanchev added this to the 6.2.x milestone Nov 22, 2023
@rstoyanchev rstoyanchev self-assigned this Nov 22, 2023
@snicoll
Copy link
Member

snicoll commented Jan 16, 2024

I believe that .jsonPath(String expression, Object...args) should be deprecated as part of this effort if we want to provide the Configuration in the jsonPath call. Or perhaps it should be deprecated anyway, see #32036 for more details.

@snicoll snicoll self-assigned this Jan 16, 2024
@snicoll snicoll modified the milestones: 6.2.x, 6.2.0-M1 Jan 19, 2024
snicoll added a commit to snicoll/spring-framework that referenced this issue Jan 31, 2024
This commit improves jsonpath support in WebTestClient by detecting
a suitable json encoder/decoder that can be applied to assert more
complex data structure.

Closes spring-projectsgh-31653
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants