TestNGToAssertJRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. Fail
  2. FailWithString
  3. FailWithStringAndThrowable
  4. AssertThatIsTrue
  5. AssertThatWithFailMessageIsTrue
  6. AssertThatIsFalse
  7. AssertThatWithFailMessageIsFalse
  8. AssertThatIsNull
  9. AssertThatWithFailMessageIsNull
  10. AssertThatIsNotNull
  11. AssertThatWithFailMessageIsNotNull
  12. AssertThatIsSameAs
  13. AssertThatWithFailMessageIsSameAs
  14. AssertThatIsNotSameAs
  15. AssertThatWithFailMessageIsNotSameAs
  16. AssertThatIsEqualTo
  17. AssertThatWithFailMessageIsEqualTo
  18. AssertThatIsCloseToOffsetFloat
  19. AssertThatWithFailMessageIsCloseToOffsetFloat
  20. AssertThatIsCloseToOffsetDouble
  21. AssertThatWithFailMessageIsCloseToOffsetDouble
  22. AssertThatContainsExactly
  23. AssertThatWithFailMessageContainsExactly
  24. AssertThatContainsExactlyOffsetFloat
  25. AssertThatWithFailMessageContainsExactlyOffsetFloat
  26. AssertThatContainsExactlyOffsetDouble
  27. AssertThatWithFailMessageContainsExactlyOffsetDouble
  28. AssertThatContainsExactlyInAnyOrder
  29. AssertThatWithFailMessageContainsExactlyInAnyOrder
  30. AssertThatToIterableContainsExactlyElementsOfImmutableListCopyOf
  31. AssertThatToIterableWithFailMessageContainsExactlyElementsOfImmutableListCopyOf
  32. AssertThatContainsExactlyElementsOf
  33. AssertThatWithFailMessageContainsExactlyElementsOf
  34. AssertThatHasSameElementsAs
  35. AssertThatWithFailMessageHasSameElementsAs
  36. AssertThatIsNotEqualTo
  37. AssertThatWithFailMessageIsNotEqualTo
  38. AssertThatIsNotCloseToOffsetFloat
  39. AssertThatWithFailMessageIsNotCloseToOffsetFloat
  40. AssertThatIsNotCloseToOffsetDouble
  41. AssertThatWithFailMessageIsNotCloseToOffsetDouble
  42. AssertThatThrownBy
  43. AssertThatThrownByIsInstanceOf

Fail

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testFail() {
-  org.testng.Assert.fail();
+  fail();
 }

FailWithString

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testFailWithString() {
-  org.testng.Assert.fail("foo");
+  fail("foo");
 }

FailWithStringAndThrowable

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testFailWithStringAndThrowable() {
-  org.testng.Assert.fail("foo", new IllegalStateException());
+  fail("foo", new IllegalStateException());
 }

AssertThatIsTrue

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatIsTrue() {
-  assertTrue(true);
+  assertThat(true).isTrue();
 }

AssertThatWithFailMessageIsTrue

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsTrue() {
-  assertTrue(true, "foo");
+  assertThat(true).withFailMessage("foo").isTrue();
 }

AssertThatIsFalse

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatIsFalse() {
-  assertFalse(true);
+  assertThat(true).isFalse();
 }

AssertThatWithFailMessageIsFalse

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsFalse() {
-  assertFalse(true, "foo");
+  assertThat(true).withFailMessage("foo").isFalse();
 }

AssertThatIsNull

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatIsNull() {
-  assertNull(new Object());
+  assertThat(new Object()).isNull();
 }

AssertThatWithFailMessageIsNull

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsNull() {
-  assertNull(new Object(), "foo");
+  assertThat(new Object()).withFailMessage("foo").isNull();
 }

AssertThatIsNotNull

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatIsNotNull() {
-  assertNotNull(new Object());
+  assertThat(new Object()).isNotNull();
 }

AssertThatWithFailMessageIsNotNull

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsNotNull() {
-  assertNotNull(new Object(), "foo");
+  assertThat(new Object()).withFailMessage("foo").isNotNull();
 }

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=^(?!TestNGToAssertJRules\$AssertThatIsSameAs).* as compiler argument.

Samples

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

 void testAssertThatIsSameAs() {
-  assertSame(new Object(), new StringBuilder());
+  assertThat(new Object()).isSameAs(new StringBuilder());
 }

AssertThatWithFailMessageIsSameAs

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsSameAs() {
-  assertSame(new Object(), new StringBuilder(), "foo");
+  assertThat(new Object()).withFailMessage("foo").isSameAs(new StringBuilder());
 }

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=^(?!TestNGToAssertJRules\$AssertThatIsNotSameAs).* as compiler argument.

Samples

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

 void testAssertThatIsNotSameAs() {
-  assertNotSame(new Object(), new StringBuilder());
+  assertThat(new Object()).isNotSameAs(new StringBuilder());
 }

AssertThatWithFailMessageIsNotSameAs

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsNotSameAs() {
-  assertNotSame(new Object(), new StringBuilder(), "foo");
+  assertThat(new Object()).withFailMessage("foo").isNotSameAs(new StringBuilder());
 }

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=^(?!TestNGToAssertJRules\$AssertThatIsEqualTo).* as compiler argument.

Samples

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

 void testAssertThatIsEqualTo() {
-  assertEquals(true, false);
-  assertEquals(true, Boolean.FALSE);
-  assertEquals(Boolean.TRUE, false);
-  assertEquals(Boolean.TRUE, Boolean.FALSE);
-  assertEquals((byte) 0, (byte) 1);
-  assertEquals((byte) 0, Byte.decode("1"));
-  assertEquals(Byte.decode("0"), (byte) 1);
-  assertEquals(Byte.decode("0"), Byte.decode("1"));
-  assertEquals('a', 'b');
-  assertEquals('a', Character.valueOf('b'));
-  assertEquals(Character.valueOf('a'), 'b');
-  assertEquals(Character.valueOf('a'), Character.valueOf('b'));
-  assertEquals((short) 0, (short) 1);
-  assertEquals((short) 0, Short.decode("1"));
-  assertEquals(Short.decode("0"), (short) 1);
-  assertEquals(Short.decode("0"), Short.decode("1"));
-  assertEquals(0, 1);
-  assertEquals(0, Integer.valueOf(1));
-  assertEquals(Integer.valueOf(0), 1);
-  assertEquals(Integer.valueOf(0), Integer.valueOf(1));
-  assertEquals(0L, 1L);
-  assertEquals(0L, Long.valueOf(1));
-  assertEquals(Long.valueOf(0), 1L);
-  assertEquals(Long.valueOf(0), Long.valueOf(1));
-  assertEquals(0.0f, 1.0f);
-  assertEquals(0.0f, Float.valueOf(1.0f));
-  assertEquals(Float.valueOf(0.0f), 1.0f);
-  assertEquals(Float.valueOf(0.0f), Float.valueOf(1.0f));
-  assertEquals(0.0, 1.0);
-  assertEquals(0.0, Double.valueOf(1.0));
-  assertEquals(Double.valueOf(0.0), 1.0);
-  assertEquals(Double.valueOf(0.0), Double.valueOf(1.0));
-  assertEquals(new Object(), new StringBuilder());
-  assertEquals("actual", "expected");
-  assertEquals(ImmutableMap.of(), ImmutableMap.of(1, 2));
+  assertThat(true).isEqualTo(false);
+  assertThat(true).isEqualTo(Boolean.FALSE);
+  assertThat(Boolean.TRUE).isEqualTo(false);
+  assertThat(Boolean.TRUE).isEqualTo(Boolean.FALSE);
+  assertThat((byte) 0).isEqualTo((byte) 1);
+  assertThat((byte) 0).isEqualTo(Byte.decode("1"));
+  assertThat(Byte.decode("0")).isEqualTo((byte) 1);
+  assertThat(Byte.decode("0")).isEqualTo(Byte.decode("1"));
+  assertThat('a').isEqualTo('b');
+  assertThat('a').isEqualTo(Character.valueOf('b'));
+  assertThat(Character.valueOf('a')).isEqualTo('b');
+  assertThat(Character.valueOf('a')).isEqualTo(Character.valueOf('b'));
+  assertThat((short) 0).isEqualTo((short) 1);
+  assertThat((short) 0).isEqualTo(Short.decode("1"));
+  assertThat(Short.decode("0")).isEqualTo((short) 1);
+  assertThat(Short.decode("0")).isEqualTo(Short.decode("1"));
+  assertThat(0).isEqualTo(1);
+  assertThat(0).isEqualTo(Integer.valueOf(1));
+  assertThat(Integer.valueOf(0)).isEqualTo(1);
+  assertThat(Integer.valueOf(0)).isEqualTo(Integer.valueOf(1));
+  assertThat(0L).isEqualTo(1L);
+  assertThat(0L).isEqualTo(Long.valueOf(1));
+  assertThat(Long.valueOf(0)).isEqualTo(1L);
+  assertThat(Long.valueOf(0)).isEqualTo(Long.valueOf(1));
+  assertThat(0.0f).isEqualTo(1.0f);
+  assertThat(0.0f).isEqualTo(Float.valueOf(1.0f));
+  assertThat(Float.valueOf(0.0f)).isEqualTo(1.0f);
+  assertThat(Float.valueOf(0.0f)).isEqualTo(Float.valueOf(1.0f));
+  assertThat(0.0).isEqualTo(1.0);
+  assertThat(0.0).isEqualTo(Double.valueOf(1.0));
+  assertThat(Double.valueOf(0.0)).isEqualTo(1.0);
+  assertThat(Double.valueOf(0.0)).isEqualTo(Double.valueOf(1.0));
+  assertThat(new Object()).isEqualTo(new StringBuilder());
+  assertThat("actual").isEqualTo("expected");
+  assertThat(ImmutableMap.of()).isEqualTo(ImmutableMap.of(1, 2));
 }

AssertThatWithFailMessageIsEqualTo

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsEqualTo() {
-  assertEquals(true, false, "foo");
-  assertEquals(true, Boolean.FALSE, "bar");
-  assertEquals(Boolean.TRUE, false, "baz");
-  assertEquals(Boolean.TRUE, Boolean.FALSE, "qux");
-  assertEquals((byte) 0, (byte) 1, "quux");
-  assertEquals((byte) 0, Byte.decode("1"), "corge");
-  assertEquals(Byte.decode("0"), (byte) 1, "grault");
-  assertEquals(Byte.decode("0"), Byte.decode("1"), "garply");
-  assertEquals('a', 'b', "waldo");
-  assertEquals('a', Character.valueOf('b'), "fred");
-  assertEquals(Character.valueOf('a'), 'b', "plugh");
-  assertEquals(Character.valueOf('a'), Character.valueOf('b'), "xyzzy");
-  assertEquals((short) 0, (short) 1, "thud");
-  assertEquals((short) 0, Short.decode("1"), "foo");
-  assertEquals(Short.decode("0"), (short) 1, "bar");
-  assertEquals(Short.decode("0"), Short.decode("1"), "baz");
-  assertEquals(0, 1, "qux");
-  assertEquals(0, Integer.valueOf(1), "quux");
-  assertEquals(Integer.valueOf(0), 1, "corge");
-  assertEquals(Integer.valueOf(0), Integer.valueOf(1), "grault");
-  assertEquals(0L, 1L, "garply");
-  assertEquals(0L, Long.valueOf(1), "waldo");
-  assertEquals(Long.valueOf(0), 1L, "fred");
-  assertEquals(Long.valueOf(0), Long.valueOf(1), "plugh");
-  assertEquals(0.0f, 1.0f, "xyzzy");
-  assertEquals(0.0f, Float.valueOf(1.0f), "thud");
-  assertEquals(Float.valueOf(0.0f), 1.0f, "foo");
-  assertEquals(Float.valueOf(0.0f), Float.valueOf(1.0f), "bar");
-  assertEquals(0.0, 1.0, "baz");
-  assertEquals(0.0, Double.valueOf(1.0), "qux");
-  assertEquals(Double.valueOf(0.0), 1.0, "quux");
-  assertEquals(Double.valueOf(0.0), Double.valueOf(1.0), "corge");
-  assertEquals(new Object(), new StringBuilder(), "grault");
-  assertEquals("actual", "expected", "garply");
-  assertEquals(ImmutableMap.of(), ImmutableMap.of(1, 2), "waldo");
+  assertThat(true).withFailMessage("foo").isEqualTo(false);
+  assertThat(true).withFailMessage("bar").isEqualTo(Boolean.FALSE);
+  assertThat(Boolean.TRUE).withFailMessage("baz").isEqualTo(false);
+  assertThat(Boolean.TRUE).withFailMessage("qux").isEqualTo(Boolean.FALSE);
+  assertThat((byte) 0).withFailMessage("quux").isEqualTo((byte) 1);
+  assertThat((byte) 0).withFailMessage("corge").isEqualTo(Byte.decode("1"));
+  assertThat(Byte.decode("0")).withFailMessage("grault").isEqualTo((byte) 1);
+  assertThat(Byte.decode("0")).withFailMessage("garply").isEqualTo(Byte.decode("1"));
+  assertThat('a').withFailMessage("waldo").isEqualTo('b');
+  assertThat('a').withFailMessage("fred").isEqualTo(Character.valueOf('b'));
+  assertThat(Character.valueOf('a')).withFailMessage("plugh").isEqualTo('b');
+  assertThat(Character.valueOf('a')).withFailMessage("xyzzy").isEqualTo(Character.valueOf('b'));
+  assertThat((short) 0).withFailMessage("thud").isEqualTo((short) 1);
+  assertThat((short) 0).withFailMessage("foo").isEqualTo(Short.decode("1"));
+  assertThat(Short.decode("0")).withFailMessage("bar").isEqualTo((short) 1);
+  assertThat(Short.decode("0")).withFailMessage("baz").isEqualTo(Short.decode("1"));
+  assertThat(0).withFailMessage("qux").isEqualTo(1);
+  assertThat(0).withFailMessage("quux").isEqualTo(Integer.valueOf(1));
+  assertThat(Integer.valueOf(0)).withFailMessage("corge").isEqualTo(1);
+  assertThat(Integer.valueOf(0)).withFailMessage("grault").isEqualTo(Integer.valueOf(1));
+  assertThat(0L).withFailMessage("garply").isEqualTo(1L);
+  assertThat(0L).withFailMessage("waldo").isEqualTo(Long.valueOf(1));
+  assertThat(Long.valueOf(0)).withFailMessage("fred").isEqualTo(1L);
+  assertThat(Long.valueOf(0)).withFailMessage("plugh").isEqualTo(Long.valueOf(1));
+  assertThat(0.0f).withFailMessage("xyzzy").isEqualTo(1.0f);
+  assertThat(0.0f).withFailMessage("thud").isEqualTo(Float.valueOf(1.0f));
+  assertThat(Float.valueOf(0.0f)).withFailMessage("foo").isEqualTo(1.0f);
+  assertThat(Float.valueOf(0.0f)).withFailMessage("bar").isEqualTo(Float.valueOf(1.0f));
+  assertThat(0.0).withFailMessage("baz").isEqualTo(1.0);
+  assertThat(0.0).withFailMessage("qux").isEqualTo(Double.valueOf(1.0));
+  assertThat(Double.valueOf(0.0)).withFailMessage("quux").isEqualTo(1.0);
+  assertThat(Double.valueOf(0.0)).withFailMessage("corge").isEqualTo(Double.valueOf(1.0));
+  assertThat(new Object()).withFailMessage("grault").isEqualTo(new StringBuilder());
+  assertThat("actual").withFailMessage("garply").isEqualTo("expected");
+  assertThat(ImmutableMap.of()).withFailMessage("waldo").isEqualTo(ImmutableMap.of(1, 2));
 }

AssertThatIsCloseToOffsetFloat

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatIsCloseToOffsetFloat() {
-  assertEquals(1.0f, 2.0f, 0.0f);
+  assertThat(1.0f).isCloseTo(2.0f, offset(0.0f));
 }

AssertThatWithFailMessageIsCloseToOffsetFloat

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsCloseToOffsetFloat() {
-  assertEquals(1.0f, 2.0f, 0.0f, "foo");
+  assertThat(1.0f).withFailMessage("foo").isCloseTo(2.0f, offset(0.0f));
 }

AssertThatIsCloseToOffsetDouble

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatIsCloseToOffsetDouble() {
-  assertEquals(1.0, 2.0, 0.0);
+  assertThat(1.0).isCloseTo(2.0, offset(0.0));
 }

AssertThatWithFailMessageIsCloseToOffsetDouble

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsCloseToOffsetDouble() {
-  assertEquals(1.0, 2.0, 0.0, "foo");
+  assertThat(1.0).withFailMessage("foo").isCloseTo(2.0, offset(0.0));
 }

AssertThatContainsExactly

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatContainsExactly() {
-  assertEquals(new boolean[] {false}, new boolean[] {true});
-  assertEquals(new byte[] {2}, new byte[] {1});
-  assertEquals(new char[] {'b'}, new char[] {'a'});
-  assertEquals(new short[] {2}, new short[] {1});
-  assertEquals(new int[] {2}, new int[] {1});
-  assertEquals(new long[] {2L}, new long[] {1L});
-  assertEquals(new float[] {2.0f}, new float[] {1.0f});
-  assertEquals(new double[] {2.0}, new double[] {1.0});
-  assertEquals(new Object[] {"bar"}, new Object[] {"foo"});
+  assertThat(new boolean[] {false}).containsExactly(new boolean[] {true});
+  assertThat(new byte[] {2}).containsExactly(new byte[] {1});
+  assertThat(new char[] {'b'}).containsExactly(new char[] {'a'});
+  assertThat(new short[] {2}).containsExactly(new short[] {1});
+  assertThat(new int[] {2}).containsExactly(new int[] {1});
+  assertThat(new long[] {2L}).containsExactly(new long[] {1L});
+  assertThat(new float[] {2.0f}).containsExactly(new float[] {1.0f});
+  assertThat(new double[] {2.0}).containsExactly(new double[] {1.0});
+  assertThat(new Object[] {"bar"}).containsExactly(new Object[] {"foo"});
 }

AssertThatWithFailMessageContainsExactly

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageContainsExactly() {
-  assertEquals(new boolean[] {false}, new boolean[] {true}, "foo");
-  assertEquals(new byte[] {2}, new byte[] {1}, "bar");
-  assertEquals(new char[] {'b'}, new char[] {'a'}, "baz");
-  assertEquals(new short[] {2}, new short[] {1}, "qux");
-  assertEquals(new int[] {2}, new int[] {1}, "quux");
-  assertEquals(new long[] {2L}, new long[] {1L}, "corge");
-  assertEquals(new float[] {2.0f}, new float[] {1.0f}, "grault");
-  assertEquals(new double[] {2.0}, new double[] {1.0}, "garply");
-  assertEquals(new Object[] {"bar"}, new Object[] {"foo"}, "waldo");
+  assertThat(new boolean[] {false}).withFailMessage("foo").containsExactly(new boolean[] {true});
+  assertThat(new byte[] {2}).withFailMessage("bar").containsExactly(new byte[] {1});
+  assertThat(new char[] {'b'}).withFailMessage("baz").containsExactly(new char[] {'a'});
+  assertThat(new short[] {2}).withFailMessage("qux").containsExactly(new short[] {1});
+  assertThat(new int[] {2}).withFailMessage("quux").containsExactly(new int[] {1});
+  assertThat(new long[] {2L}).withFailMessage("corge").containsExactly(new long[] {1L});
+  assertThat(new float[] {2.0f}).withFailMessage("grault").containsExactly(new float[] {1.0f});
+  assertThat(new double[] {2.0}).withFailMessage("garply").containsExactly(new double[] {1.0});
+  assertThat(new Object[] {"bar"}).withFailMessage("waldo").containsExactly(new Object[] {"foo"});
 }

AssertThatContainsExactlyOffsetFloat

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatContainsExactlyOffsetFloat() {
-  assertEquals(new float[] {2.0f}, new float[] {1.0f}, 0.0f);
+  assertThat(new float[] {2.0f}).containsExactly(new float[] {1.0f}, offset(0.0f));
 }

AssertThatWithFailMessageContainsExactlyOffsetFloat

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageContainsExactlyOffsetFloat() {
-  assertEquals(new float[] {2.0f}, new float[] {1.0f}, 0.0f, "foo");
+  assertThat(new float[] {2.0f})
+      .withFailMessage("foo")
+      .containsExactly(new float[] {1.0f}, offset(0.0f));
 }

AssertThatContainsExactlyOffsetDouble

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatContainsExactlyOffsetDouble() {
-  assertEquals(new double[] {2.0}, new double[] {1.0}, 0.0);
+  assertThat(new double[] {2.0}).containsExactly(new double[] {1.0}, offset(0.0));
 }

AssertThatWithFailMessageContainsExactlyOffsetDouble

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageContainsExactlyOffsetDouble() {
-  assertEquals(new double[] {2.0}, new double[] {1.0}, 0.0, "foo");
+  assertThat(new double[] {2.0})
+      .withFailMessage("foo")
+      .containsExactly(new double[] {1.0}, offset(0.0));
 }

AssertThatContainsExactlyInAnyOrder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatContainsExactlyInAnyOrder() {
-  assertEqualsNoOrder(new Object[] {"bar"}, new Object[] {"foo"});
+  assertThat(new Object[] {"bar"}).containsExactlyInAnyOrder(new Object[] {"foo"});
 }

AssertThatWithFailMessageContainsExactlyInAnyOrder

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageContainsExactlyInAnyOrder() {
-  assertEqualsNoOrder(new Object[] {"bar"}, new Object[] {"foo"}, "foo");
+  assertThat(new Object[] {"bar"})
+      .withFailMessage("foo")
+      .containsExactlyInAnyOrder(new Object[] {"foo"});
 }

AssertThatToIterableContainsExactlyElementsOfImmutableListCopyOf

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatToIterableContainsExactlyElementsOfImmutableListCopyOf() {
-  assertEquals(new ArrayList<Number>().iterator(), new ArrayList<Integer>().iterator());
+  assertThat(new ArrayList<Number>().iterator())
+      .toIterable()
+      .containsExactlyElementsOf(copyOf(new ArrayList<Integer>().iterator()));
   assertEquals(new ArrayList<Number>().iterator(), new ArrayList<String>().iterator());
 }

AssertThatToIterableWithFailMessageContainsExactlyElementsOfImmutableListCopyOf

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatToIterableWithFailMessageContainsExactlyElementsOfImmutableListCopyOf() {
-  assertEquals(new ArrayList<Number>().iterator(), new ArrayList<Integer>().iterator(), "foo");
+  assertThat(new ArrayList<Number>().iterator())
+      .toIterable()
+      .withFailMessage("foo")
+      .containsExactlyElementsOf(copyOf(new ArrayList<Integer>().iterator()));
   assertEquals(new ArrayList<Number>().iterator(), new ArrayList<String>().iterator(), "bar");
 }

AssertThatContainsExactlyElementsOf

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatContainsExactlyElementsOf() {
+  assertThat(Iterables.unmodifiableIterable(new ArrayList<Number>()))
+      .containsExactlyElementsOf(Iterables.unmodifiableIterable(new ArrayList<Integer>()));
   assertEquals(
       Iterables.unmodifiableIterable(new ArrayList<Number>()),
-      Iterables.unmodifiableIterable(new ArrayList<Integer>()));
-  assertEquals(
-      Iterables.unmodifiableIterable(new ArrayList<Number>()),
       Iterables.unmodifiableIterable(new ArrayList<String>()));
-  assertEquals(new ArrayList<Number>(), new ArrayList<Integer>());
+  assertThat(new ArrayList<Number>()).containsExactlyElementsOf(new ArrayList<Integer>());
   assertEquals(new ArrayList<Number>(), new ArrayList<String>());
 }

AssertThatWithFailMessageContainsExactlyElementsOf

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageContainsExactlyElementsOf() {
+  assertThat(Iterables.unmodifiableIterable(new ArrayList<Number>()))
+      .withFailMessage("foo")
+      .containsExactlyElementsOf(Iterables.unmodifiableIterable(new ArrayList<Integer>()));
   assertEquals(
       Iterables.unmodifiableIterable(new ArrayList<Number>()),
-      Iterables.unmodifiableIterable(new ArrayList<Integer>()),
-      "foo");
-  assertEquals(
-      Iterables.unmodifiableIterable(new ArrayList<Number>()),
       Iterables.unmodifiableIterable(new ArrayList<String>()),
       "bar");
-  assertEquals(new ArrayList<Number>(), new ArrayList<Integer>(), "baz");
+  assertThat(new ArrayList<Number>())
+      .withFailMessage("baz")
+      .containsExactlyElementsOf(new ArrayList<Integer>());
   assertEquals(new ArrayList<Number>(), new ArrayList<String>(), "qux");
 }

AssertThatHasSameElementsAs

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatHasSameElementsAs() {
-  assertEquals(ImmutableSet.<Number>of(), ImmutableSet.<Integer>of());
+  assertThat(ImmutableSet.<Number>of()).hasSameElementsAs(ImmutableSet.<Integer>of());
   assertEquals(ImmutableSet.<Number>of(), ImmutableSet.<String>of());
 }

AssertThatWithFailMessageHasSameElementsAs

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageHasSameElementsAs() {
-  assertEquals(ImmutableSet.<Number>of(), ImmutableSet.<Integer>of(), "foo");
+  assertThat(ImmutableSet.<Number>of())
+      .withFailMessage("foo")
+      .hasSameElementsAs(ImmutableSet.<Integer>of());
   assertEquals(ImmutableSet.<Number>of(), ImmutableSet.<String>of(), "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=^(?!TestNGToAssertJRules\$AssertThatIsNotEqualTo).* as compiler argument.

Samples

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

 void testAssertThatIsNotEqualTo() {
-  assertNotEquals(true, false);
-  assertNotEquals((byte) 0, (byte) 1);
-  assertNotEquals('a', 'b');
-  assertNotEquals((short) 0, (short) 1);
-  assertNotEquals(0, 1);
-  assertNotEquals(0L, 1L);
-  assertNotEquals(0.0f, 1.0f);
-  assertNotEquals(0.0, 1.0);
-  assertNotEquals(new Object(), new StringBuilder());
-  assertNotEquals("foo", "bar");
-  assertNotEquals(ImmutableSet.of(), ImmutableSet.of(1));
-  assertNotEquals(ImmutableMap.of(), ImmutableMap.of(1, 2));
+  assertThat(true).isNotEqualTo(false);
+  assertThat((byte) 0).isNotEqualTo((byte) 1);
+  assertThat('a').isNotEqualTo('b');
+  assertThat((short) 0).isNotEqualTo((short) 1);
+  assertThat(0).isNotEqualTo(1);
+  assertThat(0L).isNotEqualTo(1L);
+  assertThat(0.0f).isNotEqualTo(1.0f);
+  assertThat(0.0).isNotEqualTo(1.0);
+  assertThat(new Object()).isNotEqualTo(new StringBuilder());
+  assertThat("foo").isNotEqualTo("bar");
+  assertThat(ImmutableSet.of()).isNotEqualTo(ImmutableSet.of(1));
+  assertThat(ImmutableMap.of()).isNotEqualTo(ImmutableMap.of(1, 2));
 }

AssertThatWithFailMessageIsNotEqualTo

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsNotEqualTo() {
-  assertNotEquals(true, false, "foo");
-  assertNotEquals((byte) 0, (byte) 1, "bar");
-  assertNotEquals('a', 'b', "baz");
-  assertNotEquals((short) 0, (short) 1, "qux");
-  assertNotEquals(0, 1, "quux");
-  assertNotEquals(0L, 1L, "corge");
-  assertNotEquals(0.0f, 1.0f, "grault");
-  assertNotEquals(0.0, 1.0, "garply");
-  assertNotEquals(new Object(), new StringBuilder(), "waldo");
-  assertNotEquals("foo", "bar", "fred");
-  assertNotEquals(ImmutableSet.of(), ImmutableSet.of(1), "plugh");
-  assertNotEquals(ImmutableMap.of(), ImmutableMap.of(1, 2), "xyzzy");
+  assertThat(true).withFailMessage("foo").isNotEqualTo(false);
+  assertThat((byte) 0).withFailMessage("bar").isNotEqualTo((byte) 1);
+  assertThat('a').withFailMessage("baz").isNotEqualTo('b');
+  assertThat((short) 0).withFailMessage("qux").isNotEqualTo((short) 1);
+  assertThat(0).withFailMessage("quux").isNotEqualTo(1);
+  assertThat(0L).withFailMessage("corge").isNotEqualTo(1L);
+  assertThat(0.0f).withFailMessage("grault").isNotEqualTo(1.0f);
+  assertThat(0.0).withFailMessage("garply").isNotEqualTo(1.0);
+  assertThat(new Object()).withFailMessage("waldo").isNotEqualTo(new StringBuilder());
+  assertThat("foo").withFailMessage("fred").isNotEqualTo("bar");
+  assertThat(ImmutableSet.of()).withFailMessage("plugh").isNotEqualTo(ImmutableSet.of(1));
+  assertThat(ImmutableMap.of()).withFailMessage("xyzzy").isNotEqualTo(ImmutableMap.of(1, 2));
 }

AssertThatIsNotCloseToOffsetFloat

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatIsNotCloseToOffsetFloat() {
-  assertNotEquals(1.0f, 2.0f, 0.0f);
+  assertThat(1.0f).isNotCloseTo(2.0f, offset(0.0f));
 }

AssertThatWithFailMessageIsNotCloseToOffsetFloat

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsNotCloseToOffsetFloat() {
-  assertNotEquals(1.0f, 2.0f, 0.0f, "foo");
+  assertThat(1.0f).withFailMessage("foo").isNotCloseTo(2.0f, offset(0.0f));
 }

AssertThatIsNotCloseToOffsetDouble

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatIsNotCloseToOffsetDouble() {
-  assertNotEquals(1.0, 2.0, 0.0);
+  assertThat(1.0).isNotCloseTo(2.0, offset(0.0));
 }

AssertThatWithFailMessageIsNotCloseToOffsetDouble

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatWithFailMessageIsNotCloseToOffsetDouble() {
-  assertNotEquals(1.0, 2.0, 0.0, "foo");
+  assertThat(1.0).withFailMessage("foo").isNotCloseTo(2.0, offset(0.0));
 }

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=^(?!TestNGToAssertJRules\$AssertThatThrownBy).* as compiler argument.

Samples

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

 void testAssertThatThrownBy() {
   assertThrows((ThrowingRunnable) null);
-  assertThrows(() -> {});
+  assertThatThrownBy(() -> {});
 }

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=^(?!TestNGToAssertJRules\$AssertThatThrownByIsInstanceOf).* as compiler argument.

Samples

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

 void testAssertThatThrownByIsInstanceOf() {
   assertThrows(IllegalStateException.class, (ThrowingRunnable) null);
-  assertThrows(IllegalStateException.class, () -> {});
+  assertThatThrownBy(() -> {}).isInstanceOf(IllegalStateException.class);
 }

Copyright © 2017-2026 Picnic Technologies BV