Extend StepVerifierStepIdentity Refaster rule (#541)

By flagging expressions of the form `step.expectNextCount(0)`.
This commit is contained in:
Mohamed Sameh
2023-03-27 10:30:25 +02:00
committed by GitHub
parent 0b3be1b75b
commit 57cd084f82
3 changed files with 11 additions and 7 deletions

View File

@@ -1204,12 +1204,14 @@ final class ReactorRules {
}
}
/** Don't unnecessarily call {@link StepVerifier.Step#expectNext(Object[])}. */
static final class StepVerifierStepExpectNextEmpty<T> {
/** Don't unnecessarily have {@link StepVerifier.Step} expect no elements. */
// XXX: Given an `IsEmpty` matcher that identifies a wide range of guaranteed-empty `Iterable`
// expressions, consider also simplifying `step.expectNextSequence(someEmptyIterable)`.
static final class StepVerifierStepIdentity<T> {
@BeforeTemplate
@SuppressWarnings("unchecked")
StepVerifier.Step<T> before(StepVerifier.Step<T> step) {
return step.expectNext();
return Refaster.anyOf(step.expectNext(), step.expectNextCount(0));
}
@AfterTemplate

View File

@@ -389,8 +389,10 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase {
return StepVerifier.create(Flux.just(1));
}
StepVerifier.Step<Integer> testStepVerifierStepExpectNextEmpty() {
return StepVerifier.create(Mono.just(0)).expectNext();
ImmutableSet<StepVerifier.Step<Integer>> testStepVerifierStepIdentity() {
return ImmutableSet.of(
StepVerifier.create(Mono.just(1)).expectNext(),
StepVerifier.create(Mono.just(2)).expectNextCount(0L));
}
ImmutableSet<StepVerifier.Step<String>> testStepVerifierStepExpectNext() {

View File

@@ -377,8 +377,8 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase {
return Flux.just(1).as(StepVerifier::create);
}
StepVerifier.Step<Integer> testStepVerifierStepExpectNextEmpty() {
return StepVerifier.create(Mono.just(0));
ImmutableSet<StepVerifier.Step<Integer>> testStepVerifierStepIdentity() {
return ImmutableSet.of(StepVerifier.create(Mono.just(1)), StepVerifier.create(Mono.just(2)));
}
ImmutableSet<StepVerifier.Step<String>> testStepVerifierStepExpectNext() {