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

Deprecate catchThrowableOfType(ThrowingCallable, Class) in favor of catchThrowableOfType(Class, ThrowingCallable) #2823

Merged
merged 19 commits into from May 10, 2024

Conversation

java-coding-prodigy
Copy link
Contributor

@java-coding-prodigy java-coding-prodigy commented Oct 27, 2022

Check List:

Following the contributing guidelines will make it easier for us to review and accept your PR.

@java-coding-prodigy java-coding-prodigy marked this pull request as draft October 27, 2022 06:43
@java-coding-prodigy
Copy link
Contributor Author

For the documentation what should I do? Should I copy paste the same documentation as for the other method?

@scordio
Copy link
Member

scordio commented Oct 27, 2022

Yes, I'd copy the existing documentation.

@java-coding-prodigy
Copy link
Contributor Author

Yes, I'd copy the existing documentation.

Should I also mention the new method in the old methods description?

@scordio
Copy link
Member

scordio commented Oct 28, 2022

Should I also mention the new method in the old methods description?

Yes, you could add a @deprecated entry in the Javadoc similarly to what we have with AbstractThrowableAssert::getCause.

@java-coding-prodigy
Copy link
Contributor Author

Now for unit tests should I also use similar unit tests as the old methods do? Or should I change the method calls in the tests to the new method?

@java-coding-prodigy
Copy link
Contributor Author

Now for unit tests should I also use similar unit tests as the old methods do? Or should I change the method calls in the tests to the new method?

So I'll do the second thing?

@scordio
Copy link
Member

scordio commented Nov 3, 2022

Now for unit tests should I also use similar unit tests as the old methods do? Or should I change the method calls in the tests to the new method?

So I'll do the second thing?

Yes, changing the method calls in the tests to the new method is fine. Sorry for the late feedback!

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.

As per my comment, please remove the unsupported attributes so that the build can go forward.

@java-coding-prodigy
Copy link
Contributor Author

I don't understand why some of the checks are failing

@scordio
Copy link
Member

scordio commented Nov 12, 2022

It's caused by the standard_assertions_and_bdd_assertions_should_have_the_same_non_assertions_methods test method in Assertions_sync_with_BDDAssertions_WithAssertions_and_soft_assertions_variants_Test.

To fix it, you need to add new entry point methods in BDDAssertions, in line with the changes you did in Assertions.

@java-coding-prodigy
Copy link
Contributor Author

It's caused by the standard_assertions_and_bdd_assertions_should_have_the_same_non_assertions_methods test method in Assertions_sync_with_BDDAssertions_WithAssertions_and_soft_assertions_variants_Test.

To fix it, you need to add new entry point methods in BDDAssertions, in line with the changes you did in Assertions.

Thank you, I had overlooked the BDDAssertions.java file previously.
I also added a <p> tag in the documentations of the old methods after the deprecated marker, as the method description was coming on the same line otherwise.

@java-coding-prodigy java-coding-prodigy marked this pull request as ready for review November 14, 2022 14:20
@java-coding-prodigy
Copy link
Contributor Author

@scordio Could you please approve the workflows? Thank you.

@java-coding-prodigy
Copy link
Contributor Author

java-coding-prodigy commented Nov 26, 2022

@scordio Please approve the workflows, and also review the code in case any changes still need to made.
Thank you :)

@vlsi
Copy link
Contributor

vlsi commented Feb 8, 2023

Technically speaking, the PR is not something "Kotlin requires".
The PR makes the code easier to use in Java as well: lambda body can be big, so the code is easier to follow if smaller arguments (e.g. Class) come before lambdas.

So I would suggest renaming the PR (and commits) to something like Move lambdas to last arguments of .....

@scordio scordio changed the title Make the assertion lambdas Kotlin friendly Move functional interface based arguments to the last position Feb 9, 2023
@scordio
Copy link
Member

scordio commented Feb 9, 2023

I agree with @vlsi, also mentioned in #2821 (comment):

We believe that the readability of Java code can also benefit from this change.

PR renamed.

@scordio scordio added this to the 3.25.0 milestone Feb 9, 2023
@scordio scordio changed the title Move functional interface based arguments to the last position Move catchThrowableOfType ThrowingCallable argument to the last position Feb 9, 2023
@java-coding-prodigy
Copy link
Contributor Author

Bump

@scordio
Copy link
Member

scordio commented May 10, 2024

We should also add a Kotlin-based test as the whole topic started from there. I'll take care of it.

@scordio scordio changed the title Move catchThrowableOfType ThrowingCallable argument to the last position Add catchThrowableOfType(Class, ThrowingCallable) overload May 10, 2024
@scordio scordio changed the title Add catchThrowableOfType(Class, ThrowingCallable) overload Deprecate catchThrowableOfType(ThrowingCallable, Class) in favor of catchThrowableOfType(Class, ThrowingCallable) May 10, 2024
# Conflicts:
#	assertj-tests/assertj-integration-tests/assertj-core-kotlin/src/test/kotlin/org/assertj/core/tests/kotlin/Assertions_describedAs_text_supplier_Test.kt
@scordio scordio added the type: deprecation A deprecation of an existing API label May 10, 2024
@scordio scordio merged commit a33478f into assertj:3.x May 10, 2024
11 checks passed
scordio pushed a commit that referenced this pull request May 10, 2024
… `catchThrowableOfType(Class, ThrowingCallable)` (#2823)

Co-authored-by: Vladimir Sitnikov <vlsi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: deprecation A deprecation of an existing API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the assertion lambdas Kotlin friendly
3 participants