Beispiel #1
0
  @Test
  public void testEmptyIsEmpty() {
    Observable.<Integer>empty().subscribe(w);

    verify(w).onComplete();
    verify(w, never()).onNext(any(Integer.class));
    verify(w, never()).onError(any(Throwable.class));
  }
Beispiel #2
0
 @Test
 public void testFirstOfNone() {
   Observable<Integer> observable = Observable.empty();
   observable.first().subscribe(w);
   verify(w, never()).onNext(anyInt());
   verify(w, never()).onComplete();
   verify(w, times(1)).onError(isA(NoSuchElementException.class));
 }
Beispiel #3
0
 @Test
 public void testTakeFirstOfNone() {
   Observable<Integer> observable = Observable.empty();
   observable.take(1).subscribe(w);
   verify(w, never()).onNext(anyInt());
   verify(w, times(1)).onComplete();
   verify(w, never()).onError(any(Throwable.class));
 }
Beispiel #4
0
 @Test
 public void testCountZeroItems() {
   Observable<String> observable = Observable.empty();
   observable.count().subscribe(w);
   // we should be called only once
   verify(w, times(1)).onNext(anyLong());
   verify(w).onNext(0L);
   verify(w, never()).onError(any(Throwable.class));
   verify(w, times(1)).onComplete();
 }
Beispiel #5
0
  @Test
  public void testContainsWithEmptyObservable() {
    Observable<Boolean> observable = Observable.<String>empty().contains("a");

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

    observable.subscribe(observer);

    verify(observer, times(1)).onNext(false);
    verify(observer, never()).onNext(true);
    verify(observer, never()).onError(org.mockito.Matchers.any(Throwable.class));
    verify(observer, times(1)).onComplete();
  }
Beispiel #6
0
 @Test
 public void testEmptyIdentity() {
   assertEquals(Observable.empty(), Observable.empty());
 }