Search in sources :

Example 16 with Completable

use of rx.Completable in project azure-sdk-for-java by Azure.

the class ServiceBusNamespaceImpl method createResourceAsync.

@Override
public Observable<ServiceBusNamespace> createResourceAsync() {
    Completable createNamespaceCompletable = this.manager().inner().namespaces().createOrUpdateAsync(this.resourceGroupName(), this.name(), this.inner()).map(new Func1<NamespaceInner, NamespaceInner>() {

        @Override
        public NamespaceInner call(NamespaceInner inner) {
            setInner(inner);
            return inner;
        }
    }).toCompletable();
    Completable childrenOperationsCompletable = submitChildrenOperationsAsync();
    final ServiceBusNamespace self = this;
    return Completable.concat(createNamespaceCompletable, childrenOperationsCompletable).doOnTerminate(new Action0() {

        @Override
        public void call() {
            initChildrenOperationsCache();
        }
    }).andThen(Observable.just(self));
}
Also used : Completable(rx.Completable) Action0(rx.functions.Action0) ServiceBusNamespace(com.microsoft.azure.management.servicebus.ServiceBusNamespace) Func1(rx.functions.Func1)

Example 17 with Completable

use of rx.Completable in project azure-sdk-for-java by Azure.

the class TopicImpl method createChildResourceAsync.

@Override
protected Observable<Topic> createChildResourceAsync() {
    Completable createTopicCompletable = this.manager().inner().topics().createOrUpdateAsync(this.resourceGroupName(), this.parentName, this.name(), this.inner()).map(new Func1<TopicInner, TopicInner>() {

        @Override
        public TopicInner call(TopicInner inner) {
            setInner(inner);
            return inner;
        }
    }).toCompletable();
    Completable childrenOperationsCompletable = submitChildrenOperationsAsync();
    final Topic self = this;
    return Completable.concat(createTopicCompletable, childrenOperationsCompletable).doOnTerminate(new Action0() {

        @Override
        public void call() {
            initChildrenOperationsCache();
        }
    }).andThen(Observable.just(self));
}
Also used : Completable(rx.Completable) Action0(rx.functions.Action0) Func1(rx.functions.Func1) Topic(com.microsoft.azure.management.servicebus.Topic)

Example 18 with Completable

use of rx.Completable in project storio by pushtorefresh.

the class RxJavaUtils method createCompletable.

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

Example 19 with Completable

use of rx.Completable in project storio by pushtorefresh.

the class OnSubscribeExecuteAsBlockingCompletableTest method shouldExecuteAsBlockingAfterSubscription.

@SuppressWarnings("ResourceType")
@Test
public void shouldExecuteAsBlockingAfterSubscription() {
    final PreparedWriteOperation preparedOperation = mock(PreparedWriteOperation.class);
    TestSubscriber testSubscriber = new TestSubscriber();
    verifyZeroInteractions(preparedOperation);
    Completable completable = Completable.create(OnSubscribeExecuteAsBlockingCompletable.newInstance(preparedOperation));
    verifyZeroInteractions(preparedOperation);
    completable.subscribe(testSubscriber);
    testSubscriber.assertNoErrors();
    testSubscriber.assertCompleted();
    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) TestSubscriber(rx.observers.TestSubscriber) Test(org.junit.Test)

Example 20 with Completable

use of rx.Completable in project storio by pushtorefresh.

the class DeleteOperationDesignTest method deleteObjectsCompletable.

@Test
public void deleteObjectsCompletable() {
    final List<Article> articles = new ArrayList<Article>();
    Completable completable = storIOContentResolver().delete().objects(articles).withDeleteResolver(ArticleMeta.DELETE_RESOLVER).prepare().asRxCompletable();
}
Also used : Completable(rx.Completable) ArrayList(java.util.ArrayList) 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