Skip to content

Commit

Permalink
Extend MonoIdentity Refaster rule (#465)
Browse files Browse the repository at this point in the history
By flagging expressions of the form `mono.flux().next()`.
  • Loading branch information
werli authored Jan 17, 2023
1 parent dec3220 commit 82a07fd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ Flux<T> after(Flux<T> flux, T object) {
static final class MonoIdentity<T> {
@BeforeTemplate
Mono<T> before(Mono<T> mono) {
return mono.switchIfEmpty(Mono.empty());
return Refaster.anyOf(mono.switchIfEmpty(Mono.empty()), mono.flux().next());
}

@BeforeTemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ ImmutableSet<Flux<String>> testFluxDefaultIfEmpty() {
}

ImmutableSet<Mono<?>> testMonoIdentity() {
return ImmutableSet.of(Mono.just(1).switchIfEmpty(Mono.empty()), Mono.<Void>empty().then());
return ImmutableSet.of(
Mono.just(1).switchIfEmpty(Mono.empty()),
Mono.just(2).flux().next(),
Mono.<Void>empty().then());
}

ImmutableSet<Flux<Integer>> testFluxSwitchIfEmptyOfEmptyPublisher() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ ImmutableSet<Flux<String>> testFluxDefaultIfEmpty() {
}

ImmutableSet<Mono<?>> testMonoIdentity() {
return ImmutableSet.of(Mono.just(1), Mono.<Void>empty());
return ImmutableSet.of(Mono.just(1), Mono.just(2), Mono.<Void>empty());
}

ImmutableSet<Flux<Integer>> testFluxSwitchIfEmptyOfEmptyPublisher() {
Expand Down

0 comments on commit 82a07fd

Please sign in to comment.