Reactive Java
StepVerifier initial request
Control test demand rather than requesting all items immediately. Source-reviewed Reactor or WebFlux example, NOT RUN.
Formal Syntax & Structure
java syntaxjava
StepVerifier.create(publisher, 0).thenRequest(2)Working Example
Example Snippetjava
package lab;import java.time.Duration;import org.junit.jupiter.api.Test;import reactor.core.publisher.Flux;import reactor.test.StepVerifier;class DemandTest { @Test void demand() { StepVerifier.create(Flux.range(1, 3), 0) .expectSubscription().thenRequest(2).expectNext(1, 2) .thenRequest(1).expectNext(3).expectComplete() .verify(Duration.ofSeconds(2)); }}