Skip to main content Link Search Menu Expand Document (external link)

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. AssertThatThrownByIOException
  18. AssertThatThrownByIOExceptionHasMessage
  19. AssertThatThrownByIOExceptionHasMessageParameters
  20. AssertThatThrownBy
  21. AssertThatThrownByHasMessage
  22. AssertThatThrownByHasMessageParameters
  23. AbstractThrowableAssertHasMessage
  24. 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");
   }

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");
   }

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");
   }

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-2023 Picnic Technologies BV