AssertJThrowingCallableRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$).*as compiler argument.
Table of contents
- AssertThatThrownByIsInstanceOf
- AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClass
- AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessage
- AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassRootCauseHasMessage
- AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageVarargs
- AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageStartingWith
- AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageContaining
- AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageNotContainingAny
- AssertThatThrownByIsInstanceOfIllegalStateExceptionClass
- AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessage
- AssertThatThrownByIsInstanceOfIllegalStateExceptionClassRootCauseHasMessage
- AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageVarargs
- AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageStartingWith
- AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageContaining
- AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageNotContaining
- AssertThatThrownByIsInstanceOfNullPointerExceptionClass
- AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessage
- AssertThatThrownByIsInstanceOfNullPointerExceptionClassRootCauseHasMessage
- AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageVarargs
- AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageStartingWith
- AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageContaining
- AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageNotContaining
- AssertThatThrownByIsInstanceOfIOExceptionClass
- AssertThatThrownByIsInstanceOfIOExceptionClassHasMessage
- AssertThatThrownByIsInstanceOfIOExceptionClassRootCauseHasMessage
- AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageVarargs
- AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageStartingWith
- AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageContaining
- AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageNotContaining
- AssertThatThrownByAsInstanceOfThrowable
- AssertThatThrownByIsInstanceOfHasMessage
- AssertThatThrownByIsInstanceOfRootCauseHasMessage
- AssertThatThrownByIsInstanceOfHasMessageVarargs
- AssertThatThrownByIsInstanceOfHasMessageStartingWith
- AssertThatThrownByIsInstanceOfHasMessageContaining
- AssertThatThrownByIsInstanceOfHasMessageNotContaining
- AbstractThrowableAssertHasMessage
- AbstractThrowableAssertWithFailMessage
- AbstractThrowableAssertCauseIsSameAs
AssertThatThrownByIsInstanceOf
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOf")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOf).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertThatThrownByIsInstanceOf() {
- assertThatThrownBy(() -> {}).asInstanceOf(throwable(IllegalArgumentException.class));
- assertThatThrownBy(() -> {}).asInstanceOf(type(IllegalArgumentException.class));
+ assertThatThrownBy(() -> {}).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> {}).isInstanceOf(IllegalArgumentException.class);
}AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClass
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClass")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClass).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfIllegalArgumentExceptionClass() {
- return assertThatIllegalArgumentException().isThrownBy(() -> {});
+ return assertThatThrownBy(() -> {}).isInstanceOf(IllegalArgumentException.class);
}AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessage() {
- return assertThatIllegalArgumentException().isThrownBy(() -> {}).withMessage("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("foo");
}AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassRootCauseHasMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassRootCauseHasMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassRootCauseHasMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassRootCauseHasMessage() {
- return assertThatIllegalArgumentException()
- .isThrownBy(() -> {})
- .havingRootCause()
- .withMessage("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .rootCause()
+ .hasMessage("foo");
}AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageVarargs
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageVarargs")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageVarargs).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageVarargs() {
- return assertThatIllegalArgumentException().isThrownBy(() -> {}).withMessage("foo %s", "bar");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("foo %s", "bar");
}AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageStartingWith
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageStartingWith")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageStartingWith).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageStartingWith() {
- return assertThatIllegalArgumentException().isThrownBy(() -> {}).withMessageStartingWith("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageStartingWith("foo");
}AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageContaining
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageContaining")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageContaining).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageContaining() {
- return assertThatIllegalArgumentException().isThrownBy(() -> {}).withMessageContaining("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("foo");
}AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageNotContainingAny
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageNotContainingAny")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageNotContainingAny).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalArgumentExceptionClassHasMessageNotContainingAny() {
- return assertThatIllegalArgumentException()
- .isThrownBy(() -> {})
- .withMessageNotContainingAny("foo", "bar");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageNotContainingAny("foo", "bar");
}AssertThatThrownByIsInstanceOfIllegalStateExceptionClass
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalStateExceptionClass")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalStateExceptionClass).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfIllegalStateExceptionClass() {
- return assertThatIllegalStateException().isThrownBy(() -> {});
+ return assertThatThrownBy(() -> {}).isInstanceOf(IllegalStateException.class);
}AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessage() {
- return assertThatIllegalStateException().isThrownBy(() -> {}).withMessage("foo");
+ return assertThatThrownBy(() -> {}).isInstanceOf(IllegalStateException.class).hasMessage("foo");
}AssertThatThrownByIsInstanceOfIllegalStateExceptionClassRootCauseHasMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalStateExceptionClassRootCauseHasMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalStateExceptionClassRootCauseHasMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalStateExceptionClassRootCauseHasMessage() {
- return assertThatIllegalStateException()
- .isThrownBy(() -> {})
- .havingRootCause()
- .withMessage("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalStateException.class)
+ .rootCause()
+ .hasMessage("foo");
}AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageVarargs
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageVarargs")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageVarargs).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageVarargs() {
- return assertThatIllegalStateException().isThrownBy(() -> {}).withMessage("foo %s", "bar");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalStateException.class)
+ .hasMessage("foo %s", "bar");
}AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageStartingWith
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageStartingWith")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageStartingWith).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageStartingWith() {
- return assertThatIllegalStateException().isThrownBy(() -> {}).withMessageStartingWith("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalStateException.class)
+ .hasMessageStartingWith("foo");
}AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageContaining
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageContaining")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageContaining).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageContaining() {
- return assertThatIllegalStateException().isThrownBy(() -> {}).withMessageContaining("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining("foo");
}AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageNotContaining
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageNotContaining")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageNotContaining).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIllegalStateExceptionClassHasMessageNotContaining() {
- return assertThatIllegalStateException().isThrownBy(() -> {}).withMessageNotContaining("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalStateException.class)
+ .hasMessageNotContaining("foo");
}AssertThatThrownByIsInstanceOfNullPointerExceptionClass
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfNullPointerExceptionClass")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfNullPointerExceptionClass).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfNullPointerExceptionClass() {
- return assertThatNullPointerException().isThrownBy(() -> {});
+ return assertThatThrownBy(() -> {}).isInstanceOf(NullPointerException.class);
}AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessage() {
- return assertThatNullPointerException().isThrownBy(() -> {}).withMessage("foo");
+ return assertThatThrownBy(() -> {}).isInstanceOf(NullPointerException.class).hasMessage("foo");
}AssertThatThrownByIsInstanceOfNullPointerExceptionClassRootCauseHasMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfNullPointerExceptionClassRootCauseHasMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfNullPointerExceptionClassRootCauseHasMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfNullPointerExceptionClassRootCauseHasMessage() {
- return assertThatNullPointerException()
- .isThrownBy(() -> {})
- .havingRootCause()
- .withMessage("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(NullPointerException.class)
+ .rootCause()
+ .hasMessage("foo");
}AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageVarargs
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageVarargs")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageVarargs).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageVarargs() {
- return assertThatNullPointerException().isThrownBy(() -> {}).withMessage("foo %s", "bar");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(NullPointerException.class)
+ .hasMessage("foo %s", "bar");
}AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageStartingWith
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageStartingWith")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageStartingWith).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageStartingWith() {
- return assertThatNullPointerException().isThrownBy(() -> {}).withMessageStartingWith("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(NullPointerException.class)
+ .hasMessageStartingWith("foo");
}AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageContaining
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageContaining")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageContaining).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageContaining() {
- return assertThatNullPointerException().isThrownBy(() -> {}).withMessageContaining("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(NullPointerException.class)
+ .hasMessageContaining("foo");
}AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageNotContaining
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageNotContaining")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageNotContaining).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfNullPointerExceptionClassHasMessageNotContaining() {
- return assertThatNullPointerException().isThrownBy(() -> {}).withMessageNotContaining("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(NullPointerException.class)
+ .hasMessageNotContaining("foo");
}AssertThatThrownByIsInstanceOfIOExceptionClass
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIOExceptionClass")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIOExceptionClass).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfIOExceptionClass() {
- return assertThatIOException().isThrownBy(() -> {});
+ return assertThatThrownBy(() -> {}).isInstanceOf(IOException.class);
}AssertThatThrownByIsInstanceOfIOExceptionClassHasMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIOExceptionClassHasMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIOExceptionClassHasMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfIOExceptionClassHasMessage() {
- return assertThatIOException().isThrownBy(() -> {}).withMessage("foo");
+ return assertThatThrownBy(() -> {}).isInstanceOf(IOException.class).hasMessage("foo");
}AssertThatThrownByIsInstanceOfIOExceptionClassRootCauseHasMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIOExceptionClassRootCauseHasMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIOExceptionClassRootCauseHasMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIOExceptionClassRootCauseHasMessage() {
- return assertThatIOException().isThrownBy(() -> {}).havingRootCause().withMessage("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IOException.class)
+ .rootCause()
+ .hasMessage("foo");
}AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageVarargs
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageVarargs")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageVarargs).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfIOExceptionClassHasMessageVarargs() {
- return assertThatIOException().isThrownBy(() -> {}).withMessage("foo %s", "bar");
+ return assertThatThrownBy(() -> {}).isInstanceOf(IOException.class).hasMessage("foo %s", "bar");
}AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageStartingWith
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageStartingWith")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageStartingWith).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIOExceptionClassHasMessageStartingWith() {
- return assertThatIOException().isThrownBy(() -> {}).withMessageStartingWith("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IOException.class)
+ .hasMessageStartingWith("foo");
}AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageContaining
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageContaining")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageContaining).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIOExceptionClassHasMessageContaining() {
- return assertThatIOException().isThrownBy(() -> {}).withMessageContaining("foo");
+ return assertThatThrownBy(() -> {}).isInstanceOf(IOException.class).hasMessageContaining("foo");
}AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageNotContaining
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageNotContaining")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfIOExceptionClassHasMessageNotContaining).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?>
testAssertThatThrownByIsInstanceOfIOExceptionClassHasMessageNotContaining() {
- return assertThatIOException().isThrownBy(() -> {}).withMessageNotContaining("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IOException.class)
+ .hasMessageNotContaining("foo");
}AssertThatThrownByAsInstanceOfThrowable
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByAsInstanceOfThrowable")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByAsInstanceOfThrowable).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByAsInstanceOfThrowable() {
- return assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {});
+ return assertThatThrownBy(() -> {}).asInstanceOf(throwable(IllegalArgumentException.class));
}AssertThatThrownByIsInstanceOfHasMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfHasMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfHasMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfHasMessage() {
- return assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> {})
- .withMessage("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("foo");
}AssertThatThrownByIsInstanceOfRootCauseHasMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfRootCauseHasMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfRootCauseHasMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfRootCauseHasMessage() {
- return assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> {})
- .havingRootCause()
- .withMessage("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .rootCause()
+ .hasMessage("foo");
}AssertThatThrownByIsInstanceOfHasMessageVarargs
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfHasMessageVarargs")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfHasMessageVarargs).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfHasMessageVarargs() {
- return assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> {})
- .withMessage("foo %s", "bar");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("foo %s", "bar");
}AssertThatThrownByIsInstanceOfHasMessageStartingWith
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfHasMessageStartingWith")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfHasMessageStartingWith).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfHasMessageStartingWith() {
- return assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> {})
- .withMessageStartingWith("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageStartingWith("foo");
}AssertThatThrownByIsInstanceOfHasMessageContaining
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfHasMessageContaining")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfHasMessageContaining).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfHasMessageContaining() {
- return assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> {})
- .withMessageContaining("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("foo");
}AssertThatThrownByIsInstanceOfHasMessageNotContaining
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatThrownByIsInstanceOfHasMessageNotContaining")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIsInstanceOfHasMessageNotContaining).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractObjectAssert<?, ?> testAssertThatThrownByIsInstanceOfHasMessageNotContaining() {
- return assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> {})
- .withMessageNotContaining("foo");
+ return assertThatThrownBy(() -> {})
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageNotContaining("foo");
}AbstractThrowableAssertHasMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AbstractThrowableAssertHasMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AbstractThrowableAssertHasMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<AbstractThrowableAssert<?, ? extends Throwable>>
testAbstractThrowableAssertHasMessage() {
return ImmutableSet.of(
assertThatThrownBy(() -> {})
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("foo %s".formatted("bar")),
+ .hasMessage("foo %s", "bar"),
assertThatThrownBy(() -> {})
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("foo %s %s".formatted("bar", 1)));
+ .hasMessage("foo %s %s", "bar", 1));
}AbstractThrowableAssertWithFailMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AbstractThrowableAssertWithFailMessage")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AbstractThrowableAssertWithFailMessage).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<AbstractThrowableAssert<?, ? extends Throwable>>
testAbstractThrowableAssertWithFailMessage() {
return ImmutableSet.of(
assertThatThrownBy(() -> {})
.isInstanceOf(IllegalArgumentException.class)
- .withFailMessage("foo %s".formatted("bar")),
+ .withFailMessage("foo %s", "bar"),
assertThatThrownBy(() -> {})
.isInstanceOf(IllegalArgumentException.class)
- .withFailMessage("foo %s %s".formatted("bar", 1)));
+ .withFailMessage("foo %s %s", "bar", 1));
}AbstractThrowableAssertCauseIsSameAs
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AbstractThrowableAssertCauseIsSameAs")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AbstractThrowableAssertCauseIsSameAs).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
@SuppressWarnings("deprecation" /* Rule targets deprecated API. */)
AbstractThrowableAssert<?, ? extends Throwable> testAbstractThrowableAssertCauseIsSameAs() {
- return assertThat(new IllegalStateException())
- .hasCauseReference(new IllegalArgumentException());
+ return assertThat(new IllegalStateException()).cause().isSameAs(new IllegalArgumentException());
}