-
Notifications
You must be signed in to change notification settings - Fork 1.7k
GH-4008: Improve ReplyingKafkaTemplateTests with modular validation #4031
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
Conversation
artembilan
left a comment
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.
Thank you for refactoring this hard-to-read logic!
...g-kafka/src/test/java/org/springframework/kafka/requestreply/ReplyingKafkaTemplateTests.java
Outdated
Show resolved
Hide resolved
|
|
||
| assertThat(resultingMessage.getPayload()).isEqualTo("OK"); | ||
| assertThat(resultingMessage.getHeaders()).containsKey("originalPayload"); | ||
| assertThat(resultingMessage.getHeaders().get("originalPayload")).isEqualTo("expected_message"); |
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.
There is an API in AssertJ to do both at the same time:
assertThat(resultingMessage.getHeaders()).containsEntry("originalPayload", "expected_message");
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.
There is an API in AssertJ to do both at the same time:
assertThat(resultingMessage.getHeaders()).containsEntry("originalPayload", "expected_message");
@artembilan Thank you for the suggestion! I’ve implemented your feedback in commit e8baed9 by using AssertJ’s containsEntry() method. This replaces the separate assertions with the more concise approach you recommended.
artembilan
left a comment
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.
Thank you for the update!
It is really very close to merge.
However I’ve noticed the problem:
Signed-off-by: snowykte0426 snowykte0426@naver.com
this one has to come with your official name to satisfy all the legal requirements.
Please, revise your local Git client config.
Squash and push a commit with with right sign-off.
Improve test validation logic by: - Using direct assertThat() assertions instead of custom validation methods - Replacing separate header assertions with single containsEntry() method - Fixing checkstyle violations (trailing whitespace and extra blank lines) Signed-off-by: Kim Tae Eun <snowykte0426@naver.com>
Thank you for the review feedback. I've squashed the commits and updated |
Summary
This PR addresses issue #4008 by refactoring
ReplyingKafkaTemplateTeststo improve test maintainability and readability through better
separation of concerns.
Message<?>objects instead ofhandling validation internally
(
validateHeaders,validateSuccessfulResponse)listener logic
Changes Made
handleCustomReplyHeaderNoReplyPartitionandhandleCustomReplyHeaderDefaultPartitionHeaderto focus only on businesslogic
validateHeaders()andvalidateSuccessfulResponse()methods for external header verificationtestCustomReplyTopicHeaderIsNotDuplicatedand
testCustomReplyHeadersAreNotDuplicatedto use the new validationapproach
Fixes #4008