AssertJMapRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. AbstractMapAssertIsEmpty
  2. AssertThatIsEmpty
  3. AbstractMapAssertIsNotEmpty
  4. AssertThatIsNotEmpty
  5. AbstractMapAssertContainsExactlyInAnyOrderEntriesOf
  6. AbstractMapAssertContainsExactlyEntriesOfImmutableMapOf
  7. AssertThatHasSize
  8. AbstractMapAssertHasSameSizeAs
  9. AssertThatContainsKey
  10. AssertThatDoesNotContainKey
  11. AssertThatContainsOnlyKeysObject
  12. AssertThatContainsOnlyKeysIterable
  13. AssertThatContainsValue
  14. AssertThatDoesNotContainValue
  15. AssertThatMapContainsEntry

AbstractMapAssertIsEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAbstractMapAssertIsEmpty() {
   assertThat(ImmutableMap.of(1, 0)).containsExactlyEntriesOf(ImmutableMap.of(1, 2));
-  assertThat(ImmutableMap.of(2, 0)).containsExactlyEntriesOf(ImmutableMap.of());
+  assertThat(ImmutableMap.of(2, 0)).isEmpty();
   assertThat(ImmutableMap.of(3, 0))
       .containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(1, 2, 3, 4));
-  assertThat(ImmutableMap.of(4, 0)).containsExactlyInAnyOrderEntriesOf(ImmutableMap.of());
+  assertThat(ImmutableMap.of(4, 0)).isEmpty();
   assertThat(ImmutableMap.of(5, 0)).hasSameSizeAs(ImmutableMap.of(1, 2));
-  assertThat(ImmutableMap.of(6, 0)).hasSameSizeAs(ImmutableMap.of());
+  assertThat(ImmutableMap.of(6, 0)).isEmpty();
   assertThat(ImmutableMap.of(7, 0)).isEqualTo(ImmutableMap.of("foo", "bar"));
-  assertThat(ImmutableMap.of(8, 0)).isEqualTo(ImmutableMap.of());
+  assertThat(ImmutableMap.of(8, 0)).isEmpty();
   assertThat(ImmutableMap.of(9, 0)).containsOnlyKeys(ImmutableList.of(1));
-  assertThat(ImmutableMap.of(10, 0)).containsOnlyKeys(ImmutableList.of());
-  assertThat(ImmutableMap.of(11, 0)).containsExactly();
-  assertThat(ImmutableMap.of(12, 0)).containsOnly();
-  assertThat(ImmutableMap.of(13, 0)).containsOnlyKeys();
+  assertThat(ImmutableMap.of(10, 0)).isEmpty();
+  assertThat(ImmutableMap.of(11, 0)).isEmpty();
+  assertThat(ImmutableMap.of(12, 0)).isEmpty();
+  assertThat(ImmutableMap.of(13, 0)).isEmpty();
 }

AssertThatIsEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatIsEmpty() {
-  assertThat(ImmutableMap.of(1, 0)).hasSize(0);
-  assertThat(ImmutableMap.of(2, 0).isEmpty()).isTrue();
-  assertThat(ImmutableMap.of(3, 0).size()).isEqualTo(0L);
-  assertThat(ImmutableMap.of(4, 0).size()).isNotPositive();
-  assertThat(ImmutableMap.of(5, 0).keySet()).isEmpty();
-  assertThat(ImmutableMap.of(6, 0).values()).isEmpty();
-  assertThat(ImmutableMap.of(7, 0).entrySet()).isEmpty();
+  assertThat(ImmutableMap.of(1, 0)).isEmpty();
+  assertThat(ImmutableMap.of(2, 0)).isEmpty();
+  assertThat(ImmutableMap.of(3, 0)).isEmpty();
+  assertThat(ImmutableMap.of(4, 0)).isEmpty();
+  assertThat(ImmutableMap.of(5, 0)).isEmpty();
+  assertThat(ImmutableMap.of(6, 0)).isEmpty();
+  assertThat(ImmutableMap.of(7, 0)).isEmpty();
 }

AbstractMapAssertIsNotEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<MapAssert<Integer, Integer>> testAbstractMapAssertIsNotEmpty() {
   return ImmutableSet.of(
       assertThat(ImmutableMap.of(1, 0)).isNotEqualTo(ImmutableMap.of("foo", "bar")),
-      assertThat(ImmutableMap.of(2, 0)).isNotEqualTo(ImmutableMap.of()));
+      assertThat(ImmutableMap.of(2, 0)).isNotEmpty());
 }

AssertThatIsNotEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsNotEmpty() {
   return ImmutableSet.of(
-      assertThat(ImmutableMap.of(1, 0).isEmpty()).isFalse(),
-      assertThat(ImmutableMap.of(2, 0).size()).isNotEqualTo(0),
-      assertThat(ImmutableMap.of(3, 0).size()).isPositive(),
-      assertThat(ImmutableMap.of(4, 0).keySet()).isNotEmpty(),
-      assertThat(ImmutableMap.of(5, 0).values()).isNotEmpty(),
-      assertThat(ImmutableMap.of(6, 0).entrySet()).isNotEmpty());
+      assertThat(ImmutableMap.of(1, 0)).isNotEmpty(),
+      assertThat(ImmutableMap.of(2, 0)).isNotEmpty(),
+      assertThat(ImmutableMap.of(3, 0)).isNotEmpty(),
+      assertThat(ImmutableMap.of(4, 0)).isNotEmpty(),
+      assertThat(ImmutableMap.of(5, 0)).isNotEmpty(),
+      assertThat(ImmutableMap.of(6, 0)).isNotEmpty());
 }

AbstractMapAssertContainsExactlyInAnyOrderEntriesOf

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 MapAssert<Integer, Integer> testAbstractMapAssertContainsExactlyInAnyOrderEntriesOf() {
-  return assertThat(ImmutableMap.of(1, 2, 3, 4)).isEqualTo(ImmutableMap.of(1, 2, 3, 4));
+  return assertThat(ImmutableMap.of(1, 2, 3, 4))
+      .containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(1, 2, 3, 4));
 }

AbstractMapAssertContainsExactlyEntriesOfImmutableMapOf

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 MapAssert<Integer, Integer> testAbstractMapAssertContainsExactlyEntriesOfImmutableMapOf() {
-  return assertThat(ImmutableMap.of(1, 2))
-      .containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(1, 2));
+  return assertThat(ImmutableMap.of(1, 2)).containsExactlyEntriesOf(ImmutableMap.of(1, 2));
 }

AssertThatHasSize

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatHasSize() {
   return ImmutableSet.of(
-      assertThat(ImmutableMap.of(1, 2).size()).isEqualTo(1),
-      assertThat(ImmutableMap.of(3, 4).keySet()).hasSize(1),
-      assertThat(ImmutableMap.of(5, 6).values()).hasSize(1),
-      assertThat(ImmutableMap.of(7, 8).entrySet()).hasSize(1));
+      assertThat(ImmutableMap.of(1, 2)).hasSize(1),
+      assertThat(ImmutableMap.of(3, 4)).hasSize(1),
+      assertThat(ImmutableMap.of(5, 6)).hasSize(1),
+      assertThat(ImmutableMap.of(7, 8)).hasSize(1));
 }

AbstractMapAssertHasSameSizeAs

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 MapAssert<Integer, Integer> testAbstractMapAssertHasSameSizeAs() {
-  return assertThat(ImmutableMap.of(1, 2)).hasSize(ImmutableMap.of(3, 4).size());
+  return assertThat(ImmutableMap.of(1, 2)).hasSameSizeAs(ImmutableMap.of(3, 4));
 }

AssertThatContainsKey

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatContainsKey() {
   return ImmutableSet.of(
-      assertThat(ImmutableMap.of(1, 2).containsKey(3)).isTrue(),
-      assertThat(ImmutableMap.of(4, 5).keySet()).contains(6));
+      assertThat(ImmutableMap.of(1, 2)).containsKey(3),
+      assertThat(ImmutableMap.of(4, 5)).containsKey(6));
 }

AssertThatDoesNotContainKey

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatDoesNotContainKey() {
   return ImmutableSet.of(
-      assertThat(ImmutableMap.of(1, 2).containsKey(3)).isFalse(),
-      assertThat(ImmutableMap.of(4, 5).keySet()).doesNotContain(6));
+      assertThat(ImmutableMap.of(1, 2)).doesNotContainKey(3),
+      assertThat(ImmutableMap.of(4, 5)).doesNotContainKey(6));
 }

AssertThatContainsOnlyKeysObject

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatContainsOnlyKeysObject() {
-  return assertThat(ImmutableMap.of(1, 2).keySet()).containsExactly(3);
+  return assertThat(ImmutableMap.of(1, 2)).containsOnlyKeys(3);
 }

AssertThatContainsOnlyKeysIterable

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatContainsOnlyKeysIterable() {
-  return assertThat(ImmutableMap.of(1, 2).keySet()).hasSameElementsAs(ImmutableSet.of(3));
+  return assertThat(ImmutableMap.of(1, 2)).containsOnlyKeys(ImmutableSet.of(3));
 }

AssertThatContainsValue

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatContainsValue() {
   return ImmutableSet.of(
-      assertThat(ImmutableMap.of(1, 2).containsValue(3)).isTrue(),
-      assertThat(ImmutableMap.of(4, 5).values()).contains(6));
+      assertThat(ImmutableMap.of(1, 2)).containsValue(3),
+      assertThat(ImmutableMap.of(4, 5)).containsValue(6));
 }

AssertThatDoesNotContainValue

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatDoesNotContainValue() {
   return ImmutableSet.of(
-      assertThat(ImmutableMap.of(1, 2).containsValue(3)).isFalse(),
-      assertThat(ImmutableMap.of(4, 5).values()).doesNotContain(6));
+      assertThat(ImmutableMap.of(1, 2)).doesNotContainValue(3),
+      assertThat(ImmutableMap.of(4, 5)).doesNotContainValue(6));
 }

AssertThatMapContainsEntry

SUGGESTION

Simplification

Suppression

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

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

Samples

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


Copyright © 2017-2026 Picnic Technologies BV