Skip to content

Commit

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

@BeforeTemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ ImmutableSet<Mono<?>> testMonoIdentity() {
return ImmutableSet.of(
Mono.just(1).switchIfEmpty(Mono.empty()),
Mono.just(2).flux().next(),
Mono.just(3).flux().singleOrEmpty(),
Mono.<Void>empty().then());
}

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.just(2), Mono.<Void>empty());
return ImmutableSet.of(Mono.just(1), Mono.just(2), Mono.just(3), Mono.<Void>empty());
}

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

0 comments on commit 81ffd04

Please sign in to comment.