Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[reactor-test] Add StepVerifier option to use ConditionalSubscriber #3035

Merged
merged 4 commits into from May 23, 2022

Conversation

simonbasle
Copy link
Member

This commit adds a new feature to StepVerifier that enforces the use
of a ConditionalSubscriber as the verifier's Subscriber.

It is activated by calling enableConditionalSupport at any Step
(similar to the as naming method). Note that the reason the feature is
added to the Step API is that it is the only part that is typed with
<T> (which is desirable for the Predicate to be typed).

This feature only guarantees that the StepVerifier will use a subscriber
that implements ConditionalSubscriber when it subscribes to the source.
Note that this doesn't guarantee the Publisher under test is itself
going to produce ConditionalSubscribers, and even if it does, this
doesn't guarantee that at runtime the tryOnNext path will be used.
All of this depends on the source and the publisher chain under test.

This commit adds a new feature to StepVerifier that enforces the use
of a ConditionalSubscriber as the verifier's Subscriber.

It is activated by calling `enableConditionalSupport` at any `Step`
(similar to the `as` naming method). Note that the reason the feature is
added to the `Step` API is that it is the only part that is typed with
`<T>` (which is desirable for the `Predicate` to be typed).

This feature only guarantees that the StepVerifier will use a subscriber
that implements ConditionalSubscriber when it subscribes to the source.
Note that this doesn't guarantee the Publisher under test is itself
going to produce ConditionalSubscribers, and even if it does, this
doesn't guarantee that at runtime the `tryOnNext` path will be used.
All of this depends on the source and the publisher chain under test.
@simonbasle simonbasle added this to the 3.4.x Backlog milestone May 5, 2022
@simonbasle simonbasle added area/reactor-test This belongs to the reactor-test module type/enhancement A general enhancement labels May 5, 2022
@simonbasle simonbasle self-assigned this May 5, 2022
@simonbasle simonbasle requested a review from a team May 5, 2022 10:49
@simonbasle
Copy link
Member Author

simonbasle commented May 5, 2022

TODOs:

  • I'll look into moving this to LastStep<T> since that interface is also typed. It might be a better place in order to avoid having the toggle in the middle of the expectations, but instead closer to the verify call.
  • actually LastStep isn't generified, but FirstStep<T> is. Maybe this can be squeezed at the beginning before expectSubscription
  • tests

@simonbasle simonbasle marked this pull request as ready for review May 5, 2022 13:46
@simonbasle simonbasle requested a review from a team as a code owner May 5, 2022 13:46
@simonbasle simonbasle modified the milestones: 3.4.x Backlog, 3.4.19 May 23, 2022
@simonbasle simonbasle merged commit 01a55c9 into 3.4.x May 23, 2022
@simonbasle simonbasle deleted the reactorTestConditionalStepVerifier branch May 23, 2022 08:16
simonbasle added a commit that referenced this pull request May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/reactor-test This belongs to the reactor-test module type/enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants