Search in sources :

Example 6 with MaybeObserver

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);
}
Also used : Disposable(io.reactivex.disposables.Disposable) MaybeObserver(io.reactivex.MaybeObserver) Test(org.junit.Test)

Example 7 with MaybeObserver

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();
}
Also used : Disposable(io.reactivex.disposables.Disposable) MaybeObserver(io.reactivex.MaybeObserver) Test(org.junit.Test)

Example 8 with MaybeObserver

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();
}
Also used : Disposable(io.reactivex.disposables.Disposable) MaybeObserver(io.reactivex.MaybeObserver) Test(org.junit.Test)

Example 9 with MaybeObserver

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();
}
Also used : Disposable(io.reactivex.disposables.Disposable) MaybeObserver(io.reactivex.MaybeObserver) Test(org.junit.Test)

Example 10 with MaybeObserver

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