use of io.reactivex.CompletableObserver in project resilience4j by resilience4j.
the class BulkheadCompletableObserverTest method shouldHonorDisposedWhenCallingOnError.
@Test
public void shouldHonorDisposedWhenCallingOnError() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
CompletableObserver childObserver = mock(CompletableObserver.class);
CompletableObserver decoratedObserver = BulkheadOperator.of(bulkhead).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onError(new IllegalStateException());
// Then
verify(childObserver, never()).onError(any());
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(1);
}
use of io.reactivex.CompletableObserver in project resilience4j by resilience4j.
the class CircuitBreakerCompletableObserverTest method shouldHonorDisposedWhenCallingOnComplete.
@Test
public void shouldHonorDisposedWhenCallingOnComplete() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
CompletableObserver childObserver = mock(CompletableObserver.class);
CompletableObserver decoratedObserver = CircuitBreakerOperator.of(circuitBreaker).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onComplete();
// Then
verify(childObserver, never()).onComplete();
assertSingleSuccessfulCall();
}
use of io.reactivex.CompletableObserver in project resilience4j by resilience4j.
the class CircuitBreakerCompletableObserverTest method shouldHonorDisposedWhenCallingOnError.
@Test
public void shouldHonorDisposedWhenCallingOnError() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
CompletableObserver childObserver = mock(CompletableObserver.class);
CompletableObserver decoratedObserver = CircuitBreakerOperator.of(circuitBreaker).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onError(new IllegalStateException());
// Then
verify(childObserver, never()).onError(any());
assertSingleFailedCall();
}
use of io.reactivex.CompletableObserver in project resilience4j by resilience4j.
the class RateLimiterCompletableObserverTest method shouldHonorDisposedWhenCallingOnError.
@Test
public void shouldHonorDisposedWhenCallingOnError() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
CompletableObserver childObserver = mock(CompletableObserver.class);
CompletableObserver decoratedObserver = RateLimiterOperator.of(rateLimiter).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onError(new IllegalStateException());
// Then
verify(childObserver, never()).onError(any());
assertSinglePermitUsed();
}
use of io.reactivex.CompletableObserver in project resilience4j by resilience4j.
the class RateLimiterCompletableObserverTest method shouldHonorDisposedWhenCallingOnComplete.
@Test
public void shouldHonorDisposedWhenCallingOnComplete() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
CompletableObserver childObserver = mock(CompletableObserver.class);
CompletableObserver decoratedObserver = RateLimiterOperator.of(rateLimiter).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onComplete();
// Then
verify(childObserver, never()).onComplete();
assertSinglePermitUsed();
}
Aggregations