Skip to content
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

Open
wants to merge 7 commits into
base: 3.x
Choose a base branch
from

Conversation

pbacz
Copy link
Contributor

@pbacz pbacz commented Jan 2, 2024

Check List:

Copy link
Member

@scordio scordio left a 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() {
Copy link
Member

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?

Copy link
Contributor Author

@pbacz pbacz Jan 3, 2024

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,
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@pbacz
Copy link
Contributor Author

pbacz commented Jan 3, 2024

@scordio I need this commit in my branch 887f97b
Which approach is recommended in the project?

  • rebase over main
  • merge main to my branch
  • cherry pick the commit

@scordio
Copy link
Member

scordio commented Jan 3, 2024

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.

pbacz and others added 6 commits January 3, 2024 23:20
…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>
@pbacz pbacz changed the title Add hasPermittedSubclasses and hasNoPermittedSubclasses for Class assertions Add hasPermittedSubclasses for Class assertions Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hasPermittedSubclasses and hasNoPermittedSubclasses for Class assertions
2 participants