-
Notifications
You must be signed in to change notification settings - Fork 571
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
[Backport stable/1.2] Extend Either/EitherAssert capabilities #8815
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adds a `getOrElse` API to the `Either` type. This new method behaves much like `Optional#getOrElse` by returning a default value when the `Either` is a `Left`, or return its right value when it's a `Right`. (cherry picked from commit 3dd05cf)
Extends the existing `EitherAssert` set of assertions with new extraction capabilities. This allows one to write something like: ```java EitherAssert.assertThat(either).left().isEqualTo(1); EitherAssert.assertThat(instantEither) .right() .asInstanceOf(InstanceOfAssertFactories.INSTANT) .isBetween(today, tomorrow); ``` Assertion info is correctly preserved across the whole chain. (cherry picked from commit 46c88e6)
Co-authored-by: Nico Korthout <korthout@users.noreply.github.com> (cherry picked from commit 6347168)
Use the public `test-util` `EitherAssert` instead of the test scoped `EitherAssert` found in the `util` module. We shouldn't use test scoped files from other modules in general, and we should use the one made explicitly for reuse. (cherry picked from commit 7464426)
Removes the customized, generated `EitherAssert` in the util module. This was only used for testing `Either` itself, but there was only marginal value to it. Furthermore, we already have another `EitherAssert` available in the `test-util` module, which is the one meant to be reused in all the other modules as a test utility. (cherry picked from commit e595174)
(cherry picked from commit 1087d6a)
cc40cbe
to
998adf6
Compare
(cherry picked from commit 873160f)
998adf6
to
ce8df45
Compare
korthout
approved these changes
Feb 21, 2022
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 @npepinpe LGTM 👍
bors merge |
This pull request was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR backports #8797 to stable/1.2, which is necessary to in the end backport the fix for #5525. There were some conflicts which I corrected with the last commit (one extra dependency pulled).
Related issues
backports #8797
Definition of Done
Not all items need to be done depending on the issue and the pull request.
Code changes:
backport stable/1.3
) to the PR, in case that fails you need to create backports manually.Testing:
Documentation: