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));
}
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);
});
}
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());
}
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));
}
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);
}
Aggregations