Extend MonoIdentity Refaster rule (#465)

By flagging expressions of the form `mono.flux().next()`.
This commit is contained in:
Phil Werli
2023-01-17 07:33:56 +01:00
committed by GitHub
parent dec3220b5b
commit 82a07fde25
3 changed files with 6 additions and 3 deletions

View File

@@ -369,7 +369,7 @@ final class ReactorRules {
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

View File

@@ -116,7 +116,10 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase {
}
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() {

View File

@@ -121,7 +121,7 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase {
}
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() {