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. AssertThatMapContainsOnlyKey
  12. AssertThatMapContainsOnlyKeys
  13. AssertThatMapContainsValue
  14. AssertThatMapDoesNotContainValue
  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());
+  assertThat(ImmutableMap.of(1, 0)).isEmpty();
   assertThat(ImmutableMap.of(2, 0)).containsExactlyEntriesOf(ImmutableMap.of(1, 2));
-  assertThat(ImmutableMap.of(3, 0)).containsExactlyInAnyOrderEntriesOf(ImmutableMap.of());
+  assertThat(ImmutableMap.of(3, 0)).isEmpty();
   assertThat(ImmutableMap.of(4, 0))
       .containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(1, 2, 3, 4));
-  assertThat(ImmutableMap.of(5, 0)).hasSameSizeAs(ImmutableMap.of());
+  assertThat(ImmutableMap.of(5, 0)).isEmpty();
   assertThat(ImmutableMap.of(6, 0)).hasSameSizeAs(ImmutableMap.of(1, 2));
-  assertThat(ImmutableMap.of(7, 0)).isEqualTo(ImmutableMap.of());
+  assertThat(ImmutableMap.of(7, 0)).isEmpty();
   assertThat(ImmutableMap.of(8, 0)).isEqualTo(ImmutableMap.of("foo", "bar"));
-  assertThat(ImmutableMap.of(9, 0)).containsOnlyKeys(ImmutableList.of());
+  assertThat(ImmutableMap.of(9, 0)).isEmpty();
   assertThat(ImmutableMap.of(10, 0)).containsOnlyKeys(ImmutableList.of(1));
-  assertThat(ImmutableMap.of(11, 0)).containsExactly();
-  assertThat(ImmutableMap.of(12, 0)).containsOnly();
-  assertThat(ImmutableMap.of(13, 0)).containsOnlyKeys();
+  assertThat(ImmutableMap.of(11, 0)).isEmpty();
+  assertThat(ImmutableMap.of(12, 0)).isEmpty();
+  assertThat(ImmutableMap.of(13, 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(1, 0)).isNotEmpty(),
       assertThat(ImmutableMap.of(2, 0)).isNotEqualTo(ImmutableMap.of("foo", "bar")));
 }

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.

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

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.

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

AssertThatMapContainsOnlyKey

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

AssertThatMapContainsOnlyKeys

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatMapContainsOnlyKeys() {
-  return assertThat(ImmutableMap.of(1, 2).keySet()).hasSameElementsAs(ImmutableSet.of(3));
+  return assertThat(ImmutableMap.of(1, 2)).containsOnlyKeys(ImmutableSet.of(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.

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

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.

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatMapDoesNotContainValue() {
   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-2024 Picnic Technologies BV