@Test
public void composeGroup() {
Set<Integer> values = new ConcurrentSkipListSet<>();
Flux<Integer> flux = Flux.range(1, 10)
.parallel(3)
.runOn(Schedulers.parallel())
.doOnNext(values::add)
.composeGroup(p -> p.log("rail" + p.key())
.map(i -> (p.key() + 1) * 100 + i))
.sequential();
StepVerifier.create(flux.sort())
.assertNext(i -> assertThat(i - 100)
.isBetween(1, 10))
.thenConsumeWhile(i -> i / 100 == 1)
.assertNext(i -> assertThat(i - 200)
.isBetween(1, 10))
.thenConsumeWhile(i -> i / 100 == 2)
.assertNext(i -> assertThat(i - 300)
.isBetween(1, 10))
.thenConsumeWhile(i -> i / 100 == 3)
.verifyComplete();
assertThat(values)
.hasSize(10)
.contains(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
}