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
Add hasPermittedSubclasses for Class assertions #3316
base: 3.x
Are you sure you want to change the base?
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.
Thank you, @pbacz! I have a few comments.
* @throws AssertionError if {@code actual} is {@code null}. | ||
* @throws AssertionError if the actual {@code Class} has any permitted subclasses | ||
*/ | ||
public SELF hasNoPermittedSubclasses() { |
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.
I had the impression it's not valuable to have this assertion (#3263 (comment)).
Or did I misunderstand?
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.
Looks like I misunderstood. When you said:
I propose we add only hasPermittedSubclasses with contains behavior
I thought you mean add hasPermittedSubclasses
and do not add hasOnlyPermittedSubclasses
.
I can remove this assertion, no problem.
* @throws AssertionError if {@code actual} is {@code null}. | ||
* @throws AssertionError if the actual {@code Class} does not have all of these permitted subclasses. | ||
*/ | ||
public void assertContainsPermittedSubclasses(AssertionInfo info, Class<?> actual, |
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.
This can be pulled to AbstractClassAssert
as a private method as it's unlikely we would reuse this elsewhere. hasSuperclass
implementation might be a good example of such a pattern.
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.
Ok, will do.
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.
Done.
...va-17/src/test/java/org/assertj/core/tests/java17/Assertions_assertThat_with_Class_Test.java
Show resolved
Hide resolved
I'd suggest either rebase or merge but it's totally up to you. We'll anyway squash the changes in a single commit once ready. |
…rc/test/java/org/assertj/core/tests/java17/Assertions_assertThat_with_Class_Test.java Co-authored-by: Stefano Cordio <stefano_cordio@epam.com>
…rc/test/java/org/assertj/core/tests/java17/Assertions_assertThat_with_Class_Test.java Co-authored-by: Stefano Cordio <stefano_cordio@epam.com>
Check List:
hasPermittedSubclasses
andhasNoPermittedSubclasses
forClass
assertions #3263