-
Notifications
You must be signed in to change notification settings - Fork 14.4k
KAFKA-19349: Move CreateTopicsRequestWithPolicyTest to clients-integration-tests #19849
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
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.
Thanks @Rancho-7 for this patch, left some comments
private void validateErrorCreateTopicsRequests(NewTopic topic, Admin admin, boolean validateOnly, Class<? extends Throwable> expectedExceptionClass, String expectedErrorMessage) { | ||
ExecutionException exception = assertThrows(ExecutionException.class, () -> | ||
admin.createTopics(List.of(topic), new CreateTopicsOptions().validateOnly(validateOnly)).all().get()); | ||
assertInstanceOf(expectedExceptionClass, exception.getCause()); |
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.
Could you use a stricter check here, use assertEquals
instead of assertInstanceOf
?
assertInstanceOf(expectedExceptionClass, exception.getCause()); | |
assertEquals( | |
expectedExceptionClass, | |
exception.getCause(), | |
"Expected " + expectedExceptionClass.getSimpleName() + ", but got " + exception.getCause().getSimpleName() | |
); |
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.
Thanks @m1a2st for the review! I have added the enhanced assertion message to make the output clearer as suggested. However, using assertEquals
would require creating a addtional instance which may be unnecessary? since we have already verified the exception type and error message here.
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.
assertInstanceOf
allows the subclasses, so it's not a strict check. By contrast, assertEquals(expectedExceptionClass, exception.getCause().getClass());
is a strict check.
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.
jira: https://issues.apache.org/jira/browse/KAFKA-19349
Move CreateTopicsRequestWithPolicyTest to clients-integration-tests.
Reviewers: Ken Huang s7133700@gmail.com, Chia-Ping Tsai
chia7712@gmail.com