use of io.reactivex.MaybeObserver in project resilience4j by resilience4j.
the class BulkheadMaybeObserverTest method shouldHonorDisposedWhenCallingOnComplete.
@Test
public void shouldHonorDisposedWhenCallingOnComplete() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
MaybeObserver childObserver = mock(MaybeObserver.class);
MaybeObserver decoratedObserver = BulkheadOperator.of(bulkhead).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onComplete();
// Then
verify(childObserver, never()).onComplete();
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(1);
}
use of io.reactivex.MaybeObserver in project resilience4j by resilience4j.
the class CircuitBreakerMaybeObserverTest method shouldHonorDisposedWhenCallingOnSuccess.
@Test
public void shouldHonorDisposedWhenCallingOnSuccess() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
MaybeObserver childObserver = mock(MaybeObserver.class);
MaybeObserver decoratedObserver = CircuitBreakerOperator.of(circuitBreaker).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onSuccess(1);
// Then
verify(childObserver, never()).onSuccess(any());
assertSingleSuccessfulCall();
}
use of io.reactivex.MaybeObserver in project resilience4j by resilience4j.
the class CircuitBreakerMaybeObserverTest method shouldHonorDisposedWhenCallingOnError.
@Test
public void shouldHonorDisposedWhenCallingOnError() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
MaybeObserver childObserver = mock(MaybeObserver.class);
MaybeObserver 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.MaybeObserver in project resilience4j by resilience4j.
the class CircuitBreakerMaybeObserverTest method shouldHonorDisposedWhenCallingOnComplete.
@Test
public void shouldHonorDisposedWhenCallingOnComplete() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
MaybeObserver childObserver = mock(MaybeObserver.class);
MaybeObserver 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.MaybeObserver in project resilience4j by resilience4j.
the class CircuitBreakerMaybeObserverTest method shouldNotAffectCircuitBreakerWhenWasDisposedAfterNotPermittedSubscribe.
@Test
public void shouldNotAffectCircuitBreakerWhenWasDisposedAfterNotPermittedSubscribe() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
MaybeObserver childObserver = mock(MaybeObserver.class);
MaybeObserver decoratedObserver = CircuitBreakerOperator.of(circuitBreaker).apply(childObserver);
circuitBreaker.transitionToOpenState();
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
// Then
assertNoRegisteredCall();
}
Aggregations