@Test @DisplayName("delegate `onNext` calls to wrapped observers") void delegateOnNext() { MemoizingObserver<String> observer1 = StreamObservers.memoizingObserver(); MemoizingObserver<String> observer2 = StreamObservers.memoizingObserver(); StreamObserver<String> observer = new CompositeObserver<>(ImmutableList.of(observer1, observer2)); String value = "String value."; observer.onNext(value); assertThat(observer1.firstResponse()).isEqualTo(value); assertThat(observer2.firstResponse()).isEqualTo(value); }
@Override public void onNext(T value) { observers.forEach(o -> o.onNext(value)); }
CompositeObserver implements StreamObserver<T> { @Override public void onNext(T value) { observers.forEach(o -> o.onNext(value)); } }
CompositeObserver implements StreamObserver<T> { @Override public void onNext(T value) { observers.forEach(o -> o.onNext(value)); } CompositeObserver(Iterable<StreamObserver<? super T>> observers); }
CompositeObserver implements StreamObserver<T> { @Override public void onNext(T value) { observers.forEach(o -> o.onNext(value)); } CompositeObserver(Iterable<StreamObserver<? super T>> observers); @Override void onNext(T value); @Override void onError(Throwable t); @Override void onCompleted(); }
CompositeObserver implements StreamObserver<T> { @Override public void onNext(T value) { observers.forEach(o -> o.onNext(value)); } CompositeObserver(Iterable<StreamObserver<? super T>> observers); @Override void onNext(T value); @Override void onError(Throwable t); @Override void onCompleted();  }