Search in sources :

Example 6 with CompletableObserver

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

Example 7 with CompletableObserver

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

Example 8 with CompletableObserver

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

Example 9 with CompletableObserver

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

Example 10 with CompletableObserver

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

Aggregations

CompletableObserver (io.reactivex.CompletableObserver)10 Disposable (io.reactivex.disposables.Disposable)10 Test (org.junit.Test)8 Handler (android.os.Handler)1 NonNull (android.support.annotation.NonNull)1 HorizontalChangeHandler (com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler)1 NcApi (com.nextcloud.talk.api.NcApi)1 UserEntity (com.nextcloud.talk.models.database.UserEntity)1 GenericOverall (com.nextcloud.talk.models.json.generic.GenericOverall)1 PushConfigurationState (com.nextcloud.talk.models.json.push.PushConfigurationState)1 Observer (io.reactivex.Observer)1 IOException (java.io.IOException)1 CookieManager (java.net.CookieManager)1 HashMap (java.util.HashMap)1 JavaNetCookieJar (okhttp3.JavaNetCookieJar)1