AssertJStreamRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJStreamRules\$).*as compiler argument.
Table of contents
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=^(?!AssertJStreamRules\$AssertThatIsEmpty).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertThatIsEmpty() {
- assertThat(Stream.of(1).findAny()).isEmpty();
- assertThat(Stream.of(2).findFirst()).isEmpty();
- assertThat(Stream.of(3).toArray()).isEmpty();
- assertThat(Stream.of(4).toArray(Integer[]::new)).isEmpty();
- assertThat(Stream.of(5).toList()).isEmpty();
- assertThat(Stream.of(6).collect((Collector<Integer, Object, Iterable<Object>>) null)).isEmpty();
- assertThat(Stream.of(7).collect(toImmutableSet())).isEmpty();
- assertThat(Stream.of(8).collect(toImmutableList())).isEmpty();
+ assertThat(Stream.of(1)).isEmpty();
+ assertThat(Stream.of(2)).isEmpty();
+ assertThat(Stream.of(3)).isEmpty();
+ assertThat(Stream.of(4)).isEmpty();
+ assertThat(Stream.of(5)).isEmpty();
+ assertThat(Stream.of(6)).isEmpty();
+ assertThat(Stream.of(7)).isEmpty();
+ assertThat(Stream.of(8)).isEmpty();
}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=^(?!AssertJStreamRules\$AssertThatIsNotEmpty).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertThatIsNotEmpty() {
- assertThat(Stream.of(1).count()).isNotEqualTo(0);
- assertThat(Stream.of(2).count()).isNotEqualTo(0L);
- assertThat(Stream.of(3).findAny()).isPresent();
- assertThat(Stream.of(4).findFirst()).isPresent();
- assertThat(Stream.of(5).toArray()).isNotEmpty();
- assertThat(Stream.of(6).toArray(Integer[]::new)).isNotEmpty();
- assertThat(Stream.of(7).toList()).isNotEmpty();
- assertThat(Stream.of(8).collect((Collector<Integer, Object, Iterable<Object>>) null))
- .isNotEmpty();
- assertThat(Stream.of(9).collect(toImmutableSet())).isNotEmpty();
- assertThat(Stream.of(10).collect(toImmutableList())).isNotEmpty();
+ assertThat(Stream.of(1)).isNotEmpty();
+ assertThat(Stream.of(2)).isNotEmpty();
+ assertThat(Stream.of(3)).isNotEmpty();
+ assertThat(Stream.of(4)).isNotEmpty();
+ assertThat(Stream.of(5)).isNotEmpty();
+ assertThat(Stream.of(6)).isNotEmpty();
+ assertThat(Stream.of(7)).isNotEmpty();
+ assertThat(Stream.of(8)).isNotEmpty();
+ assertThat(Stream.of(9)).isNotEmpty();
+ assertThat(Stream.of(10)).isNotEmpty();
}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=^(?!AssertJStreamRules\$AssertThatHasSize).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatHasSize() {
- return assertThat(Stream.of(1).count()).isEqualTo(2);
+ return assertThat(Stream.of(1)).hasSize(2);
}AssertThatFilteredOn
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatFilteredOn")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJStreamRules\$AssertThatFilteredOn).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ListAssert<Integer> testAssertThatFilteredOn() {
- return assertThat(Stream.of(1).filter(i -> i > 2));
+ return assertThat(Stream.of(1)).filteredOn(i -> i > 2);
}AssertThatNoneMatch
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatNoneMatch")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJStreamRules\$AssertThatNoneMatch).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertThatNoneMatch() {
- assertThat(Stream.of(1)).filteredOn(i -> i > 2).isEmpty();
- assertThat(Stream.of(3).anyMatch(i -> i > 4)).isFalse();
- assertThat(Stream.of(5).noneMatch(i -> i > 6)).isTrue();
+ assertThat(Stream.of(1)).noneMatch(i -> i > 2);
+ assertThat(Stream.of(3)).noneMatch(i -> i > 4);
+ assertThat(Stream.of(5)).noneMatch(i -> i > 6);
}AssertThatAnyMatch
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatAnyMatch")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJStreamRules\$AssertThatAnyMatch).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<AbstractAssert<?, ?>> testAssertThatAnyMatch() {
return ImmutableSet.of(
- assertThat(Stream.of(1)).filteredOn(i -> i > 2).isNotEmpty(),
- assertThat(Stream.of(3).anyMatch(i -> i > 4)).isTrue(),
- assertThat(Stream.of(5).noneMatch(i -> i > 6)).isFalse());
+ assertThat(Stream.of(1)).anyMatch(i -> i > 2),
+ assertThat(Stream.of(3)).anyMatch(i -> i > 4),
+ assertThat(Stream.of(5)).anyMatch(i -> i > 6));
}AssertThatCollection
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatCollection")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJStreamRules\$AssertThatCollection).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatCollection() {
- return assertThat(ImmutableSet.of("foo").stream());
+ return assertThat(ImmutableSet.of("foo"));
}