@Test
public void doOnSubscribe() {

    final int[] count = { 0 };
    Flowable.range(1, 5)
    .parallel(2)
    .doOnSubscribe(new Consumer<Subscription>() {
        @Override
        public void accept(Subscription s) throws Exception {
            count[0]++;
        }
    })
    .sequential()
    .test()
    .assertResult(1, 2, 3, 4, 5);
    assertEquals(2, count[0]);
}