Source:
public void shouldBuildRatioMapSeries() throws Exception { List<DataPoint<AvailabilityType>> serie1 = ImmutableList.of( new DataPoint<>(0L, AvailabilityType.UP), new DataPoint<>(5L, AvailabilityType.DOWN), new DataPoint<>(10L, AvailabilityType.UP)); List<DataPoint<AvailabilityType>> serie2 = ImmutableList.of( new DataPoint<>(0L, AvailabilityType.UP), new DataPoint<>(7L, AvailabilityType.DOWN), new DataPoint<>(10L, AvailabilityType.ADMIN)); List<DataPoint<AvailabilityType>> serie3 = ImmutableList.of( new DataPoint<>(1L, AvailabilityType.UP), new DataPoint<>(7L, AvailabilityType.DOWN)); Observable<Observable<DataPoint<AvailabilityType>>> observable = Observable.just( Observable.from(serie1), Observable.from(serie2), Observable.from(serie3)); List<DataPoint<RatioMap>> result = service.buildRatioMapSeries(observable, Order.ASC, AvailabilityType::getText) .toList() .toBlocking() .single(); assertThat(result).extracting(DataPoint::getTimestamp).containsExactly(0L, 1L, 5L, 7L, 10L); assertThat(result).extracting(dp -> dp.getValue().getSamples()) .containsExactly(2, 3, 3, 3, 3); assertThat(result).extracting(dp -> dp.getValue().getRatio("up")) .usingElementComparator(dc) .containsExactly(1d, 1d, 0.6667, 0d, 0.3333); assertThat(result).extracting(dp -> dp.getValue().getRatio("down")) .usingElementComparator(dc) .containsExactly(0d, 0d, 0.3333, 1d, 0.3333); assertThat(result).extracting(dp -> dp.getValue().getRatio("admin")) .usingElementComparator(dc) .containsExactly(0d, 0d, 0d, 0d, 0.3333); assertThat(result).extracting(dp -> dp.getValue().getRatio("unknown")) .usingElementComparator(dc) .containsExactly(0d, 0d, 0d, 0d, 0d); }

Target:
public void shouldBuildRatioMapSeries() throws Exception { Observable<Observable<DataPoint<AvailabilityType>>> allSeries = Observable.just( Observable.just( new DataPoint<>(0L, AvailabilityType.UP), new DataPoint<>(5L, AvailabilityType.DOWN), new DataPoint<>(10L, AvailabilityType.UP)), Observable.just( new DataPoint<>(0L, AvailabilityType.UP), new DataPoint<>(7L, AvailabilityType.DOWN), new DataPoint<>(10L, AvailabilityType.ADMIN)), Observable.just( new DataPoint<>(1L, AvailabilityType.UP), new DataPoint<>(7L, AvailabilityType.DOWN))); Observable<DataPoint<RatioMap>> result = service.buildRatioMapSeries(allSeries, Order.ASC, AvailabilityType::getText); TestSubscriber<DataPoint<RatioMap>> testSubscriber = new TestSubscriber<>(); result.subscribe(testSubscriber); testSubscriber.awaitTerminalEvent(); testSubscriber.assertNoErrors(); List<DataPoint<RatioMap>> emitedDataPoints = testSubscriber.getOnNextEvents(); assertThat(emitedDataPoints).extracting(DataPoint::getTimestamp).containsExactly(0L, 1L, 5L, 7L, 10L); assertThat(emitedDataPoints).extracting(dp -> dp.getValue().getSamples()) .containsExactly(2, 3, 3, 3, 3); assertThat(emitedDataPoints).extracting(dp -> dp.getValue().getRatio("up")) .usingElementComparator(dc) .containsExactly(1d, 1d, 0.6667, 0d, 0.3333); assertThat(emitedDataPoints).extracting(dp -> dp.getValue().getRatio("down")) .usingElementComparator(dc) .containsExactly(0d, 0d, 0.3333, 1d, 0.3333); assertThat(emitedDataPoints).extracting(dp -> dp.getValue().getRatio("admin")) .usingElementComparator(dc) .containsExactly(0d, 0d, 0d, 0d, 0.3333); assertThat(emitedDataPoints).extracting(dp -> dp.getValue().getRatio("unknown")) .usingElementComparator(dc) .containsExactly(0d, 0d, 0d, 0d, 0d); }