Search in sources :

Example 36 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 37 with Completable

use of rx.Completable in project vertx-openshift-it by cescoffier.

the class OracleVerticle method start.

@Override
public void start() throws Exception {
    Router router = Router.router(vertx);
    router.route().handler(BodyHandler.create());
    router.route("/api/vegetables/:id").handler(this::validateId);
    router.get("/api/vegetables").handler(this::getAll);
    router.post("/api/vegetables").handler(this::addOne);
    router.get("/api/vegetables/:id").handler(this::getOne);
    router.put("/api/vegetables/:id").handler(this::updateOne);
    router.delete("/api/vegetables/:id").handler(this::deleteOne);
    router.get("/healthcheck").handler(rc -> rc.response().end("OK"));
    JsonObject config = TestUtils.allocateDatabase("oracle", true);
    JDBCClient jdbcClient = JDBCClient.createShared(vertx, config);
    vegetableTableExists(jdbcClient).subscribe(VegetableTableExists -> {
        Completable firstAction = initDatabase(vertx, jdbcClient);
        if (VegetableTableExists) {
            firstAction = dropVegetableTable(jdbcClient).andThen(initDatabase(vertx, jdbcClient));
        }
        firstAction.andThen(initHttpServer(router, jdbcClient)).subscribe((http) -> System.out.println("Server ready on port " + http.actualPort()), Throwable::printStackTrace);
    });
}
Also used : Completable(rx.Completable) Router(io.vertx.rxjava.ext.web.Router) JsonObject(io.vertx.core.json.JsonObject) JDBCClient(io.vertx.rxjava.ext.jdbc.JDBCClient)

Example 38 with Completable

use of rx.Completable in project components by Talend.

the class CouchbaseStreamingConnectionTest method testConnect.

@Test
public void testConnect() {
    Completable completable = Completable.complete();
    Mockito.when(client.connect()).thenReturn(completable);
    streamingConnection.connect();
    Assert.assertTrue(!streamingConnection.isClosed());
}
Also used : Completable(rx.Completable) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 39 with Completable

use of rx.Completable in project Hystrix by Netflix.

the class BasicObservableTest method testGetCompletableUserWithRegularFallback.

@Test
public void testGetCompletableUserWithRegularFallback() {
    Completable completable = userService.getCompletableUserWithRegularFallback(null, "name: ");
    completable.<User>toObservable().subscribe(new Action1<User>() {

        @Override
        public void call(User user) {
            assertEquals("default_id", user.getId());
        }
    });
    com.netflix.hystrix.HystrixInvokableInfo getUserCommand = getHystrixCommandByKey("getCompletableUserWithRegularFallback");
    assertTrue(getUserCommand.getExecutionEvents().contains(HystrixEventType.FAILURE));
    assertTrue(getUserCommand.getExecutionEvents().contains(HystrixEventType.FALLBACK_SUCCESS));
}
Also used : Completable(rx.Completable) User(com.netflix.hystrix.contrib.javanica.test.common.domain.User) Test(org.junit.Test) BasicHystrixTest(com.netflix.hystrix.contrib.javanica.test.common.BasicHystrixTest)

Example 40 with Completable

use of rx.Completable in project feign by OpenFeign.

the class HystrixBuilderTest method rxCompletableFailWithoutFallback.

@Test
public void rxCompletableFailWithoutFallback() {
    server.enqueue(new MockResponse().setResponseCode(500));
    final TestInterface api = target(TestInterface.class, "http://localhost:" + server.getPort());
    final Completable completable = api.completable();
    assertThat(completable).isNotNull();
    assertThat(server.getRequestCount()).isEqualTo(0);
    final TestSubscriber<String> testSubscriber = new TestSubscriber<String>();
    completable.subscribe(testSubscriber);
    testSubscriber.awaitTerminalEvent();
    testSubscriber.assertError(HystrixRuntimeException.class);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) Completable(rx.Completable) TestSubscriber(rx.observers.TestSubscriber) Test(org.junit.Test)

Aggregations

Completable (rx.Completable)42 Test (org.junit.Test)32 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 BasicHystrixTest (com.netflix.hystrix.contrib.javanica.test.common.BasicHystrixTest)2 User (com.netflix.hystrix.contrib.javanica.test.common.domain.User)2 PreparedWriteOperation (com.pushtorefresh.storio.operations.PreparedWriteOperation)2 OnSubscribeExecuteAsBlockingCompletable (com.pushtorefresh.storio.operations.internal.OnSubscribeExecuteAsBlockingCompletable)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 InvalidDataAccessApiUsageException (org.springframework.dao.InvalidDataAccessApiUsageException)2 Mono (reactor.core.publisher.Mono)2 CloudException (com.microsoft.azure.CloudException)1 Network (com.microsoft.azure.management.network.Network)1 NetworkInterface (com.microsoft.azure.management.network.NetworkInterface)1