When combining many Mono<Void>
s using .then(Mono<Void>)
they don't run in the expected order.
Can somebody explain the difference between the working and nonworking code below?
Working code
StepVerifier.create(
repository.incrementCounter(bucket, timeStamp)
.then(repository.incrementCounter(bucket, timeStamp))
.then(Mono.just(1).flatMap(t -> repository.resetCounter(bucket, timeStamp)))
.then(Mono.just(1).flatMap(t -> repository.getCounter(bucket, timeStamp))))
.expectNext(0L)
.verifyComplete();
non-working
StepVerifier.create(
repository.incrementCounter(bucket, timeStamp)
.then(repository.incrementCounter(bucket, timeStamp))
.then(repository.resetCounter(bucket, timeStamp))
.then(repository.getCounter(bucket, timeStamp)))
.expectNext(0L)
.verifyComplete();