Flux<List<Integer>> scenario_bufferWillSubdivideAnInputFluxGapTime() { return Flux.just(1, 2, 3, 4, 5, 6, 7, 8) .delayElements(Duration.ofMillis(99)) .buffer(Duration.ofMillis(200), Duration.ofMillis(300)); }
Flux<List<Integer>> scenario_bufferWillSubdivideAnInputFluxOverlapTime() { return Flux.just(1, 2, 3, 4, 5, 6, 7, 8) .delayElements(Duration.ofMillis(99)) .buffer(Duration.ofMillis(300), Duration.ofMillis(200)); }
Flux<List<Integer>> scenario_bufferWillSubdivideAnInputFluxOverlapTime2() { return Flux.just(1, 2, 3, 4, 5, 6, 7, 8) .delayElements(Duration.ofMillis(99)) .buffer(Duration.ofMillis(300L), Duration.ofMillis(200L)); }
@Override public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) { return response.writeWith(Flux.just("h", "e", "l", "l", "o") .delayElements(Duration.ofMillis(100)) .publishOn(asyncGroup) .collect(dataBufferFactory::allocateBuffer, (buffer, str) -> buffer.write(str.getBytes()))); } }
Flux<List<Integer>> scenario_bufferWillSubdivideAnInputFluxTime() { return Flux.just(1, 2, 3, 4, 5, 6, 7, 8) .delayElements(Duration.ofMillis(99)) .buffer(Duration.ofMillis(200)); }
Flux<List<Integer>> scenario_bufferWithTimeoutAccumulateOnTimeOrSize() { return Flux.range(1, 6) .delayElements(Duration.ofMillis(300)) .bufferTimeout(5, Duration.ofMillis(2000)); }
Flux<List<Integer>> scenario_bufferWithTimeoutAccumulateOnTimeOrSize2() { return Flux.range(1, 6) .delayElements(Duration.ofMillis(300)) .bufferTimeout(5, Duration.ofMillis(2000)); }
Flux<List<Integer>> scenario_bufferWithTimeoutThrowingExceptionOnTimeOrSizeIfDownstreamDemandIsLow() { return Flux.range(1, 6) .delayElements(Duration.ofMillis(300)) .bufferTimeout(5, Duration.ofMillis(100)); }
Flux<List<Integer>> scenario_windowWillSubdivideAnInputFluxOverlapTime() { return Flux.just(1, 2, 3, 4, 5, 6, 7, 8) .delayElements(Duration.ofMillis(99)) .window(Duration.ofMillis(300), Duration.ofMillis(200)) .concatMap(Flux::buffer); }
Flux<List<Integer>> scenario_windowWillSubdivideAnInputFluxGapTime() { return Flux.just(1, 2, 3, 4, 5, 6, 7, 8) .delayElements(Duration.ofMillis(99)) .window(Duration.ofMillis(200), Duration.ofMillis(300)) .concatMap(Flux::buffer); }
Flux<Integer> scenario_rangeTimedSample() { return Flux.range(1, Integer.MAX_VALUE) .delayElements(Duration.ofMillis(100)) .sample(Duration.ofSeconds(4)) .take(1); }
Flux<Integer> scenario_sampleTimeoutTime(){ return Flux.range(1, 10) .delayElements(Duration.ofMillis(300)) .sampleTimeout(d -> Mono.delay(Duration.ofMillis(100*d)), 1); }
Flux<List<Integer>> scenario_windowWithTimeoutAccumulateOnTimeOrSize() { return Flux.range(1, 6) .delayElements(Duration.ofMillis(300)) .windowTimeout(5, Duration.ofMillis(2000)) .concatMap(Flux::buffer); }
public Flux<Integer> commitError() { this.commitProbe = PublisherProbe.of( Flux.just(3, 2, 1) .delayElements(DELAY) .map(i -> 100 / (i - 1)) //results in divide by 0 .log("commit method used", level, SignalType.ON_NEXT, SignalType.ON_COMPLETE)); return commitProbe.flux(); }
Flux<Integer> scenario_backpressuredThenCancel() { return Flux.just(1, 2, 3) .flatMap(f -> Flux.range(1, 10) .delayElements(Duration.ofMillis(10L))) .hide(); }
@Test public void thenAwaitThenCancelWaitsForDuration() { Duration verifyDuration = StepVerifier.create(Flux.just("foo", "bar") .delayElements(Duration.ofMillis(500))) .expectSubscription() .thenAwait(Duration.ofMillis(500)) .expectNext("foo") .thenAwait(Duration.ofMillis(200)) .thenCancel() .verify(Duration.ofMillis(1000)); assertThat(verifyDuration.toMillis()).isGreaterThanOrEqualTo(700L); }
public Flux<Integer> rollbackDelay() { this.rollbackProbe = PublisherProbe.of( Flux.just(5, 4, 3, 2, 1) .delayElements(DELAY) .log("rollback method used", level, SignalType.ON_NEXT, SignalType.ON_COMPLETE)); return rollbackProbe.flux(); }
@Test public void triggerSequenceWithDelays() { StepVerifier.withVirtualTime(() -> Mono.just("foo") .delayUntil(a -> Flux.just(1, 2, 3) .hide() .delayElements(Duration.ofMillis(500)))) .expectSubscription() .expectNoEvent(Duration.ofMillis(1400)) .thenAwait(Duration.ofMillis(100)) .expectNext("foo") .verifyComplete(); }
public Flux<Integer> commitDelay() { this.commitProbe = PublisherProbe.of( Flux.just(3, 2, 1) .delayElements(DELAY) .log("commit method used", level, SignalType.ON_NEXT, SignalType.ON_COMPLETE)); return commitProbe.flux(); }
@Test public void triggerSequenceWithDelays() { StepVerifier.withVirtualTime(() -> Flux.just("foo", "bar") .delayUntil(a -> Flux.just(1, 2, 3).hide().delayElements(Duration.ofMillis(500)))) .expectSubscription() .expectNoEvent(Duration.ofMillis(1400)) .thenAwait(Duration.ofMillis(100)) .expectNext("foo") .expectNoEvent(Duration.ofMillis(1500)) .expectNext("bar") .verifyComplete(); }