Search in sources :

Example 1 with CompletableOnSubscribeExecuteAsBlocking

use of com.pushtorefresh.storio3.operations.internal.CompletableOnSubscribeExecuteAsBlocking in project storio by pushtorefresh.

the class CompletableOnSubscribeExecuteAsBlockingTest method shouldExecuteAsBlockingAfterSubscription.

@SuppressWarnings("ResourceType")
@Test
public void shouldExecuteAsBlockingAfterSubscription() {
    final PreparedCompletableOperation preparedOperation = mock(PreparedCompletableOperation.class);
    TestObserver testObserver = new TestObserver();
    verifyZeroInteractions(preparedOperation);
    Completable completable = Completable.create(new CompletableOnSubscribeExecuteAsBlocking(preparedOperation));
    verifyZeroInteractions(preparedOperation);
    completable.subscribe(testObserver);
    testObserver.assertNoErrors();
    testObserver.assertComplete();
    verify(preparedOperation).executeAsBlocking();
    verify(preparedOperation, never()).asRxFlowable(any(BackpressureStrategy.class));
    verify(preparedOperation, never()).asRxSingle();
    verify(preparedOperation, never()).asRxCompletable();
}
Also used : Completable(io.reactivex.Completable) PreparedCompletableOperation(com.pushtorefresh.storio3.operations.PreparedCompletableOperation) BackpressureStrategy(io.reactivex.BackpressureStrategy) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test)

Example 2 with CompletableOnSubscribeExecuteAsBlocking

use of com.pushtorefresh.storio3.operations.internal.CompletableOnSubscribeExecuteAsBlocking in project storio by pushtorefresh.

the class RxJavaUtils method createCompletable.

@CheckResult
@NonNull
public static <Result, Data> Completable createCompletable(@NonNull StorIOContentResolver storIOContentResolver, @NonNull PreparedCompletableOperation<Result, Data> operation) {
    throwExceptionIfRxJava2IsNotAvailable("asRxCompletable()");
    final Completable completable = Completable.create(new CompletableOnSubscribeExecuteAsBlocking(operation));
    return subscribeOn(storIOContentResolver, completable);
}
Also used : Completable(io.reactivex.Completable) CompletableOnSubscribeExecuteAsBlocking(com.pushtorefresh.storio3.operations.internal.CompletableOnSubscribeExecuteAsBlocking) CheckResult(android.support.annotation.CheckResult) NonNull(android.support.annotation.NonNull)

Example 3 with CompletableOnSubscribeExecuteAsBlocking

use of com.pushtorefresh.storio3.operations.internal.CompletableOnSubscribeExecuteAsBlocking in project storio by pushtorefresh.

the class RxJavaUtils method createCompletable.

@CheckResult
@NonNull
public static <T, Data> Completable createCompletable(@NonNull StorIOSQLite storIOSQLite, @NonNull PreparedCompletableOperation<T, Data> operation) {
    throwExceptionIfRxJava2IsNotAvailable("asRxCompletable()");
    final Completable completable = Completable.create(new CompletableOnSubscribeExecuteAsBlocking(operation));
    return subscribeOn(storIOSQLite, completable);
}
Also used : Completable(io.reactivex.Completable) CompletableOnSubscribeExecuteAsBlocking(com.pushtorefresh.storio3.operations.internal.CompletableOnSubscribeExecuteAsBlocking) CheckResult(android.support.annotation.CheckResult) NonNull(android.support.annotation.NonNull)

Example 4 with CompletableOnSubscribeExecuteAsBlocking

use of com.pushtorefresh.storio3.operations.internal.CompletableOnSubscribeExecuteAsBlocking in project storio by pushtorefresh.

the class CompletableOnSubscribeExecuteAsBlockingTest method shouldCallOnErrorIfExceptionOccurred.

@SuppressWarnings({ "ThrowableInstanceNeverThrown", "ResourceType" })
@Test
public void shouldCallOnErrorIfExceptionOccurred() {
    final PreparedCompletableOperation preparedOperation = mock(PreparedCompletableOperation.class);
    StorIOException expectedException = new StorIOException("test exception");
    when(preparedOperation.executeAsBlocking()).thenThrow(expectedException);
    TestObserver testObserver = new TestObserver();
    Completable completable = Completable.create(new CompletableOnSubscribeExecuteAsBlocking(preparedOperation));
    verifyZeroInteractions(preparedOperation);
    completable.subscribe(testObserver);
    testObserver.assertError(expectedException);
    testObserver.assertNotComplete();
    verify(preparedOperation).executeAsBlocking();
    verify(preparedOperation, never()).asRxFlowable(any(BackpressureStrategy.class));
    verify(preparedOperation, never()).asRxSingle();
    verify(preparedOperation, never()).asRxCompletable();
}
Also used : Completable(io.reactivex.Completable) StorIOException(com.pushtorefresh.storio3.StorIOException) PreparedCompletableOperation(com.pushtorefresh.storio3.operations.PreparedCompletableOperation) BackpressureStrategy(io.reactivex.BackpressureStrategy) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test)

Aggregations

Completable (io.reactivex.Completable)4 CheckResult (android.support.annotation.CheckResult)2 NonNull (android.support.annotation.NonNull)2 PreparedCompletableOperation (com.pushtorefresh.storio3.operations.PreparedCompletableOperation)2 CompletableOnSubscribeExecuteAsBlocking (com.pushtorefresh.storio3.operations.internal.CompletableOnSubscribeExecuteAsBlocking)2 BackpressureStrategy (io.reactivex.BackpressureStrategy)2 TestObserver (io.reactivex.observers.TestObserver)2 Test (org.junit.Test)2 StorIOException (com.pushtorefresh.storio3.StorIOException)1