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

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. AssertThatMapIsEmpty
  3. AbstractMapAssertIsNotEmpty
  4. AssertThatMapIsNotEmpty
  5. AbstractMapAssertContainsExactlyInAnyOrderEntriesOf
  6. AbstractMapAssertContainsExactlyEntriesOf
  7. AssertThatMapHasSize
  8. AbstractMapAssertHasSameSizeAs
  9. AssertThatMapContainsKey
  10. AssertThatMapDoesNotContainKey
  11. AssertThatMapContainsValue
  12. AssertThatMapDoesNotContainValue
  13. 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());
-    assertThat(ImmutableMap.of(2, 0)).containsExactlyEntriesOf(ImmutableBiMap.of());
-    assertThat(ImmutableMap.of(3, 0)).containsExactlyEntriesOf(ImmutableSortedMap.of());
-    assertThat(ImmutableMap.of(4, 0)).containsExactlyEntriesOf(new HashMap<>());
-    assertThat(ImmutableMap.of(5, 0)).containsExactlyEntriesOf(new LinkedHashMap<>());
-    assertThat(ImmutableMap.of(6, 0)).containsExactlyEntriesOf(new TreeMap<>());
-    assertThat(ImmutableMap.of(7, 0)).hasSameSizeAs(ImmutableMap.of());
-    assertThat(ImmutableMap.of(8, 0)).hasSameSizeAs(ImmutableBiMap.of());
-    assertThat(ImmutableMap.of(9, 0)).hasSameSizeAs(ImmutableSortedMap.of());
-    assertThat(ImmutableMap.of(10, 0)).hasSameSizeAs(new HashMap<>());
-    assertThat(ImmutableMap.of(11, 0)).hasSameSizeAs(new LinkedHashMap<>());
-    assertThat(ImmutableMap.of(12, 0)).hasSameSizeAs(new TreeMap<>());
-    assertThat(ImmutableMap.of(13, 0)).isEqualTo(ImmutableMap.of());
-    assertThat(ImmutableMap.of(14, 0)).isEqualTo(ImmutableBiMap.of());
-    assertThat(ImmutableMap.of(15, 0)).isEqualTo(ImmutableSortedMap.of());
-    assertThat(ImmutableMap.of(16, 0)).isEqualTo(new HashMap<>());
-    assertThat(ImmutableMap.of(17, 0)).isEqualTo(new LinkedHashMap<>());
-    assertThat(ImmutableMap.of(18, 0)).isEqualTo(new TreeMap<>());
-    assertThat(ImmutableMap.of(19, 0)).containsOnlyKeys(ImmutableList.of());
-    assertThat(ImmutableMap.of(20, 0)).containsOnlyKeys(new ArrayList<>());
-    assertThat(ImmutableMap.of(21, 0)).containsOnlyKeys(ImmutableSet.of());
-    assertThat(ImmutableMap.of(22, 0)).containsOnlyKeys(new HashSet<>());
-    assertThat(ImmutableMap.of(23, 0)).containsOnlyKeys(ImmutableSortedSet.of());
-    assertThat(ImmutableMap.of(24, 0)).containsOnlyKeys(new TreeSet<>());
-    assertThat(ImmutableMap.of(25, 0)).containsOnlyKeys(ImmutableMultiset.of());
-    assertThat(ImmutableMap.of(26, 0)).containsOnlyKeys(ImmutableSortedMultiset.of());
-    assertThat(ImmutableMap.of(27, 0)).containsExactly();
-    assertThat(ImmutableMap.of(28, 0)).containsOnly();
-    assertThat(ImmutableMap.of(29, 0)).containsOnlyKeys();
+    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();
+    assertThat(ImmutableMap.of(8, 0)).isEmpty();
+    assertThat(ImmutableMap.of(9, 0)).isEmpty();
+    assertThat(ImmutableMap.of(10, 0)).isEmpty();
+    assertThat(ImmutableMap.of(11, 0)).isEmpty();
+    assertThat(ImmutableMap.of(12, 0)).isEmpty();
+    assertThat(ImmutableMap.of(13, 0)).isEmpty();
+    assertThat(ImmutableMap.of(14, 0)).isEmpty();
+    assertThat(ImmutableMap.of(15, 0)).isEmpty();
+    assertThat(ImmutableMap.of(16, 0)).isEmpty();
+    assertThat(ImmutableMap.of(17, 0)).isEmpty();
+    assertThat(ImmutableMap.of(18, 0)).isEmpty();
+    assertThat(ImmutableMap.of(19, 0)).isEmpty();
+    assertThat(ImmutableMap.of(20, 0)).isEmpty();
+    assertThat(ImmutableMap.of(21, 0)).isEmpty();
+    assertThat(ImmutableMap.of(22, 0)).isEmpty();
+    assertThat(ImmutableMap.of(23, 0)).isEmpty();
+    assertThat(ImmutableMap.of(24, 0)).isEmpty();
+    assertThat(ImmutableMap.of(25, 0)).isEmpty();
+    assertThat(ImmutableMap.of(26, 0)).isEmpty();
+    assertThat(ImmutableMap.of(27, 0)).isEmpty();
+    assertThat(ImmutableMap.of(28, 0)).isEmpty();
+    assertThat(ImmutableMap.of(29, 0)).isEmpty();
   }

AssertThatMapIsEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatMapIsEmpty() {
-    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()),
-        assertThat(ImmutableMap.of(2, 0)).isNotEqualTo(ImmutableBiMap.of()),
-        assertThat(ImmutableMap.of(3, 0)).isNotEqualTo(ImmutableSortedMap.of()),
-        assertThat(ImmutableMap.of(4, 0)).isNotEqualTo(new HashMap<>()),
-        assertThat(ImmutableMap.of(5, 0)).isNotEqualTo(new LinkedHashMap<>()),
-        assertThat(ImmutableMap.of(6, 0)).isNotEqualTo(new TreeMap<>()));
+        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());
   }

AssertThatMapIsNotEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatMapIsNotEmpty() {
     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));
   }

AbstractMapAssertContainsExactlyEntriesOf

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

AssertThatMapHasSize

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatMapHasSize() {
     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));
   }

AssertThatMapContainsKey

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatMapContainsKey() {
-    return assertThat(ImmutableMap.of(1, 2).containsKey(3)).isTrue();
+    return assertThat(ImmutableMap.of(1, 2)).containsKey(3);
   }

AssertThatMapDoesNotContainKey

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatMapDoesNotContainKey() {
-    return assertThat(ImmutableMap.of(1, 2).containsKey(3)).isFalse();
+    return assertThat(ImmutableMap.of(1, 2)).doesNotContainKey(3);
   }

AssertThatMapContainsValue

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatMapContainsValue() {
-    return assertThat(ImmutableMap.of(1, 2).containsValue(3)).isTrue();
+    return assertThat(ImmutableMap.of(1, 2)).containsValue(3);
   }

AssertThatMapDoesNotContainValue

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatMapDoesNotContainValue() {
-    return assertThat(ImmutableMap.of(1, 2).containsValue(3)).isFalse();
+    return assertThat(ImmutableMap.of(1, 2)).doesNotContainValue(3);
   }

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-2023 Picnic Technologies BV