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. AssertThatMapContainsOnlyKeys
  12. AssertThatMapContainsValue
  13. AssertThatMapDoesNotContainValue
  14. 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.

 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);
 }

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.

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