Publisher stubs

So far, we have been creating a Publisher along with the operators. As a result, we could build  end-to-end validations. However, in most business services, a Publisher will be created in some part of the code and operations will be performed in another. In order to unit test the operation service code, we would need to generate a dummy Publisher. Reactor also provides TestPublisher for this purpose. We can create a TestPublisher using the create factory method. The generated TestPublisher can be converted into a Flux or a Mono. TestPublisher makes it possible to emit  events using any of the following methods:

Method name Description
 next(T) / next(T,T...) Invokes Publisher OnNext with the supplied values.
 complete() ...

Get Hands-On Reactive Programming with Reactor now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.