@Test
 public void testFulfillAdaptedFunctions2() {
   MySubscriber<String> subscriber = new MySubscriber<>();
   Handler<AsyncResult<String>> o = RxHelper.toFuture(subscriber::onNext, subscriber::onError);
   o.handle(Future.succeededFuture("abc"));
   subscriber.assertItem("abc").assertEmpty();
 }
 @Test
 public void testFulfillAdaptedSubscriber() {
   MySubscriber<String> subscriber = new MySubscriber<>();
   Handler<AsyncResult<String>> o = RxHelper.toFuture(subscriber);
   o.handle(Future.succeededFuture("abc"));
   subscriber.assertItem("abc").assertCompleted().assertEmpty();
 }
 @Test
 public void testRejectAdaptedSubscriber() {
   MySubscriber<String> subscriber = new MySubscriber<>();
   Handler<AsyncResult<String>> o = RxHelper.toFuture(subscriber);
   Exception e = new Exception();
   o.handle(Future.failedFuture(e));
   subscriber.assertError(e).assertEmpty();
 }
 @Test
 public void testCompleteWithSuccessBeforeSubscribe() {
   ObservableFuture<String> o = RxHelper.observableFuture();
   o.toHandler().handle(Future.succeededFuture("abc"));
   MySubscriber<String> subscriber = new MySubscriber<>();
   o.subscribe(subscriber);
   subscriber.assertItem("abc").assertCompleted().assertEmpty();
 }
 @Test
 public void testRejectAdaptedFunctions2() {
   MySubscriber<String> subscriber = new MySubscriber<>();
   Handler<AsyncResult<String>> o = RxHelper.toFuture(subscriber::onNext, subscriber::onError);
   Exception cause = new Exception();
   o.handle(Future.failedFuture(cause));
   subscriber.assertError(cause).assertEmpty();
 }
 @Test
 public void testUnsubscribeBeforeResolve() {
   ObservableFuture<String> o = RxHelper.observableFuture();
   MySubscriber<String> subscriber = new MySubscriber<>();
   Subscription sub = o.subscribe(subscriber);
   sub.unsubscribe();
   assertTrue(sub.isUnsubscribed());
   subscriber.assertEmpty();
 }
 @Test
 public void testCompleteWithFailureBeforeSubscribe() {
   ObservableFuture<String> o = RxHelper.observableFuture();
   Throwable failure = new Throwable();
   o.toHandler().handle(Future.failedFuture(failure));
   MySubscriber<String> subscriber = new MySubscriber<>();
   o.subscribe(subscriber);
   subscriber.assertError(failure).assertEmpty();
 }
 @Test
 public void testRejectAdaptedFunctions1() {
   MySubscriber<String> subscriber = new MySubscriber<>();
   Handler<AsyncResult<String>> o = RxHelper.toFuture(subscriber::onNext);
   Exception cause = new Exception();
   try {
     o.handle(Future.failedFuture(cause));
   } catch (OnErrorNotImplementedException e) {
     assertSame(cause, e.getCause());
   }
   subscriber.assertEmpty();
 }
 private Observable<Void> writeBodyObservable(
     HttpClientRequest clientRequest, MailgunSendRequest sendRequest) {
   ObservableFuture<Void> observableFuture = RxHelper.observableFuture();
   writeBody(clientRequest, sendRequest, observableFuture.toHandler());
   return observableFuture;
 }
예제 #10
0
 /**
  * Completion handler to receive a completion signal when this completions completes.
  *
  * @return
  */
 public Observable<T> handlerObservable() {
   io.vertx.rx.java.ObservableFuture<T> completionHandler =
       io.vertx.rx.java.RxHelper.observableFuture();
   handler(completionHandler.toHandler());
   return completionHandler;
 }