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
Move internal extracting to AbstractAssert #1781
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.
I think, with suggested changes, this will meet our use cases.
Thanks for the feedback @bjhargrave! I should be able to continue on this topic in the next days.
I agree with you that it would make sense to increase flexibility, I only want to see the impact of it adding proper tests. If the changes get too big, I may do them in a separate PR. |
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.
A few ideas
I built this PR locally and tried using the new Thanks! @@ -210,8 +198,7 @@ public abstract class AbstractPromiseAssert<SELF extends AbstractPromiseAssert<S
* resolved successfully.
*/
public AbstractThrowableAssert<?, ? extends Throwable> hasFailedWithThrowableThat() {
- return hasFailed().asObjectAssert()
- .extracting(this::getFailure, InstanceOfAssertFactories.THROWABLE);
+ return hasFailed().extracting(this::getFailure, InstanceOfAssertFactories.THROWABLE);
}
void assertNotFailed() {
@@ -271,8 +258,7 @@ public abstract class AbstractPromiseAssert<SELF extends AbstractPromiseAssert<S
* resolved with a failure.
*/
public AbstractObjectAssert<?, RESULT> hasValueThat() {
- return isSuccessful().asObjectAssert()
- .extracting(this::getValue);
+ return isSuccessful().extracting(this::getValue, Assertions::assertThat);
}
/**
@@ -294,7 +280,7 @@ public abstract class AbstractPromiseAssert<SELF extends AbstractPromiseAssert<S
*/
public <ASSERT extends AbstractAssert<?, ?>> ASSERT hasValueThat(
InstanceOfAssertFactory<? super RESULT, ASSERT> assertFactory) {
- return hasValueThat().asInstanceOf(assertFactory);
+ return isSuccessful().extracting(this::getValue, assertFactory);
} |
@bjhargrave thanks for the feedback, glad it worked! To make it mergeable I need to rework the tests a bit more but I don't expect further changes in |
Thanks so much for all your work on this! |
The PR is not ready yet, tests and javadoc need some reworking.
@kriegfrj @bjhargrave would this help your needs?
@joel-costigliola I added the
isPublic()
matcher toMETHODS_CHANGING_THE_OBJECT_UNDER_TEST
inSoftProxies
to allow a protectedextracting
without changing the method name. At the moment I don't see any side effect but please let me know your opinion about it. ✅ Applied in 3534841.Check List: