@Test public void testToObservableError() { final TestSubscriber<Response> tester = new TestSubscriber<>(); try (AsyncHttpClient client = asyncHttpClient()) { Observable<Response> o1 = AsyncHttpObservable.toObservable(() -> client.prepareGet("https: o1.subscribe(tester); tester.awaitTerminalEvent(); tester.assertTerminalEvent(); tester.assertNoErrors(); tester.assertCompleted(); List<Response> responses = tester.getOnNextEvents(); assertNotNull(responses); assertEquals(responses.size(), 1); assertEquals(responses.get(0).getStatusCode(), 404); } catch (Exception e) { Thread.currentThread().interrupt(); } }
public static Observable<Response> toObservable(final Func0<BoundRequestBuilder> supplier) { final BoundRequestBuilder builder = supplier.call(); return Observable.unsafeCreate(new Observable.OnSubscribe<Response>() { @Override public void call(final Subscriber<? super Response> subscriber) { try { AsyncCompletionHandler<Void> handler = new AsyncCompletionHandler<Void>() { @Override public Void onCompleted(Response response) throws Exception { subscriber.onNext(response); subscriber.onCompleted(); return null; } @Override public void onThrowable(Throwable t) { subscriber.onError(t); } }; builder.execute(handler); } catch (Throwable t) { subscriber.onError(t); } } }); }
AsyncHttpObservable { public static Observable<Response> toObservable(final Func0<BoundRequestBuilder> supplier) { final BoundRequestBuilder builder = supplier.call(); return Observable.unsafeCreate(new Observable.OnSubscribe<Response>() { @Override public void call(final Subscriber<? super Response> subscriber) { try { AsyncCompletionHandler<Void> handler = new AsyncCompletionHandler<Void>() { @Override public Void onCompleted(Response response) throws Exception { subscriber.onNext(response); subscriber.onCompleted(); return null; } @Override public void onThrowable(Throwable t) { subscriber.onError(t); } }; builder.execute(handler); } catch (Throwable t) { subscriber.onError(t); } } }); } }
AsyncHttpObservable { public static Observable<Response> toObservable(final Func0<BoundRequestBuilder> supplier) { final BoundRequestBuilder builder = supplier.call(); return Observable.unsafeCreate(new Observable.OnSubscribe<Response>() { @Override public void call(final Subscriber<? super Response> subscriber) { try { AsyncCompletionHandler<Void> handler = new AsyncCompletionHandler<Void>() { @Override public Void onCompleted(Response response) throws Exception { subscriber.onNext(response); subscriber.onCompleted(); return null; } @Override public void onThrowable(Throwable t) { subscriber.onError(t); } }; builder.execute(handler); } catch (Throwable t) { subscriber.onError(t); } } }); }  }
AsyncHttpObservable { public static Observable<Response> toObservable(final Func0<BoundRequestBuilder> supplier) { final BoundRequestBuilder builder = supplier.call(); return Observable.unsafeCreate(new Observable.OnSubscribe<Response>() { @Override public void call(final Subscriber<? super Response> subscriber) { try { AsyncCompletionHandler<Void> handler = new AsyncCompletionHandler<Void>() { @Override public Void onCompleted(Response response) throws Exception { subscriber.onNext(response); subscriber.onCompleted(); return null; } @Override public void onThrowable(Throwable t) { subscriber.onError(t); } }; builder.execute(handler); } catch (Throwable t) { subscriber.onError(t); } } }); }  static Observable<Response> toObservable(final Func0<BoundRequestBuilder> supplier); static Observable<Response> observe(final Func0<BoundRequestBuilder> supplier); }
AsyncHttpObservable { public static Observable<Response> toObservable(final Func0<BoundRequestBuilder> supplier) { final BoundRequestBuilder builder = supplier.call(); return Observable.unsafeCreate(new Observable.OnSubscribe<Response>() { @Override public void call(final Subscriber<? super Response> subscriber) { try { AsyncCompletionHandler<Void> handler = new AsyncCompletionHandler<Void>() { @Override public Void onCompleted(Response response) throws Exception { subscriber.onNext(response); subscriber.onCompleted(); return null; } @Override public void onThrowable(Throwable t) { subscriber.onError(t); } }; builder.execute(handler); } catch (Throwable t) { subscriber.onError(t); } } }); }  static Observable<Response> toObservable(final Func0<BoundRequestBuilder> supplier); static Observable<Response> observe(final Func0<BoundRequestBuilder> supplier);  }