TestNGToAssertJRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$).*
as compiler argument.
Table of contents
- Fail
- FailWithMessage
- FailWithMessageAndThrowable
- AssertTrue
- AssertTrueWithMessage
- AssertFalse
- AssertFalseWithMessage
- AssertNull
- AssertNullWithMessage
- AssertNotNull
- AssertNotNullWithMessage
- AssertSame
- AssertSameWithMessage
- AssertNotSame
- AssertNotSameWithMessage
- AssertEqual
- AssertEqualWithMessage
- AssertEqualFloatsWithDelta
- AssertEqualFloatsWithDeltaWithMessage
- AssertEqualDoublesWithDelta
- AssertEqualDoublesWithDeltaWithMessage
- AssertEqualArrayIterationOrder
- AssertEqualArrayIterationOrderWithMessage
- AssertEqualFloatArraysWithDelta
- AssertEqualFloatArraysWithDeltaWithMessage
- AssertEqualDoubleArraysWithDelta
- AssertEqualDoubleArraysWithDeltaWithMessage
- AssertEqualArraysIrrespectiveOfOrder
- AssertEqualArraysIrrespectiveOfOrderWithMessage
- AssertEqualIteratorIterationOrder
- AssertEqualIteratorIterationOrderWithMessage
- AssertEqualIterableIterationOrder
- AssertEqualIterableIterationOrderWithMessage
- AssertEqualSets
- AssertEqualSetsWithMessage
- AssertUnequal
- AssertUnequalWithMessage
- AssertUnequalFloatsWithDelta
- AssertUnequalFloatsWithDeltaWithMessage
- AssertUnequalDoublesWithDelta
- AssertUnequalDoublesWithDeltaWithMessage
- AssertThrows
- AssertThrowsWithType
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();
}
FailWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("FailWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$FailWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testFailWithMessage() {
- org.testng.Assert.fail("foo");
+ fail("foo");
}
FailWithMessageAndThrowable
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("FailWithMessageAndThrowable")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$FailWithMessageAndThrowable).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testFailWithMessageAndThrowable() {
- org.testng.Assert.fail("foo", new IllegalStateException());
+ fail("foo", new IllegalStateException());
}
AssertTrue
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertTrue")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertTrue).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertTrue() {
- assertTrue(true);
+ assertThat(true).isTrue();
}
AssertTrueWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertTrueWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertTrueWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertTrueWithMessage() {
- assertTrue(true, "foo");
+ assertThat(true).withFailMessage("foo").isTrue();
}
AssertFalse
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertFalse")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertFalse).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertFalse() {
- assertFalse(true);
+ assertThat(true).isFalse();
}
AssertFalseWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertFalseWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertFalseWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertFalseWithMessage() {
- assertFalse(true, "message");
+ assertThat(true).withFailMessage("message").isFalse();
}
AssertNull
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertNull")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertNull).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertNull() {
- assertNull(new Object());
+ assertThat(new Object()).isNull();
}
AssertNullWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertNullWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertNullWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertNullWithMessage() {
- assertNull(new Object(), "foo");
+ assertThat(new Object()).withFailMessage("foo").isNull();
}
AssertNotNull
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertNotNull")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertNotNull).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertNotNull() {
- assertNotNull(new Object());
+ assertThat(new Object()).isNotNull();
}
AssertNotNullWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertNotNullWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertNotNullWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertNotNullWithMessage() {
- assertNotNull(new Object(), "foo");
+ assertThat(new Object()).withFailMessage("foo").isNotNull();
}
AssertSame
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertSame")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertSame).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertSame() {
- assertSame(new Object(), new Object());
+ assertThat(new Object()).isSameAs(new Object());
}
AssertSameWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertSameWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertSameWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertSameWithMessage() {
- assertSame(new Object(), new Object(), "foo");
+ assertThat(new Object()).withFailMessage("foo").isSameAs(new Object());
}
AssertNotSame
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertNotSame")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertNotSame).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertNotSame() {
- assertNotSame(new Object(), new Object());
+ assertThat(new Object()).isNotSameAs(new Object());
}
AssertNotSameWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertNotSameWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertNotSameWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertNotSameWithMessage() {
- assertNotSame(new Object(), new Object(), "foo");
+ assertThat(new Object()).withFailMessage("foo").isNotSameAs(new Object());
}
AssertEqual
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqual")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqual).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqual() {
- 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));
}
AssertEqualWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualWithMessage() {
- 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");
+ 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);
// XXX: Ambiguous method call, as the relevant overload is missing. See testng-team/testng#3199.
// 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(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));
}
AssertEqualFloatsWithDelta
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualFloatsWithDelta")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualFloatsWithDelta).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualFloatsWithDelta() {
- assertEquals(0.0F, 0.0F, 0.0F);
+ assertThat(0.0F).isCloseTo(0.0F, offset(0.0F));
}
AssertEqualFloatsWithDeltaWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualFloatsWithDeltaWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualFloatsWithDeltaWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualFloatsWithDeltaWithMessage() {
- assertEquals(0.0F, 0.0F, 0.0F, "foo");
+ assertThat(0.0F).withFailMessage("foo").isCloseTo(0.0F, offset(0.0F));
}
AssertEqualDoublesWithDelta
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualDoublesWithDelta")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualDoublesWithDelta).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualDoublesWithDelta() {
- assertEquals(0.0, 0.0, 0.0);
+ assertThat(0.0).isCloseTo(0.0, offset(0.0));
}
AssertEqualDoublesWithDeltaWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualDoublesWithDeltaWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualDoublesWithDeltaWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualDoublesWithDeltaWithMessage() {
- assertEquals(0.0, 0.0, 0.0, "foo");
+ assertThat(0.0).withFailMessage("foo").isCloseTo(0.0, offset(0.0));
}
AssertEqualArrayIterationOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualArrayIterationOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualArrayIterationOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualArrayIterationOrder() {
- assertEquals(new boolean[0], new boolean[0]);
- assertEquals(new byte[0], new byte[0]);
- assertEquals(new char[0], new char[0]);
- assertEquals(new short[0], new short[0]);
- assertEquals(new int[0], new int[0]);
- assertEquals(new long[0], new long[0]);
- assertEquals(new float[0], new float[0]);
- assertEquals(new double[0], new double[0]);
- assertEquals(new Object[0], new Object[0]);
+ assertThat(new boolean[0]).containsExactly(new boolean[0]);
+ assertThat(new byte[0]).containsExactly(new byte[0]);
+ assertThat(new char[0]).containsExactly(new char[0]);
+ assertThat(new short[0]).containsExactly(new short[0]);
+ assertThat(new int[0]).containsExactly(new int[0]);
+ assertThat(new long[0]).containsExactly(new long[0]);
+ assertThat(new float[0]).containsExactly(new float[0]);
+ assertThat(new double[0]).containsExactly(new double[0]);
+ assertThat(new Object[0]).containsExactly(new Object[0]);
}
AssertEqualArrayIterationOrderWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualArrayIterationOrderWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualArrayIterationOrderWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualArrayIterationOrderWithMessage() {
- assertEquals(new boolean[0], new boolean[0], "foo");
- assertEquals(new byte[0], new byte[0], "bar");
- assertEquals(new char[0], new char[0], "baz");
- assertEquals(new short[0], new short[0], "qux");
- assertEquals(new int[0], new int[0], "quux");
- assertEquals(new long[0], new long[0], "quuz");
- assertEquals(new float[0], new float[0], "corge");
- assertEquals(new double[0], new double[0], "grault");
- assertEquals(new Object[0], new Object[0], "garply");
+ assertThat(new boolean[0]).withFailMessage("foo").containsExactly(new boolean[0]);
+ assertThat(new byte[0]).withFailMessage("bar").containsExactly(new byte[0]);
+ assertThat(new char[0]).withFailMessage("baz").containsExactly(new char[0]);
+ assertThat(new short[0]).withFailMessage("qux").containsExactly(new short[0]);
+ assertThat(new int[0]).withFailMessage("quux").containsExactly(new int[0]);
+ assertThat(new long[0]).withFailMessage("quuz").containsExactly(new long[0]);
+ assertThat(new float[0]).withFailMessage("corge").containsExactly(new float[0]);
+ assertThat(new double[0]).withFailMessage("grault").containsExactly(new double[0]);
+ assertThat(new Object[0]).withFailMessage("garply").containsExactly(new Object[0]);
}
AssertEqualFloatArraysWithDelta
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualFloatArraysWithDelta")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualFloatArraysWithDelta).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualFloatArraysWithDelta() {
- assertEquals(new float[0], new float[0], 0.0F);
+ assertThat(new float[0]).containsExactly(new float[0], offset(0.0F));
}
AssertEqualFloatArraysWithDeltaWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualFloatArraysWithDeltaWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualFloatArraysWithDeltaWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualFloatArraysWithDeltaWithMessage() {
- assertEquals(new float[0], new float[0], 0.0F, "foo");
+ assertThat(new float[0]).withFailMessage("foo").containsExactly(new float[0], offset(0.0F));
}
AssertEqualDoubleArraysWithDelta
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualDoubleArraysWithDelta")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualDoubleArraysWithDelta).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualDoubleArraysWithDelta() {
- assertEquals(new double[0], new double[0], 0.0);
+ assertThat(new double[0]).containsExactly(new double[0], offset(0.0));
}
AssertEqualDoubleArraysWithDeltaWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualDoubleArraysWithDeltaWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualDoubleArraysWithDeltaWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualDoubleArraysWithDeltaWithMessage() {
- assertEquals(new double[0], new double[0], 0.0, "foo");
+ assertThat(new double[0]).withFailMessage("foo").containsExactly(new double[0], offset(0.0));
}
AssertEqualArraysIrrespectiveOfOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualArraysIrrespectiveOfOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualArraysIrrespectiveOfOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualArraysIrrespectiveOfOrder() {
- assertEqualsNoOrder(new Object[0], new Object[0]);
+ assertThat(new Object[0]).containsExactlyInAnyOrder(new Object[0]);
}
AssertEqualArraysIrrespectiveOfOrderWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualArraysIrrespectiveOfOrderWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualArraysIrrespectiveOfOrderWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualArraysIrrespectiveOfOrderWithMessage() {
- assertEqualsNoOrder(new Object[0], new Object[0], "foo");
+ assertThat(new Object[0]).withFailMessage("foo").containsExactlyInAnyOrder(new Object[0]);
}
AssertEqualIteratorIterationOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualIteratorIterationOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualIteratorIterationOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualIteratorIterationOrder() {
- assertEquals(
- Iterators.unmodifiableIterator(new ArrayList<>().iterator()),
- Iterators.unmodifiableIterator(new ArrayList<>().iterator()));
+ assertThat(Iterators.unmodifiableIterator(new ArrayList<>().iterator()))
+ .toIterable()
+ .containsExactlyElementsOf(
+ copyOf(Iterators.unmodifiableIterator(new ArrayList<>().iterator())));
}
AssertEqualIteratorIterationOrderWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualIteratorIterationOrderWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualIteratorIterationOrderWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualIteratorIterationOrderWithMessage() {
- assertEquals(
- Iterators.unmodifiableIterator(new ArrayList<>().iterator()),
- Iterators.unmodifiableIterator(new ArrayList<>().iterator()),
- "foo");
+ assertThat(Iterators.unmodifiableIterator(new ArrayList<>().iterator()))
+ .toIterable()
+ .withFailMessage("foo")
+ .containsExactlyElementsOf(
+ copyOf(Iterators.unmodifiableIterator(new ArrayList<>().iterator())));
}
AssertEqualIterableIterationOrder
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualIterableIterationOrder")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualIterableIterationOrder).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualIterableIterationOrder() {
- assertEquals(
- Iterables.unmodifiableIterable(new ArrayList<>()),
- Iterables.unmodifiableIterable(new ArrayList<>()));
- assertEquals(
- Collections.synchronizedCollection(new ArrayList<>()),
- Collections.synchronizedCollection(new ArrayList<>()));
+ assertThat(Iterables.unmodifiableIterable(new ArrayList<>()))
+ .containsExactlyElementsOf(Iterables.unmodifiableIterable(new ArrayList<>()));
+ assertThat(Collections.synchronizedCollection(new ArrayList<>()))
+ .containsExactlyElementsOf(Collections.synchronizedCollection(new ArrayList<>()));
}
AssertEqualIterableIterationOrderWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualIterableIterationOrderWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualIterableIterationOrderWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualIterableIterationOrderWithMessage() {
- assertEquals(
- Iterables.unmodifiableIterable(new ArrayList<>()),
- Iterables.unmodifiableIterable(new ArrayList<>()),
- "foo");
- assertEquals(
- Collections.synchronizedCollection(new ArrayList<>()),
- Collections.synchronizedCollection(new ArrayList<>()),
- "bar");
+ assertThat(Iterables.unmodifiableIterable(new ArrayList<>()))
+ .withFailMessage("foo")
+ .containsExactlyElementsOf(Iterables.unmodifiableIterable(new ArrayList<>()));
+ assertThat(Collections.synchronizedCollection(new ArrayList<>()))
+ .withFailMessage("bar")
+ .containsExactlyElementsOf(Collections.synchronizedCollection(new ArrayList<>()));
}
AssertEqualSets
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualSets")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualSets).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualSets() {
- assertEquals(ImmutableSet.of(), ImmutableSet.of());
+ assertThat(ImmutableSet.of()).hasSameElementsAs(ImmutableSet.of());
}
AssertEqualSetsWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertEqualSetsWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertEqualSetsWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertEqualSetsWithMessage() {
- assertEquals(ImmutableSet.of(), ImmutableSet.of(), "foo");
+ assertThat(ImmutableSet.of()).withFailMessage("foo").hasSameElementsAs(ImmutableSet.of());
}
AssertUnequal
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertUnequal")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertUnequal).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertUnequal() {
- assertNotEquals(true, true);
- assertNotEquals((byte) 0, (byte) 0);
- assertNotEquals((char) 0, (char) 0);
- assertNotEquals((short) 0, (short) 0);
- assertNotEquals(0, 0);
- assertNotEquals(0L, 0L);
- assertNotEquals(0.0F, 0.0F);
- assertNotEquals(0.0, 0.0);
- assertNotEquals(new Object(), new Object());
- assertNotEquals("actual", "expected");
- assertNotEquals(ImmutableSet.of(), ImmutableSet.of());
- assertNotEquals(ImmutableMap.of(), ImmutableMap.of());
+ assertThat(true).isNotEqualTo(true);
+ assertThat((byte) 0).isNotEqualTo((byte) 0);
+ assertThat((char) 0).isNotEqualTo((char) 0);
+ assertThat((short) 0).isNotEqualTo((short) 0);
+ assertThat(0).isNotEqualTo(0);
+ assertThat(0L).isNotEqualTo(0L);
+ assertThat(0.0F).isNotEqualTo(0.0F);
+ assertThat(0.0).isNotEqualTo(0.0);
+ assertThat(new Object()).isNotEqualTo(new Object());
+ assertThat("actual").isNotEqualTo("expected");
+ assertThat(ImmutableSet.of()).isNotEqualTo(ImmutableSet.of());
+ assertThat(ImmutableMap.of()).isNotEqualTo(ImmutableMap.of());
}
AssertUnequalWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertUnequalWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertUnequalWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertUnequalWithMessage() {
- assertNotEquals(true, true, "foo");
- assertNotEquals((byte) 0, (byte) 0, "bar");
- assertNotEquals((char) 0, (char) 0, "baz");
- assertNotEquals((short) 0, (short) 0, "qux");
- assertNotEquals(0, 0, "quux");
- assertNotEquals(0L, 0L, "quuz");
- assertNotEquals(0.0F, 0.0F, "corge");
- assertNotEquals(0.0, 0.0, "grault");
- assertNotEquals(new Object(), new Object(), "garply");
- assertNotEquals("actual", "expected", "waldo");
- assertNotEquals(ImmutableSet.of(), ImmutableSet.of(), "fred");
- assertNotEquals(ImmutableMap.of(), ImmutableMap.of(), "plugh");
+ assertThat(true).withFailMessage("foo").isNotEqualTo(true);
+ assertThat((byte) 0).withFailMessage("bar").isNotEqualTo((byte) 0);
+ assertThat((char) 0).withFailMessage("baz").isNotEqualTo((char) 0);
+ assertThat((short) 0).withFailMessage("qux").isNotEqualTo((short) 0);
+ assertThat(0).withFailMessage("quux").isNotEqualTo(0);
+ assertThat(0L).withFailMessage("quuz").isNotEqualTo(0L);
+ assertThat(0.0F).withFailMessage("corge").isNotEqualTo(0.0F);
+ assertThat(0.0).withFailMessage("grault").isNotEqualTo(0.0);
+ assertThat(new Object()).withFailMessage("garply").isNotEqualTo(new Object());
+ assertThat("actual").withFailMessage("waldo").isNotEqualTo("expected");
+ assertThat(ImmutableSet.of()).withFailMessage("fred").isNotEqualTo(ImmutableSet.of());
+ assertThat(ImmutableMap.of()).withFailMessage("plugh").isNotEqualTo(ImmutableMap.of());
}
AssertUnequalFloatsWithDelta
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertUnequalFloatsWithDelta")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertUnequalFloatsWithDelta).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertUnequalFloatsWithDelta() {
- assertNotEquals(0.0F, 0.0F, 0.0F);
+ assertThat(0.0F).isNotCloseTo(0.0F, offset(0.0F));
}
AssertUnequalFloatsWithDeltaWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertUnequalFloatsWithDeltaWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertUnequalFloatsWithDeltaWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertUnequalFloatsWithDeltaWithMessage() {
- assertNotEquals(0.0F, 0.0F, 0.0F, "foo");
+ assertThat(0.0F).withFailMessage("foo").isNotCloseTo(0.0F, offset(0.0F));
}
AssertUnequalDoublesWithDelta
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertUnequalDoublesWithDelta")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertUnequalDoublesWithDelta).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertUnequalDoublesWithDelta() {
- assertNotEquals(0.0, 0.0, 0.0);
+ assertThat(0.0).isNotCloseTo(0.0, offset(0.0));
}
AssertUnequalDoublesWithDeltaWithMessage
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertUnequalDoublesWithDeltaWithMessage")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertUnequalDoublesWithDeltaWithMessage).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertUnequalDoublesWithDeltaWithMessage() {
- assertNotEquals(0.0, 0.0, 0.0, "foo");
+ assertThat(0.0).withFailMessage("foo").isNotCloseTo(0.0, offset(0.0));
}
AssertThrows
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThrows")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertThrows).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertThrows() {
- assertThrows(() -> {});
+ assertThatThrownBy(() -> {});
}
AssertThrowsWithType
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThrowsWithType")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!TestNGToAssertJRules\$AssertThrowsWithType).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertThrowsWithType() {
- assertThrows(IllegalStateException.class, () -> {});
+ assertThatThrownBy(() -> {}).isInstanceOf(IllegalStateException.class);
}