-
Notifications
You must be signed in to change notification settings - Fork 39
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
Introduce AssertThatThrownBy*ExceptionRootCauseHasMessage
Refaster rules
#1471
Conversation
AssertThat{*}ExceptionRootCauseHasMessage
Refaster rulesAssertThatThrownBy{*}RootCauseHasMessage
Refaster rules
Looks good. No mutations were possible for these changes. |
AssertThatThrownBy{*}RootCauseHasMessage
Refaster rulesAssertThatThrownBy*ExceptionRootCauseHasMessage
Refaster rules
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.
Suggested commit message:
Introduce `AssertThatThrownBy*ExceptionRootCauseHasMessage` Refaster rules (#1471)
Not great, but works :)
static final class AssertThatThrownByRootCauseHasMessage { | ||
@BeforeTemplate | ||
@SuppressWarnings("AssertThatThrownBy" /* This is a more specific template. */) | ||
AbstractObjectAssert<?, ?> before( | ||
ThrowingCallable throwingCallable, | ||
Class<? extends Throwable> exceptionType, | ||
String message) { | ||
return assertThatExceptionOfType(exceptionType) | ||
.isThrownBy(throwingCallable) | ||
.havingRootCause() | ||
.withMessage(message); | ||
} | ||
|
||
@AfterTemplate | ||
@UseImportPolicy(STATIC_IMPORT_ALWAYS) | ||
AbstractObjectAssert<?, ?> after( | ||
ThrowingCallable throwingCallable, | ||
Class<? extends Throwable> exceptionType, | ||
String message) { | ||
return assertThatThrownBy(throwingCallable) | ||
.isInstanceOf(exceptionType) | ||
.rootCause() | ||
.hasMessage(message); | ||
} | ||
} |
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.
We should make the return types more explicit, and replace ? extends Throwable
with a shared type variable T
, but that applies to many rules in this class, so: for another time. (Ideally both these steps are automated.)
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.
LGMT 🚀
e0b0007
to
ac0cdbf
Compare
Looks good. No mutations were possible for these changes. |
Quality Gate passedIssues Measures |
This PR aims to get rid of the following part of the
init-patch
of the new IT: https://github.com/PicnicSupermarket/error-prone-support/pull/1468/files#diff-6b99a1fb957cc4c8081a8a95423c965335a67c526f4b5b634aafa0d6912dc4dcR61.Not sure about the * part in the title, let me know what options are :D.