AssertJObjectRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. AssertThatIsInstanceOfClass
  2. AssertThatIsInstanceOf
  3. AssertThatIsNotInstanceOfClass
  4. AssertThatIsEqualTo
  5. AssertThatIsNotEqualTo
  6. AssertThatHasToString
  7. AssertThatIsSameAs
  8. AssertThatIsNotSameAs
  9. AssertThatHasSameHashCodeAs

AssertThatIsInstanceOfClass

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatIsInstanceOfClass() {
-  return assertThat("foo" instanceof String).isTrue();
+  return assertThat("foo").isInstanceOf(String.class);
 }

AssertThatIsInstanceOf

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatIsInstanceOf() {
-  return assertThat(String.class.isInstance("foo")).isTrue();
+  return assertThat("foo").isInstanceOf(String.class);
 }

AssertThatIsNotInstanceOfClass

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatIsNotInstanceOfClass() {
-  return assertThat("foo" instanceof String).isFalse();
+  return assertThat("foo").isNotInstanceOf(String.class);
 }

AssertThatIsEqualTo

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatIsEqualTo() {
-  return assertThat("foo".equals("bar")).isTrue();
+  return assertThat("foo").isEqualTo("bar");
 }

AssertThatIsNotEqualTo

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatIsNotEqualTo() {
-  return assertThat("foo".equals("bar")).isFalse();
+  return assertThat("foo").isNotEqualTo("bar");
 }

AssertThatHasToString

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatHasToString() {
-  return assertThat(new Object().toString()).isEqualTo("foo");
+  return assertThat(new Object()).hasToString("foo");
 }

AssertThatIsSameAs

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsSameAs() {
   return ImmutableSet.of(
       assertThat(null == "foo").isTrue(),
-      assertThat("bar" == "baz").isTrue(),
+      assertThat("bar").isSameAs("baz"),
       assertThat(null != "qux").isFalse(),
-      assertThat("quux" != "corge").isFalse());
+      assertThat("quux").isSameAs("corge"));
 }

AssertThatIsNotSameAs

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsNotSameAs() {
   return ImmutableSet.of(
       assertThat(null == "foo").isFalse(),
-      assertThat("bar" == "baz").isFalse(),
+      assertThat("bar").isNotSameAs("baz"),
       assertThat(null != "qux").isTrue(),
-      assertThat("quux" != "corge").isTrue());
+      assertThat("quux").isNotSameAs("corge"));
 }

AssertThatHasSameHashCodeAs

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatHasSameHashCodeAs() {
-  return assertThat("foo".hashCode()).isEqualTo("bar".hashCode());
+  return assertThat("foo").hasSameHashCodeAs("bar");
 }

Copyright © 2017-2026 Picnic Technologies BV