From 3da362718268c7eec1d513acc91b0e987ff7a25d Mon Sep 17 00:00:00 2001 From: Giovanni Zotta Date: Fri, 14 Jul 2023 23:02:29 +0200 Subject: [PATCH] Remove `toImmutableSet()` rule --- .../refasterrules/ReactorRules.java | 9 +-------- .../refasterrules/ReactorRulesTestInput.java | 19 ++++++------------- .../refasterrules/ReactorRulesTestOutput.java | 6 ++---- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java index 7f606e23ed1..2b36c5ee9de 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java @@ -1328,7 +1328,7 @@ StepVerifier.Step after(StepVerifier.Step step, T object) { } } - /** Avoid collecting when verifying only the given element is in the given {@link Flux}. */ + /** Avoid value collection when verifying that a {@link Flux} emits exactly one value. */ static final class FluxAsStepVerifierExpectNext { @BeforeTemplate StepVerifier.Step> before(Flux flux, T object) { @@ -1337,13 +1337,6 @@ StepVerifier.Step> before(Flux flux, T object) { .assertNext(list -> assertThat(list).containsExactly(object)); } - @BeforeTemplate - StepVerifier.Step> before2(Flux flux, T object) { - return flux.collect(toImmutableSet()) - .as(StepVerifier::create) - .assertNext(set -> assertThat(set).containsExactly(object)); - } - @AfterTemplate StepVerifier.Step after(Flux flux, T object) { return flux.as(StepVerifier::create).expectNext(object); diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java index 74f44d061bf..07bfd9d45d8 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java @@ -1,7 +1,6 @@ package tech.picnic.errorprone.refasterrules; import static com.google.common.collect.ImmutableList.toImmutableList; -import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.MoreCollectors.toOptional; import static java.util.Comparator.reverseOrder; import static java.util.function.Function.identity; @@ -423,18 +422,12 @@ ImmutableSet> testStepVerifierStepExpectNext() { StepVerifier.create(Mono.just("baz")).expectNextMatches("qux"::equals)); } - ImmutableSet testFluxAsStepVerifierExpectNext() { - return ImmutableSet.of( - Flux.just(1) - .collect(toImmutableList()) - .as(StepVerifier::create) - .assertNext(list -> assertThat(list).containsExactly(2)) - .verifyComplete(), - Flux.just(3) - .collect(toImmutableSet()) - .as(StepVerifier::create) - .assertNext(set -> assertThat(set).containsExactly(4)) - .verifyComplete()); + Duration testFluxAsStepVerifierExpectNext() { + return Flux.just(1) + .collect(toImmutableList()) + .as(StepVerifier::create) + .assertNext(list -> assertThat(list).containsExactly(2)) + .verifyComplete(); } Duration testStepVerifierLastStepVerifyComplete() { diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java index 1136b736a59..7d6cb098983 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java @@ -413,10 +413,8 @@ ImmutableSet> testStepVerifierStepExpectNext() { StepVerifier.create(Mono.just("baz")).expectNext("qux")); } - ImmutableSet testFluxAsStepVerifierExpectNext() { - return ImmutableSet.of( - Flux.just(1).as(StepVerifier::create).expectNext(2).verifyComplete(), - Flux.just(3).as(StepVerifier::create).expectNext(4).verifyComplete()); + Duration testFluxAsStepVerifierExpectNext() { + return Flux.just(1).as(StepVerifier::create).expectNext(2).verifyComplete(); } Duration testStepVerifierLastStepVerifyComplete() {