Search in sources :

Example 11 with MaybeObserver

use of io.reactivex.MaybeObserver in project resilience4j by resilience4j.

the class RateLimiterMaybeObserverTest method shouldHonorDisposedWhenCallingOnSuccess.

@Test
public void shouldHonorDisposedWhenCallingOnSuccess() throws Exception {
    // Given
    Disposable disposable = mock(Disposable.class);
    MaybeObserver childObserver = mock(MaybeObserver.class);
    MaybeObserver decoratedObserver = RateLimiterOperator.of(rateLimiter).apply(childObserver);
    decoratedObserver.onSubscribe(disposable);
    // When
    ((Disposable) decoratedObserver).dispose();
    decoratedObserver.onSuccess(1);
    // Then
    verify(childObserver, never()).onSuccess(any());
    assertSinglePermitUsed();
}
Also used : Disposable(io.reactivex.disposables.Disposable) MaybeObserver(io.reactivex.MaybeObserver) Test(org.junit.Test)

Example 12 with MaybeObserver

use of io.reactivex.MaybeObserver in project resilience4j by resilience4j.

the class RateLimiterMaybeObserverTest method shouldHonorDisposedWhenCallingOnError.

@Test
public void shouldHonorDisposedWhenCallingOnError() throws Exception {
    // Given
    Disposable disposable = mock(Disposable.class);
    MaybeObserver childObserver = mock(MaybeObserver.class);
    MaybeObserver decoratedObserver = RateLimiterOperator.of(rateLimiter).apply(childObserver);
    decoratedObserver.onSubscribe(disposable);
    // When
    ((Disposable) decoratedObserver).dispose();
    decoratedObserver.onError(new IllegalStateException());
    // Then
    verify(childObserver, never()).onError(any());
    assertSinglePermitUsed();
}
Also used : Disposable(io.reactivex.disposables.Disposable) MaybeObserver(io.reactivex.MaybeObserver) Test(org.junit.Test)

Aggregations

MaybeObserver (io.reactivex.MaybeObserver)12 Disposable (io.reactivex.disposables.Disposable)12 Test (org.junit.Test)11 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 InfoItem (org.schabi.newpipe.extractor.InfoItem)1 ChannelInfo (org.schabi.newpipe.extractor.channel.ChannelInfo)1