Skip to content

API: Deprecate AssertHelpers#6977

Merged
rdblue merged 1 commit into
apache:masterfrom
nastra:patch-4
Mar 13, 2023
Merged

API: Deprecate AssertHelpers#6977
rdblue merged 1 commit into
apache:masterfrom
nastra:patch-4

Conversation

@nastra
Copy link
Copy Markdown
Contributor

@nastra nastra commented Mar 1, 2023

I believe we should point people for newly written code to use Assertions#assertThatThrownBy(..) as it provides a more fluent way of asserting exceptions

Copy link
Copy Markdown
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

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

I like it. Should we also remove the usage of AssertHelpers? Could be a separate PR.

@nastra
Copy link
Copy Markdown
Contributor Author

nastra commented Mar 2, 2023

Should we also remove the usage of AssertHelpers? Could be a separate PR.

That would be ideal in the long run, but the diff will be quite big, because it's being used at lots of places. At the very least I think we can start and not use it in new tests.

Copy link
Copy Markdown
Contributor

@jackye1995 jackye1995 left a comment

Choose a reason for hiding this comment

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

We can create an issue to remove the usages of it, it would be a good beginner task.

* </pre>
*
* @deprecated Use {@link Assertions#assertThatThrownBy(ThrowableAssert.ThrowingCallable)} directly
* as it provides a more fluent way of asserting on exceptions.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My only issue with this is making sure that hasMessage is called. How do we enforce that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that's a valid point. I was thinking maybe we could introduce a checkstyle rule (a multiline regex) that would make sure checks against the error message are done. I can open a separate PR for that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I opened #7040 to address that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need deprecations on the methods as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

all calling sites that use any method from AssertHelpers will see that the class itself is deprecated, so I don't think we need to deprecate each method individually

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I did some small tests, there is a small difference in IDE: if only the static method is imported the user won't see deprecation warning in code unless he/she looks at the import block, so it might still be beneficial to mark methods as deprecated as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good point @jackye1995. I've added deprecations to all methods inside that class

I believe we should point people for newly written code to use `Assertions#assertThatThrownBy(..)` as it provides a more fluent way of asserting exceptions
Copy link
Copy Markdown
Contributor

@jackye1995 jackye1995 left a comment

Choose a reason for hiding this comment

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

looks good to me!

@rdblue rdblue merged commit 4fc9671 into apache:master Mar 13, 2023
@rdblue
Copy link
Copy Markdown
Contributor

rdblue commented Mar 13, 2023

@nastra, @jackye1995 I merged this. It will be a good move, but we have to make sure we are catching the message validation in reviews!

@nastra nastra deleted the patch-4 branch March 14, 2023 06:47
krvikash pushed a commit to krvikash/iceberg that referenced this pull request Mar 16, 2023
Point people to use `Assertions#assertThatThrownBy(..)` as it provides a more fluent way of asserting exceptions
@findepi
Copy link
Copy Markdown
Member

findepi commented Jun 15, 2024

follow-up to complete removal of AssertHelpers -- #10500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants