Search in sources :

Example 6 with Completable

use of rx.Completable in project storio by pushtorefresh.

the class OnSubscribeExecuteAsBlockingCompletableTest method shouldCallOnErrorIfExceptionOccurred.

@SuppressWarnings({ "ThrowableInstanceNeverThrown", "ResourceType" })
@Test
public void shouldCallOnErrorIfExceptionOccurred() {
    final PreparedWriteOperation preparedOperation = mock(PreparedWriteOperation.class);
    StorIOException expectedException = new StorIOException("test exception");
    when(preparedOperation.executeAsBlocking()).thenThrow(expectedException);
    TestSubscriber testSubscriber = new TestSubscriber();
    Completable completable = Completable.create(OnSubscribeExecuteAsBlockingCompletable.newInstance(preparedOperation));
    verifyZeroInteractions(preparedOperation);
    completable.subscribe(testSubscriber);
    testSubscriber.assertError(expectedException);
    testSubscriber.assertTerminalEvent();
    verify(preparedOperation).executeAsBlocking();
    verify(preparedOperation, never()).asRxObservable();
    verify(preparedOperation, never()).asRxSingle();
    verify(preparedOperation, never()).asRxCompletable();
}
Also used : Completable(rx.Completable) PreparedWriteOperation(com.pushtorefresh.storio.operations.PreparedWriteOperation) StorIOException(com.pushtorefresh.storio.StorIOException) TestSubscriber(rx.observers.TestSubscriber) Test(org.junit.Test)

Example 7 with Completable

use of rx.Completable in project storio by pushtorefresh.

the class PreparedDeleteByQueryTest method shouldDeleteByQueryAsCompletable.

@Test
public void shouldDeleteByQueryAsCompletable() {
    final DeleteByQueryStub deleteStub = DeleteByQueryStub.newInstance();
    final Completable completable = deleteStub.storIOContentResolver.delete().byQuery(deleteStub.deleteQuery).withDeleteResolver(deleteStub.deleteResolver).prepare().asRxCompletable();
    deleteStub.verifyBehavior(completable);
}
Also used : Completable(rx.Completable) Test(org.junit.Test)

Example 8 with Completable

use of rx.Completable in project storio by pushtorefresh.

the class RxJavaUtils method createCompletable.

@CheckResult
@NonNull
public static <T> Completable createCompletable(@NonNull StorIOSQLite storIOSQLite, @NonNull PreparedOperation<T> operation) {
    throwExceptionIfRxJavaIsNotAvailable("asRxCompletable()");
    final Completable completable = Completable.create(OnSubscribeExecuteAsBlockingCompletable.newInstance(operation));
    return subscribeOn(storIOSQLite, completable);
}
Also used : Completable(rx.Completable) OnSubscribeExecuteAsBlockingCompletable(com.pushtorefresh.storio.operations.internal.OnSubscribeExecuteAsBlockingCompletable) CheckResult(android.support.annotation.CheckResult) NonNull(android.support.annotation.NonNull)

Example 9 with Completable

use of rx.Completable in project storio by pushtorefresh.

the class DeleteOperationDesignTest method deleteCollectionOfObjectsCompletable.

@Test
public void deleteCollectionOfObjectsCompletable() {
    List<User> users = new ArrayList<User>();
    Completable completableDelete = storIOSQLite().delete().objects(users).withDeleteResolver(UserTableMeta.DELETE_RESOLVER).prepare().asRxCompletable();
}
Also used : Completable(rx.Completable) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 10 with Completable

use of rx.Completable in project storio by pushtorefresh.

the class PutOperationDesignTest method putObjectCompletable.

@Test
public void putObjectCompletable() {
    User user = newUser();
    Completable completablePut = storIOSQLite().put().object(user).withPutResolver(UserTableMeta.PUT_RESOLVER).prepare().asRxCompletable();
}
Also used : Completable(rx.Completable) Test(org.junit.Test)

Aggregations

Completable (rx.Completable)31 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)6 TestSubscriber (rx.observers.TestSubscriber)6 MockResponse (okhttp3.mockwebserver.MockResponse)4 Func1 (rx.functions.Func1)4 ContentValues (android.content.ContentValues)3 Action0 (rx.functions.Action0)3 CheckResult (android.support.annotation.CheckResult)2 NonNull (android.support.annotation.NonNull)2 PreparedWriteOperation (com.pushtorefresh.storio.operations.PreparedWriteOperation)2 OnSubscribeExecuteAsBlockingCompletable (com.pushtorefresh.storio.operations.internal.OnSubscribeExecuteAsBlockingCompletable)2 CloudException (com.microsoft.azure.CloudException)1 Network (com.microsoft.azure.management.network.Network)1 NetworkInterface (com.microsoft.azure.management.network.NetworkInterface)1 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)1 Region (com.microsoft.azure.management.resources.fluentcore.arm.Region)1 Resource (com.microsoft.azure.management.resources.fluentcore.arm.models.Resource)1 Creatable (com.microsoft.azure.management.resources.fluentcore.model.Creatable)1 Indexable (com.microsoft.azure.management.resources.fluentcore.model.Indexable)1