AssertJThrowingCallableRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

Disable all rules by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$).* as compiler argument.

Table of contents
  1. AssertThatThrownByIllegalArgumentException
  2. AssertThatThrownByIllegalArgumentExceptionHasMessage
  3. AssertThatThrownByIllegalArgumentExceptionHasMessageParameters
  4. AssertThatThrownByIllegalArgumentExceptionHasMessageStartingWith
  5. AssertThatThrownByIllegalArgumentExceptionHasMessageContaining
  6. AssertThatThrownByIllegalArgumentExceptionHasMessageNotContainingAny
  7. AssertThatThrownByIllegalStateException
  8. AssertThatThrownByIllegalStateExceptionHasMessage
  9. AssertThatThrownByIllegalStateExceptionHasMessageParameters
  10. AssertThatThrownByIllegalStateExceptionHasMessageStartingWith
  11. AssertThatThrownByIllegalStateExceptionHasMessageContaining
  12. AssertThatThrownByIllegalStateExceptionHasMessageNotContaining
  13. AssertThatThrownByNullPointerException
  14. AssertThatThrownByNullPointerExceptionHasMessage
  15. AssertThatThrownByNullPointerExceptionHasMessageParameters
  16. AssertThatThrownByNullPointerExceptionHasMessageStartingWith
  17. AssertThatThrownByNullPointerExceptionHasMessageContaining
  18. AssertThatThrownByNullPointerExceptionHasMessageNotContaining
  19. AssertThatThrownByIOException
  20. AssertThatThrownByIOExceptionHasMessage
  21. AssertThatThrownByIOExceptionHasMessageParameters
  22. AssertThatThrownByIOExceptionHasMessageStartingWith
  23. AssertThatThrownByIOExceptionHasMessageContaining
  24. AssertThatThrownByIOExceptionHasMessageNotContaining
  25. AssertThatThrownBy
  26. AssertThatThrownByHasMessage
  27. AssertThatThrownByHasMessageParameters
  28. AssertThatThrownByHasMessageStartingWith
  29. AssertThatThrownByHasMessageContaining
  30. AssertThatThrownByHasMessageNotContaining
  31. AbstractThrowableAssertHasMessage
  32. AbstractThrowableAssertWithFailMessage

AssertThatThrownByIllegalArgumentException

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalArgumentException") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalArgumentException).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIllegalArgumentException() {
-  return assertThatIllegalArgumentException().isThrownBy(() -> {});
+  return assertThatThrownBy(() -> {}).isInstanceOf(IllegalArgumentException.class);
 }

AssertThatThrownByIllegalArgumentExceptionHasMessage

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalArgumentExceptionHasMessage") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalArgumentExceptionHasMessage).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIllegalArgumentExceptionHasMessage() {
-  return assertThatIllegalArgumentException().isThrownBy(() -> {}).withMessage("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalArgumentException.class)
+      .hasMessage("foo");
 }

AssertThatThrownByIllegalArgumentExceptionHasMessageParameters

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalArgumentExceptionHasMessageParameters") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalArgumentExceptionHasMessageParameters).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIllegalArgumentExceptionHasMessageParameters() {
-  return assertThatIllegalArgumentException().isThrownBy(() -> {}).withMessage("foo %s", "bar");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalArgumentException.class)
+      .hasMessage("foo %s", "bar");
 }

AssertThatThrownByIllegalArgumentExceptionHasMessageStartingWith

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalArgumentExceptionHasMessageStartingWith") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalArgumentExceptionHasMessageStartingWith).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?>
     testAssertThatThrownByIllegalArgumentExceptionHasMessageStartingWith() {
-  return assertThatIllegalArgumentException().isThrownBy(() -> {}).withMessageStartingWith("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalArgumentException.class)
+      .hasMessageStartingWith("foo");
 }

AssertThatThrownByIllegalArgumentExceptionHasMessageContaining

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalArgumentExceptionHasMessageContaining") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalArgumentExceptionHasMessageContaining).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIllegalArgumentExceptionHasMessageContaining() {
-  return assertThatIllegalArgumentException().isThrownBy(() -> {}).withMessageContaining("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalArgumentException.class)
+      .hasMessageContaining("foo");
 }

AssertThatThrownByIllegalArgumentExceptionHasMessageNotContainingAny

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalArgumentExceptionHasMessageNotContainingAny") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalArgumentExceptionHasMessageNotContainingAny).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?>
     testAssertThatThrownByIllegalArgumentExceptionHasMessageNotContainingAny() {
-  return assertThatIllegalArgumentException()
-      .isThrownBy(() -> {})
-      .withMessageNotContainingAny("foo", "bar");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalArgumentException.class)
+      .hasMessageNotContainingAny("foo", "bar");
 }

AssertThatThrownByIllegalStateException

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalStateException") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalStateException).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIllegalStateException() {
-  return assertThatIllegalStateException().isThrownBy(() -> {});
+  return assertThatThrownBy(() -> {}).isInstanceOf(IllegalStateException.class);
 }

AssertThatThrownByIllegalStateExceptionHasMessage

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalStateExceptionHasMessage") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalStateExceptionHasMessage).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIllegalStateExceptionHasMessage() {
-  return assertThatIllegalStateException().isThrownBy(() -> {}).withMessage("foo");
+  return assertThatThrownBy(() -> {}).isInstanceOf(IllegalStateException.class).hasMessage("foo");
 }

AssertThatThrownByIllegalStateExceptionHasMessageParameters

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalStateExceptionHasMessageParameters") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalStateExceptionHasMessageParameters).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIllegalStateExceptionHasMessageParameters() {
-  return assertThatIllegalStateException().isThrownBy(() -> {}).withMessage("foo %s", "bar");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalStateException.class)
+      .hasMessage("foo %s", "bar");
 }

AssertThatThrownByIllegalStateExceptionHasMessageStartingWith

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalStateExceptionHasMessageStartingWith") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalStateExceptionHasMessageStartingWith).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIllegalStateExceptionHasMessageStartingWith() {
-  return assertThatIllegalStateException().isThrownBy(() -> {}).withMessageStartingWith("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalStateException.class)
+      .hasMessageStartingWith("foo");
 }

AssertThatThrownByIllegalStateExceptionHasMessageContaining

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalStateExceptionHasMessageContaining") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalStateExceptionHasMessageContaining).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIllegalStateExceptionHasMessageContaining() {
-  return assertThatIllegalStateException().isThrownBy(() -> {}).withMessageContaining("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalStateException.class)
+      .hasMessageContaining("foo");
 }

AssertThatThrownByIllegalStateExceptionHasMessageNotContaining

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIllegalStateExceptionHasMessageNotContaining") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIllegalStateExceptionHasMessageNotContaining).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIllegalStateExceptionHasMessageNotContaining() {
-  return assertThatIllegalStateException().isThrownBy(() -> {}).withMessageNotContaining("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalStateException.class)
+      .hasMessageNotContaining("foo");
 }

AssertThatThrownByNullPointerException

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByNullPointerException") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByNullPointerException).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByNullPointerException() {
-  return assertThatNullPointerException().isThrownBy(() -> {});
+  return assertThatThrownBy(() -> {}).isInstanceOf(NullPointerException.class);
 }

AssertThatThrownByNullPointerExceptionHasMessage

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByNullPointerExceptionHasMessage") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByNullPointerExceptionHasMessage).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByNullPointerExceptionHasMessage() {
-  return assertThatNullPointerException().isThrownBy(() -> {}).withMessage("foo");
+  return assertThatThrownBy(() -> {}).isInstanceOf(NullPointerException.class).hasMessage("foo");
 }

AssertThatThrownByNullPointerExceptionHasMessageParameters

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByNullPointerExceptionHasMessageParameters") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByNullPointerExceptionHasMessageParameters).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByNullPointerExceptionHasMessageParameters() {
-  return assertThatNullPointerException().isThrownBy(() -> {}).withMessage("foo %s", "bar");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(NullPointerException.class)
+      .hasMessage("foo %s", "bar");
 }

AssertThatThrownByNullPointerExceptionHasMessageStartingWith

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByNullPointerExceptionHasMessageStartingWith") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByNullPointerExceptionHasMessageStartingWith).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByNullPointerExceptionHasMessageStartingWith() {
-  return assertThatNullPointerException().isThrownBy(() -> {}).withMessageStartingWith("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(NullPointerException.class)
+      .hasMessageStartingWith("foo");
 }

AssertThatThrownByNullPointerExceptionHasMessageContaining

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByNullPointerExceptionHasMessageContaining") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByNullPointerExceptionHasMessageContaining).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByNullPointerExceptionHasMessageContaining() {
-  return assertThatNullPointerException().isThrownBy(() -> {}).withMessageContaining("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(NullPointerException.class)
+      .hasMessageContaining("foo");
 }

AssertThatThrownByNullPointerExceptionHasMessageNotContaining

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByNullPointerExceptionHasMessageNotContaining") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByNullPointerExceptionHasMessageNotContaining).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByNullPointerExceptionHasMessageNotContaining() {
-  return assertThatNullPointerException().isThrownBy(() -> {}).withMessageNotContaining("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(NullPointerException.class)
+      .hasMessageNotContaining("foo");
 }

AssertThatThrownByIOException

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIOException") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIOException).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIOException() {
-  return assertThatIOException().isThrownBy(() -> {});
+  return assertThatThrownBy(() -> {}).isInstanceOf(IOException.class);
 }

AssertThatThrownByIOExceptionHasMessage

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIOExceptionHasMessage") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIOExceptionHasMessage).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIOExceptionHasMessage() {
-  return assertThatIOException().isThrownBy(() -> {}).withMessage("foo");
+  return assertThatThrownBy(() -> {}).isInstanceOf(IOException.class).hasMessage("foo");
 }

AssertThatThrownByIOExceptionHasMessageParameters

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIOExceptionHasMessageParameters") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIOExceptionHasMessageParameters).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIOExceptionHasMessageParameters() {
-  return assertThatIOException().isThrownBy(() -> {}).withMessage("foo %s", "bar");
+  return assertThatThrownBy(() -> {}).isInstanceOf(IOException.class).hasMessage("foo %s", "bar");
 }

AssertThatThrownByIOExceptionHasMessageStartingWith

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIOExceptionHasMessageStartingWith") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIOExceptionHasMessageStartingWith).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIOExceptionHasMessageStartingWith() {
-  return assertThatIOException().isThrownBy(() -> {}).withMessageStartingWith("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IOException.class)
+      .hasMessageStartingWith("foo");
 }

AssertThatThrownByIOExceptionHasMessageContaining

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIOExceptionHasMessageContaining") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIOExceptionHasMessageContaining).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIOExceptionHasMessageContaining() {
-  return assertThatIOException().isThrownBy(() -> {}).withMessageContaining("foo");
+  return assertThatThrownBy(() -> {}).isInstanceOf(IOException.class).hasMessageContaining("foo");
 }

AssertThatThrownByIOExceptionHasMessageNotContaining

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByIOExceptionHasMessageNotContaining") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByIOExceptionHasMessageNotContaining).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByIOExceptionHasMessageNotContaining() {
-  return assertThatIOException().isThrownBy(() -> {}).withMessageNotContaining("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IOException.class)
+      .hasMessageNotContaining("foo");
 }

AssertThatThrownBy

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownBy") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownBy).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownBy() {
-  return assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {});
+  return assertThatThrownBy(() -> {}).isInstanceOf(IllegalArgumentException.class);
 }

AssertThatThrownByHasMessage

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByHasMessage") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByHasMessage).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByHasMessage() {
-  return assertThatExceptionOfType(IllegalArgumentException.class)
-      .isThrownBy(() -> {})
-      .withMessage("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalArgumentException.class)
+      .hasMessage("foo");
 }

AssertThatThrownByHasMessageParameters

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByHasMessageParameters") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByHasMessageParameters).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByHasMessageParameters() {
-  return assertThatExceptionOfType(IllegalArgumentException.class)
-      .isThrownBy(() -> {})
-      .withMessage("foo %s", "bar");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalArgumentException.class)
+      .hasMessage("foo %s", "bar");
 }

AssertThatThrownByHasMessageStartingWith

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByHasMessageStartingWith") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByHasMessageStartingWith).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByHasMessageStartingWith() {
-  return assertThatExceptionOfType(IllegalArgumentException.class)
-      .isThrownBy(() -> {})
-      .withMessageStartingWith("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalArgumentException.class)
+      .hasMessageStartingWith("foo");
 }

AssertThatThrownByHasMessageContaining

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByHasMessageContaining") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByHasMessageContaining).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByHasMessageContaining() {
-  return assertThatExceptionOfType(IllegalArgumentException.class)
-      .isThrownBy(() -> {})
-      .withMessageContaining("foo");
+  return assertThatThrownBy(() -> {})
+      .isInstanceOf(IllegalArgumentException.class)
+      .hasMessageContaining("foo");
 }

AssertThatThrownByHasMessageNotContaining

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatThrownByHasMessageNotContaining") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJThrowingCallableRules\$AssertThatThrownByHasMessageNotContaining).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractObjectAssert<?, ?> testAssertThatThrownByHasMessageNotContaining() {
-  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(String.format("foo %s", "bar")),
+          .hasMessage("foo %s", "bar"),
       assertThatThrownBy(() -> {})
           .isInstanceOf(IllegalArgumentException.class)
-          .hasMessage(String.format("foo %s %s", "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(String.format("foo %s", "bar")),
+          .withFailMessage("foo %s", "bar"),
       assertThatThrownBy(() -> {})
           .isInstanceOf(IllegalArgumentException.class)
-          .withFailMessage(String.format("foo %s %s", "bar", 1)));
+          .withFailMessage("foo %s %s", "bar", 1));
 }

Copyright © 2017-2024 Picnic Technologies BV