Fix asJson method to pass mapper in WebClientRequestPreparation#5512
Fix asJson method to pass mapper in WebClientRequestPreparation#5512
Conversation
Motivation: Resolve issue line#5454 with proper handling of ObjectMapper instance. Modifications: Pass the provided ObjectMapper to the ResponseAs.json method: asJson(Class<? extends T> clazz, ObjectMapper mapper). Result: The asJson method pass the provided ObjectMapper instance to the ResponseAs.json method as it should.
| requireNonNull(clazz, "clazz"); | ||
| requireNonNull(mapper, "mapper"); | ||
| return asEntity(ResponseAs.json(clazz)); | ||
| return asEntity(ResponseAs.json(clazz, mapper)); |
There was a problem hiding this comment.
Could you also add a unit test to detect unexpected changes in the future?
There was a problem hiding this comment.
I have added the test code in WebClientRequestPreparationTest.
You can review the changes in the following commit: 8bdcb3e.
However, I am not sure it helps detect unexpected changes in the future.
Could you let me know which test cases should be added?
|
@YangSiJun528 Gentle ping. 😉 |
|
Sorry for the delayed response. I will add the unit test as requested. |
be2bcd1 to
ae7754c
Compare
|
I mistakenly merged main into this PR branch, so I had to force reset it to undo the changes. |
| private static WebClient client; | ||
|
|
||
| @BeforeAll | ||
| static void beforeAll() { | ||
| client = WebClient.of(server.httpUri()); | ||
| } |
There was a problem hiding this comment.
I think we don't have to have this as a field. We could just use the client in the method.
|
I have updated the test code to reflect the review comments. |
minwoox
left a comment
There was a problem hiding this comment.
Looks great, thank @YangSiJun528! 😄
|
Well done, @YangSiJun528! 😄 |
…#5512) Motivation: Resolve issue line#5454 with proper handling of ObjectMapper instance. Modifications: - Pass the provided ObjectMapper to the ResponseAs.json method: `WebClientRequestPreparation.asJson(Class<? extends T> clazz, ObjectMapper mapper)`. Result: - The `asJson` method pass the provided ObjectMapper instance to the `ResponseAs.json` method as it should - Closes line#5454
Motivation:
Resolve issue #5454 with proper handling of ObjectMapper instance.
Modifications:
WebClientRequestPreparation.asJson(Class<? extends T> clazz, ObjectMapper mapper).Result:
asJsonmethod pass the provided ObjectMapper instance to theResponseAs.jsonmethod as it should