Java Code Examples for io.vertx.rx.java.RxHelper#observableFuture()

The following examples show how to use io.vertx.rx.java.RxHelper#observableFuture() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AsyncResultHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompleteWithFailureAfterSubscribe() {
  ObservableFuture<String> o = RxHelper.observableFuture();
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  subscribe(o, subscriber);
  subscriber.assertEmpty();
  Throwable failure = new Throwable();
  o.toHandler().handle(Future.failedFuture(failure));
  subscriber.assertError(failure).assertEmpty();
}
 
Example 2
Source File: AsyncResultHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompleteTwice() {
  ObservableFuture<String> o = RxHelper.observableFuture();
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  subscribe(o, subscriber);
  o.toHandler().handle(Future.succeededFuture("abc"));
  o.toHandler().handle(Future.succeededFuture("def"));
  subscriber.assertItem("abc").assertCompleted().assertEmpty();
}
 
Example 3
Source File: AsyncResultHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompleteWithFailureBeforeSubscribe() {
  ObservableFuture<String> o = RxHelper.observableFuture();
  Throwable failure = new Throwable();
  o.toHandler().handle(Future.failedFuture(failure));
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  subscribe(o, subscriber);
  subscriber.assertError(failure).assertEmpty();
}
 
Example 4
Source File: AsyncResultHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompleteWithSuccessAfterSubscribe() {
  ObservableFuture<String> o = RxHelper.observableFuture();
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  subscribe(o, subscriber);
  subscriber.assertEmpty();
  o.toHandler().handle(Future.succeededFuture("abc"));
  subscriber.assertItem("abc").assertCompleted().assertEmpty();
}
 
Example 5
Source File: DefaultRxElasticSearchService.java    From vertx-elasticsearch-service with Apache License 2.0 5 votes vote down vote up
@Override
public Observable<BulkResponse> bulk(List<BulkIndexOptions> bulkIndexOptions,
                                     List<BulkUpdateOptions> bulkUpdateOptions,
                                     List<BulkDeleteOptions> bulkDeleteOptions,
                                     BulkOptions bulkOptions) {
    final ObservableFuture<BulkResponse> observableFuture = RxHelper.observableFuture();
    elasticSearchService.bulk(bulkIndexOptions, bulkUpdateOptions, bulkDeleteOptions, bulkOptions, observableFuture.toHandler());
    return observableFuture;
}
 
Example 6
Source File: AsyncResultHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompleteWithSuccessBeforeSubscribe() {
  ObservableFuture<String> o = RxHelper.observableFuture();
  o.toHandler().handle(Future.succeededFuture("abc"));
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  subscribe(o, subscriber);
  subscriber.assertItem("abc").assertCompleted().assertEmpty();
}
 
Example 7
Source File: AsyncResultHandlerTest.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailTwice() {
  ObservableFuture<String> o = RxHelper.observableFuture();
  TestSubscriber<String> subscriber = new TestSubscriber<>();
  subscribe(o, subscriber);
  Throwable failure = new Throwable();
  o.toHandler().handle(Future.failedFuture(failure));
  o.toHandler().handle(Future.failedFuture(new Throwable()));
  subscriber.assertError(failure).assertEmpty();
}
 
Example 8
Source File: DefaultRxElasticSearchAdminService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<Void> createIndex(String index, JsonObject source, CreateIndexOptions options) {
    final ObservableFuture<Void> observableFuture = RxHelper.observableFuture();
    elasticSearchAdminService.createIndex(index, source, options, observableFuture.toHandler());
    return observableFuture;
}
 
Example 9
Source File: RxMicroServiceVerticle.java    From vertx-microservices-workshop with Apache License 2.0 4 votes vote down vote up
private Single<Void> rxPublish(Record record) {
  ObservableFuture<Void> adapter = RxHelper.observableFuture();
  publish(record, adapter.toHandler());
  return adapter.toSingle();
}
 
Example 10
Source File: DefaultRxElasticSearchAdminService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<Void> deleteTemplate(String name, TemplateOptions options) {
    final ObservableFuture<Void> observableFuture = RxHelper.observableFuture();
    elasticSearchAdminService.deleteTemplate(name, options, observableFuture.toHandler());
    return observableFuture;
}
 
Example 11
Source File: DefaultRxElasticSearchAdminService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<Void> putTemplate(String name, JsonObject source, TemplateOptions options) {
    final ObservableFuture<Void> observableFuture = RxHelper.observableFuture();
    elasticSearchAdminService.putTemplate(name, source, options, observableFuture.toHandler());
    return observableFuture;
}
 
Example 12
Source File: DefaultRxElasticSearchAdminService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<Void> deleteIndex(List<String> indices, DeleteIndexOptions options) {
    final ObservableFuture<Void> observableFuture = RxHelper.observableFuture();
    elasticSearchAdminService.deleteIndex(indices, options, observableFuture.toHandler());
    return observableFuture;
}
 
Example 13
Source File: DefaultRxElasticSearchService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<UpdateResponse> update(String index, String type, String id, UpdateOptions options) {
    final ObservableFuture<UpdateResponse> observableFuture = RxHelper.observableFuture();
    elasticSearchService.update(index, type, id, options, observableFuture.toHandler());
    return observableFuture;
}
 
Example 14
Source File: DefaultRxElasticSearchAdminService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<Void> putMapping(List<String> indices, String type, JsonObject source, MappingOptions options) {
    final ObservableFuture<Void> observableFuture = RxHelper.observableFuture();
    elasticSearchAdminService.putMapping(indices, type, source, options, observableFuture.toHandler());
    return observableFuture;
}
 
Example 15
Source File: DefaultRxElasticSearchService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<DeleteByQueryResponse> deleteByQuery(List<String> indices, DeleteByQueryOptions options) {
    final ObservableFuture<DeleteByQueryResponse> observableFuture = RxHelper.observableFuture();
    elasticSearchService.deleteByQuery(indices, options, observableFuture.toHandler());
    return observableFuture;
}
 
Example 16
Source File: DefaultRxElasticSearchService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<MultiGetResponse> multiGet(List<MultiGetQueryOptions> multiGetQueryOptions, MultiGetOptions options) {
    final ObservableFuture<MultiGetResponse> observableFuture = RxHelper.observableFuture();
    elasticSearchService.multiGet(multiGetQueryOptions, options, observableFuture.toHandler());
    return observableFuture;
}
 
Example 17
Source File: DefaultRxElasticSearchService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<MultiSearchResponse> multiSearch(final List<MultiSearchQueryOptions> multiSearchQueryOptions, MultiSearchOptions options) {
    final ObservableFuture<MultiSearchResponse> observableFuture = RxHelper.observableFuture();
    elasticSearchService.multiSearch(multiSearchQueryOptions, options, observableFuture.toHandler());
    return observableFuture;
}
 
Example 18
Source File: DefaultRxElasticSearchService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<DeleteResponse> delete(String index, String type, String id, DeleteOptions options) {
    final ObservableFuture<DeleteResponse> observableFuture = RxHelper.observableFuture();
    elasticSearchService.delete(index, type, id, options, observableFuture.toHandler());
    return observableFuture;
}
 
Example 19
Source File: DefaultRxElasticSearchService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<SearchResponse> searchScroll(String scrollId, SearchScrollOptions options) {
    final ObservableFuture<SearchResponse> observableFuture = RxHelper.observableFuture();
    elasticSearchService.searchScroll(scrollId, options, observableFuture.toHandler());
    return observableFuture;
}
 
Example 20
Source File: DefaultRxElasticSearchService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<GetResponse> get(String index, String type, String id, GetOptions options) {
    final ObservableFuture<GetResponse> observableFuture = RxHelper.observableFuture();
    elasticSearchService.get(index, type, id, options, observableFuture.toHandler());
    return observableFuture;
}