Refine search
@Test public void testFirstOrDefault() { Single<Integer> o = Observable.just(1, 2, 3) .first(4); o.subscribe(wo); InOrder inOrder = inOrder(wo); inOrder.verify(wo, times(1)).onSuccess(1); inOrder.verifyNoMoreInteractions(); }
private void verifyResult(Single<Boolean> single, boolean result) { SingleObserver<Boolean> observer = TestHelper.mockSingleObserver(); single.subscribe(observer); InOrder inOrder = inOrder(observer); inOrder.verify(observer, times(1)).onSuccess(result); inOrder.verifyNoMoreInteractions(); }
@Test public void testSecondFails() { s1.onNext("a"); s1.onNext("b"); s2.onError(new RuntimeException("Forced failure")); inOrder.verify(observer, times(1)).onError(any(RuntimeException.class)); s2.onNext("1"); s2.onNext("2"); inOrder.verify(observer, never()).onComplete(); inOrder.verify(observer, never()).onNext(any(String.class)); inOrder.verifyNoMoreInteractions(); }
@Test public void testFirstOrDefaultWithOneElement() { Single<Integer> o = Observable.just(1).first(2); o.subscribe(wo); InOrder inOrder = inOrder(wo); inOrder.verify(wo, times(1)).onSuccess(1); inOrder.verifyNoMoreInteractions(); }
@Test public void testFirstFails() { s2.onNext("a"); s1.onError(new RuntimeException("Forced failure")); inOrder.verify(observer, times(1)).onError(any(RuntimeException.class)); s2.onNext("b"); s1.onNext("1"); s1.onNext("2"); inOrder.verify(observer, never()).onComplete(); inOrder.verify(observer, never()).onNext(any(String.class)); inOrder.verifyNoMoreInteractions(); }
private void verifyResult(Single<Boolean> o, boolean result) { SingleObserver<Boolean> observer = TestHelper.mockSingleObserver(); o.subscribe(observer); InOrder inOrder = inOrder(observer); inOrder.verify(observer, times(1)).onSuccess(result); inOrder.verifyNoMoreInteractions(); }
@Test public void testSingleOrDefault() { Single<Integer> o = Observable.just(1).single(2); SingleObserver<Integer> observer = TestHelper.mockSingleObserver(); o.subscribe(observer); InOrder inOrder = inOrder(observer); inOrder.verify(observer, times(1)).onSuccess(1); inOrder.verifyNoMoreInteractions(); }
@Test public void testFirstFails() { s2.onNext("a"); s1.onError(new RuntimeException("Forced failure")); inOrder.verify(subscriber, times(1)).onError(any(RuntimeException.class)); s2.onNext("b"); s1.onNext("1"); s1.onNext("2"); inOrder.verify(subscriber, never()).onComplete(); inOrder.verify(subscriber, never()).onNext(any(String.class)); inOrder.verifyNoMoreInteractions(); }
private void assertCompletedSubscriber(Observer<String> observer) { InOrder inOrder = inOrder(observer); inOrder.verify(observer, times(1)).onNext("one"); inOrder.verify(observer, times(1)).onNext("two"); inOrder.verify(observer, times(1)).onNext("three"); inOrder.verify(observer, Mockito.never()).onError(any(Throwable.class)); inOrder.verify(observer, times(1)).onComplete(); inOrder.verifyNoMoreInteractions(); }
@Test public void testLastOrDefaultWithOneElement() { Single<Integer> o = Observable.just(1).last(2); SingleObserver<Integer> observer = TestHelper.mockSingleObserver(); o.subscribe(observer); InOrder inOrder = inOrder(observer); inOrder.verify(observer, times(1)).onSuccess(1); // inOrder.verify(observer, times(1)).onComplete(); inOrder.verifyNoMoreInteractions(); }
@Test public void testFirstCompletesThenSecondInfinite() { s1.onNext("a"); s1.onNext("b"); s1.onComplete(); s2.onNext("1"); inOrder.verify(observer, times(1)).onNext("a-1"); s2.onNext("2"); inOrder.verify(observer, times(1)).onNext("b-2"); inOrder.verify(observer, times(1)).onComplete(); inOrder.verifyNoMoreInteractions(); }
private void assertCompletedSubscriber(Subscriber<String> subscriber) { InOrder inOrder = inOrder(subscriber); inOrder.verify(subscriber, times(1)).onNext("one"); inOrder.verify(subscriber, times(1)).onNext("two"); inOrder.verify(subscriber, times(1)).onNext("three"); inOrder.verify(subscriber, Mockito.never()).onError(any(Throwable.class)); inOrder.verify(subscriber, times(1)).onComplete(); inOrder.verifyNoMoreInteractions(); }
@Test public void testLastOrDefault() { Single<Integer> o = Observable.just(1, 2, 3) .last(4); SingleObserver<Integer> observer = TestHelper.mockSingleObserver(); o.subscribe(observer); InOrder inOrder = inOrder(observer); inOrder.verify(observer, times(1)).onSuccess(3); // inOrder.verify(observer, times(1)).onComplete(); inOrder.verifyNoMoreInteractions(); }
@Test public void testFirstInfiniteThenSecondCompletes() { s1.onNext("a"); s1.onNext("b"); s2.onNext("1"); inOrder.verify(observer, times(1)).onNext("a-1"); s2.onNext("2"); inOrder.verify(observer, times(1)).onNext("b-2"); s2.onComplete(); inOrder.verify(observer, times(1)).onComplete(); inOrder.verifyNoMoreInteractions(); }
private void verifyResult(Observable<Boolean> o, boolean result) { Observer<Boolean> observer = TestHelper.mockObserver(); o.subscribe(observer); InOrder inOrder = inOrder(observer); inOrder.verify(observer, times(1)).onNext(result); inOrder.verify(observer).onComplete(); inOrder.verifyNoMoreInteractions(); }
@Test public void testFirstOrDefault() { Single<Integer> single = Flowable.just(1, 2, 3) .first(4); single.subscribe(wo); InOrder inOrder = inOrder(wo); inOrder.verify(wo, times(1)).onSuccess(1); inOrder.verifyNoMoreInteractions(); }
@Test public void testFirstInfiniteThenSecondCompletes() { s1.onNext("a"); s1.onNext("b"); s2.onNext("1"); inOrder.verify(subscriber, times(1)).onNext("a-1"); s2.onNext("2"); inOrder.verify(subscriber, times(1)).onNext("b-2"); s2.onComplete(); inOrder.verify(subscriber, times(1)).onComplete(); inOrder.verifyNoMoreInteractions(); }
private void verifyError(Single<Boolean> single) { SingleObserver<Boolean> observer = TestHelper.mockSingleObserver(); single.subscribe(observer); InOrder inOrder = inOrder(observer); inOrder.verify(observer, times(1)).onError(isA(TestException.class)); inOrder.verifyNoMoreInteractions(); }
@Test public void testFirstOrDefaultWithOneElement() { Single<Integer> single = Flowable.just(1).first(2); single.subscribe(wo); InOrder inOrder = inOrder(wo); inOrder.verify(wo, times(1)).onSuccess(1); inOrder.verifyNoMoreInteractions(); }
@Test public void testSecondCompletesThenFirstInfinite() { s2.onNext("1"); s2.onNext("2"); s2.onComplete(); s1.onNext("a"); inOrder.verify(subscriber, times(1)).onNext("a-1"); s1.onNext("b"); inOrder.verify(subscriber, times(1)).onNext("b-2"); inOrder.verify(subscriber, times(1)).onComplete(); inOrder.verifyNoMoreInteractions(); }