Exemplo n.º 1
0
  @Test
  public void fromArityArgs1() {
    Observable<String> items = Observable.just("one");

    assertEquals((Long) 1L, items.count().toBlocking().single());
    assertEquals("one", items.takeLast(1).toBlocking().single());
  }
Exemplo n.º 2
0
  @Test
  public void testCountError() {
    Observable<String> o = Observable.error(() -> new RuntimeException());

    o.count().subscribe(w);
    verify(w, never()).onNext(anyInt());
    verify(w, never()).onComplete();
    verify(w, times(1)).onError(any(RuntimeException.class));
  }
Exemplo n.º 3
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();
 }
Exemplo n.º 4
0
  @Test
  public void testCountAFewItems() {
    Observable<String> observable = Observable.just("a", "b", "c", "d");

    observable.count().subscribe(w);

    // we should be called only once
    verify(w, times(1)).onNext(anyLong());
    verify(w).onNext(4L);
    verify(w, never()).onError(any(Throwable.class));
    verify(w, times(1)).onComplete();
  }