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

AssertJPrimitiveRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. AssertThatIsEqualTo
  2. AssertThatIsNotEqualTo
  3. AssertThatIsLessThan
  4. AssertThatIsLessThanOrEqualTo
  5. AssertThatIsGreaterThan
  6. AssertThatIsGreaterThanOrEqualTo

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

Samples

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

 @SuppressWarnings("SimplifyBooleanExpression")
   ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsEqualTo() {
     return ImmutableSet.of(
-        assertThat(true == false).isTrue(),
-        assertThat(true != false).isFalse(),
-        assertThat((byte) 1 == (byte) 2).isTrue(),
-        assertThat((byte) 1 != (byte) 2).isFalse(),
-        assertThat((char) 1 == (char) 2).isTrue(),
-        assertThat((char) 1 != (char) 2).isFalse(),
-        assertThat((short) 1 == (short) 2).isTrue(),
-        assertThat((short) 1 != (short) 2).isFalse(),
-        assertThat(1 == 2).isTrue(),
-        assertThat(1 != 2).isFalse(),
-        assertThat(1L == 2L).isTrue(),
-        assertThat(1L != 2L).isFalse(),
-        assertThat(1F == 2F).isTrue(),
-        assertThat(1F != 2F).isFalse(),
-        assertThat(1.0 == 2.0).isTrue(),
-        assertThat(1.0 != 2.0).isFalse());
+        assertThat(true).isEqualTo(false),
+        assertThat(true).isEqualTo(false),
+        assertThat((byte) 1).isEqualTo((byte) 2),
+        assertThat((byte) 1).isEqualTo((byte) 2),
+        assertThat((char) 1).isEqualTo((char) 2),
+        assertThat((char) 1).isEqualTo((char) 2),
+        assertThat((short) 1).isEqualTo((short) 2),
+        assertThat((short) 1).isEqualTo((short) 2),
+        assertThat(1).isEqualTo(2),
+        assertThat(1).isEqualTo(2),
+        assertThat(1L).isEqualTo(2L),
+        assertThat(1L).isEqualTo(2L),
+        assertThat(1F).isEqualTo(2F),
+        assertThat(1F).isEqualTo(2F),
+        assertThat(1.0).isEqualTo(2.0),
+        assertThat(1.0).isEqualTo(2.0));
   }

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=^(?!(AssertJPrimitiveRules\.AssertThatIsNotEqualTo)) as compiler argument.

Samples

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

 @SuppressWarnings("SimplifyBooleanExpression")
   ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsNotEqualTo() {
     return ImmutableSet.of(
-        assertThat(true != false).isTrue(),
-        assertThat(true == false).isFalse(),
-        assertThat((byte) 1 != (byte) 2).isTrue(),
-        assertThat((byte) 1 == (byte) 2).isFalse(),
-        assertThat((char) 1 != (char) 2).isTrue(),
-        assertThat((char) 1 == (char) 2).isFalse(),
-        assertThat((short) 1 != (short) 2).isTrue(),
-        assertThat((short) 1 == (short) 2).isFalse(),
-        assertThat(1 != 2).isTrue(),
-        assertThat(1 == 2).isFalse(),
-        assertThat(1L != 2L).isTrue(),
-        assertThat(1L == 2L).isFalse(),
-        assertThat(1F != 2F).isTrue(),
-        assertThat(1F == 2F).isFalse(),
-        assertThat(1.0 != 2.0).isTrue(),
-        assertThat(1.0 == 2.0).isFalse());
+        assertThat(true).isNotEqualTo(false),
+        assertThat(true).isNotEqualTo(false),
+        assertThat((byte) 1).isNotEqualTo((byte) 2),
+        assertThat((byte) 1).isNotEqualTo((byte) 2),
+        assertThat((char) 1).isNotEqualTo((char) 2),
+        assertThat((char) 1).isNotEqualTo((char) 2),
+        assertThat((short) 1).isNotEqualTo((short) 2),
+        assertThat((short) 1).isNotEqualTo((short) 2),
+        assertThat(1).isNotEqualTo(2),
+        assertThat(1).isNotEqualTo(2),
+        assertThat(1L).isNotEqualTo(2L),
+        assertThat(1L).isNotEqualTo(2L),
+        assertThat(1F).isNotEqualTo(2F),
+        assertThat(1F).isNotEqualTo(2F),
+        assertThat(1.0).isNotEqualTo(2.0),
+        assertThat(1.0).isNotEqualTo(2.0));
   }

AssertThatIsLessThan

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(AssertJPrimitiveRules\.AssertThatIsLessThan)) as compiler argument.

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsLessThan() {
     return ImmutableSet.of(
-        assertThat((byte) 1 < (byte) 2).isTrue(),
-        assertThat((byte) 1 >= (byte) 2).isFalse(),
-        assertThat((char) 1 < (char) 2).isTrue(),
-        assertThat((char) 1 >= (char) 2).isFalse(),
-        assertThat((short) 1 < (short) 2).isTrue(),
-        assertThat((short) 1 >= (short) 2).isFalse(),
-        assertThat(1 < 2).isTrue(),
-        assertThat(1 >= 2).isFalse(),
-        assertThat(1L < 2L).isTrue(),
-        assertThat(1L >= 2L).isFalse(),
-        assertThat(1F < 2F).isTrue(),
-        assertThat(1F >= 2F).isFalse(),
-        assertThat(1.0 < 2.0).isTrue(),
-        assertThat(1.0 >= 2.0).isFalse());
+        assertThat((byte) 1).isLessThan((byte) 2),
+        assertThat((byte) 1).isLessThan((byte) 2),
+        assertThat((char) 1).isLessThan((char) 2),
+        assertThat((char) 1).isLessThan((char) 2),
+        assertThat((short) 1).isLessThan((short) 2),
+        assertThat((short) 1).isLessThan((short) 2),
+        assertThat(1).isLessThan(2),
+        assertThat(1).isLessThan(2),
+        assertThat(1L).isLessThan(2L),
+        assertThat(1L).isLessThan(2L),
+        assertThat(1F).isLessThan(2F),
+        assertThat(1F).isLessThan(2F),
+        assertThat(1.0).isLessThan(2.0),
+        assertThat(1.0).isLessThan(2.0));
   }

AssertThatIsLessThanOrEqualTo

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(AssertJPrimitiveRules\.AssertThatIsLessThanOrEqualTo)) as compiler argument.

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsLessThanOrEqualTo() {
     return ImmutableSet.of(
-        assertThat((byte) 1 <= (byte) 2).isTrue(),
-        assertThat((byte) 1 > (byte) 2).isFalse(),
-        assertThat((char) 1 <= (char) 2).isTrue(),
-        assertThat((char) 1 > (char) 2).isFalse(),
-        assertThat((short) 1 <= (short) 2).isTrue(),
-        assertThat((short) 1 > (short) 2).isFalse(),
-        assertThat(1 <= 2).isTrue(),
-        assertThat(1 > 2).isFalse(),
-        assertThat(1L <= 2L).isTrue(),
-        assertThat(1L > 2L).isFalse(),
-        assertThat(1F <= 2F).isTrue(),
-        assertThat(1F > 2F).isFalse(),
-        assertThat(1.0 <= 2.0).isTrue(),
-        assertThat(1.0 > 2.0).isFalse());
+        assertThat((byte) 1).isLessThanOrEqualTo((byte) 2),
+        assertThat((byte) 1).isLessThanOrEqualTo((byte) 2),
+        assertThat((char) 1).isLessThanOrEqualTo((char) 2),
+        assertThat((char) 1).isLessThanOrEqualTo((char) 2),
+        assertThat((short) 1).isLessThanOrEqualTo((short) 2),
+        assertThat((short) 1).isLessThanOrEqualTo((short) 2),
+        assertThat(1).isLessThanOrEqualTo(2),
+        assertThat(1).isLessThanOrEqualTo(2),
+        assertThat(1L).isLessThanOrEqualTo(2L),
+        assertThat(1L).isLessThanOrEqualTo(2L),
+        assertThat(1F).isLessThanOrEqualTo(2F),
+        assertThat(1F).isLessThanOrEqualTo(2F),
+        assertThat(1.0).isLessThanOrEqualTo(2.0),
+        assertThat(1.0).isLessThanOrEqualTo(2.0));
   }

AssertThatIsGreaterThan

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(AssertJPrimitiveRules\.AssertThatIsGreaterThan)) as compiler argument.

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsGreaterThan() {
     return ImmutableSet.of(
-        assertThat((byte) 1 > (byte) 2).isTrue(),
-        assertThat((byte) 1 <= (byte) 2).isFalse(),
-        assertThat((char) 1 > (char) 2).isTrue(),
-        assertThat((char) 1 <= (char) 2).isFalse(),
-        assertThat((short) 1 > (short) 2).isTrue(),
-        assertThat((short) 1 <= (short) 2).isFalse(),
-        assertThat(1 > 2).isTrue(),
-        assertThat(1 <= 2).isFalse(),
-        assertThat(1L > 2L).isTrue(),
-        assertThat(1L <= 2L).isFalse(),
-        assertThat(1F > 2F).isTrue(),
-        assertThat(1F <= 2F).isFalse(),
-        assertThat(1.0 > 2.0).isTrue(),
-        assertThat(1.0 <= 2.0).isFalse());
+        assertThat((byte) 1).isGreaterThan((byte) 2),
+        assertThat((byte) 1).isGreaterThan((byte) 2),
+        assertThat((char) 1).isGreaterThan((char) 2),
+        assertThat((char) 1).isGreaterThan((char) 2),
+        assertThat((short) 1).isGreaterThan((short) 2),
+        assertThat((short) 1).isGreaterThan((short) 2),
+        assertThat(1).isGreaterThan(2),
+        assertThat(1).isGreaterThan(2),
+        assertThat(1L).isGreaterThan(2L),
+        assertThat(1L).isGreaterThan(2L),
+        assertThat(1F).isGreaterThan(2F),
+        assertThat(1F).isGreaterThan(2F),
+        assertThat(1.0).isGreaterThan(2.0),
+        assertThat(1.0).isGreaterThan(2.0));
   }

AssertThatIsGreaterThanOrEqualTo

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(AssertJPrimitiveRules\.AssertThatIsGreaterThanOrEqualTo)) as compiler argument.

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsGreaterThanOrEqualTo() {
     return ImmutableSet.of(
-        assertThat((byte) 1 >= (byte) 2).isTrue(),
-        assertThat((byte) 1 < (byte) 2).isFalse(),
-        assertThat((char) 1 >= (char) 2).isTrue(),
-        assertThat((char) 1 < (char) 2).isFalse(),
-        assertThat((short) 1 >= (short) 2).isTrue(),
-        assertThat((short) 1 < (short) 2).isFalse(),
-        assertThat(1 >= 2).isTrue(),
-        assertThat(1 < 2).isFalse(),
-        assertThat(1L >= 2L).isTrue(),
-        assertThat(1L < 2L).isFalse(),
-        assertThat(1F >= 2F).isTrue(),
-        assertThat(1F < 2F).isFalse(),
-        assertThat(1.0 >= 2.0).isTrue(),
-        assertThat(1.0 < 2.0).isFalse());
+        assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2),
+        assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2),
+        assertThat((char) 1).isGreaterThanOrEqualTo((char) 2),
+        assertThat((char) 1).isGreaterThanOrEqualTo((char) 2),
+        assertThat((short) 1).isGreaterThanOrEqualTo((short) 2),
+        assertThat((short) 1).isGreaterThanOrEqualTo((short) 2),
+        assertThat(1).isGreaterThanOrEqualTo(2),
+        assertThat(1).isGreaterThanOrEqualTo(2),
+        assertThat(1L).isGreaterThanOrEqualTo(2L),
+        assertThat(1L).isGreaterThanOrEqualTo(2L),
+        assertThat(1F).isGreaterThanOrEqualTo(2F),
+        assertThat(1F).isGreaterThanOrEqualTo(2F),
+        assertThat(1.0).isGreaterThanOrEqualTo(2.0),
+        assertThat(1.0).isGreaterThanOrEqualTo(2.0));
   }

Copyright © 2017-2023 Picnic Technologies BV