Ejemplo n.º 1
0
  @Test
  public void testHidingError() {
    PublishSubject<Integer> src = PublishSubject.create();

    Observable<Integer> dst = src.asObservable();

    assertFalse(dst instanceof PublishSubject);

    @SuppressWarnings("unchecked")
    Observer<Object> o = mock(Observer.class);

    dst.subscribe(o);

    src.onError(new TestException());

    verify(o, never()).onNext(any());
    verify(o, never()).onComplete();
    verify(o).onError(any(TestException.class));
  }
Ejemplo n.º 2
0
  @Test
  public void testHiding() {
    PublishSubject<Integer> src = PublishSubject.create();

    Observable<Integer> dst = src.asObservable();

    assertFalse(dst instanceof PublishSubject);

    Subscriber<Object> o = TestHelper.mockSubscriber();

    dst.subscribe(o);

    src.onNext(1);
    src.onComplete();

    verify(o).onNext(1);
    verify(o).onComplete();
    verify(o, never()).onError(any(Throwable.class));
  }