Skip to content

Commit

Permalink
Remove toImmutableSet() rule
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannizotta authored and Stephan202 committed Aug 14, 2023
1 parent b032f8b commit 2f1095a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ StepVerifier.Step<T> after(StepVerifier.Step<T> 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<T> {
@BeforeTemplate
StepVerifier.Step<ImmutableList<T>> before(Flux<T> flux, T object) {
Expand All @@ -1337,13 +1337,6 @@ StepVerifier.Step<ImmutableList<T>> before(Flux<T> flux, T object) {
.assertNext(list -> assertThat(list).containsExactly(object));
}

@BeforeTemplate
StepVerifier.Step<ImmutableSet<T>> before2(Flux<T> flux, T object) {
return flux.collect(toImmutableSet())
.as(StepVerifier::create)
.assertNext(set -> assertThat(set).containsExactly(object));
}

@AfterTemplate
StepVerifier.Step<T> after(Flux<T> flux, T object) {
return flux.as(StepVerifier::create).expectNext(object);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -423,18 +422,12 @@ ImmutableSet<StepVerifier.Step<String>> testStepVerifierStepExpectNext() {
StepVerifier.create(Mono.just("baz")).expectNextMatches("qux"::equals));
}

ImmutableSet<Duration> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,8 @@ ImmutableSet<StepVerifier.Step<String>> testStepVerifierStepExpectNext() {
StepVerifier.create(Mono.just("baz")).expectNext("qux"));
}

ImmutableSet<Duration> 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() {
Expand Down

0 comments on commit 2f1095a

Please sign in to comment.