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();
}
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();
}
Aggregations