Skip to content

Commit

Permalink
Add tests for FluxFromIterable
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirk van Bokkem authored and rickie committed Feb 20, 2024
1 parent c4a87ab commit 3b28d4c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,6 @@ Mono<R> after(Mono<T> mono, Mono<S> other, BiFunction<T, S, R> combinator) {
}
}

/** Don't unnecessarily convert {@link Collection} to {@link Stream} before creating {@link Flux}. */
static final class FluxFromIterable<T> {
@BeforeTemplate
Flux<T> before(Collection<T> c) {
return Flux.fromStream(c.stream());
}

@AfterTemplate
Flux<T> after(Collection<T> c) {
return Flux.fromIterable(c);
}
}

/**
* Prefer {@link Flux#zip(Publisher, Publisher)} over a chained {@link Flux#zipWith(Publisher)},
* as the former better conveys that the {@link Publisher}s may be subscribed to concurrently, and
Expand Down Expand Up @@ -1913,4 +1900,19 @@ Duration after(StepVerifier.LastStep step, Duration duration) {
return step.verifyTimeout(duration);
}
}

/**
* Don't unnecessarily convert {@link Collection} to {@link Stream} before creating {@link Flux}.
*/
static final class FluxFromIterable<T> {
@BeforeTemplate
Flux<T> before(Collection<T> c) {
return Flux.fromStream(c.stream());
}

@AfterTemplate
Flux<T> after(Collection<T> c) {
return Flux.fromIterable(c);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -646,4 +646,8 @@ Duration testStepVerifierLastStepVerifyErrorMessage() {
Duration testStepVerifierLastStepVerifyTimeout() {
return Mono.empty().as(StepVerifier::create).expectTimeout(Duration.ZERO).verify();
}

Flux<String> testFluxFromIterable() {
return Flux.fromStream(ImmutableList.of("foo").stream());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,8 @@ Duration testStepVerifierLastStepVerifyErrorMessage() {
Duration testStepVerifierLastStepVerifyTimeout() {
return Mono.empty().as(StepVerifier::create).verifyTimeout(Duration.ZERO);
}

Flux<String> testFluxFromIterable() {
return Flux.fromIterable(ImmutableList.of("foo"));
}
}

0 comments on commit 3b28d4c

Please sign in to comment.