@Test public void asyncActionSingleErrors() { AmazonWebServiceRequest someRequest = AmazonWebServiceRequest.NOOP; final MockAsyncClient<AmazonWebServiceRequest, String> client = new MockAsyncClient<>(someRequest, "some response"); RuntimeException exception = new RuntimeException("error when initiating an async operation"); final Single<String> completable = AwsObservableExt.asyncActionSingle(supplier -> client.throwException(exception)); TestScheduler testScheduler = Schedulers.test(); final AssertableSubscriber<String> subscriber = completable.subscribeOn(testScheduler).test(); testScheduler.triggerActions(); subscriber.assertError(exception); }
public static <REQ extends AmazonWebServiceRequest, RES> Single<RES> asyncActionSingle(Func1<SingleHandlerSupplier<RES>, Future<RES>> action) { return Single.create(subscriber -> { try { final Future<RES> result = action.call(new SingleHandlerSupplier<>(subscriber)); subscriber.add(Subscriptions.create(() -> result.cancel(true))); } catch (Throwable t) { Exceptions.throwIfFatal(t); subscriber.onError(t); } }); }
AwsObservableExt { public static <REQ extends AmazonWebServiceRequest, RES> Single<RES> asyncActionSingle(Func1<SingleHandlerSupplier<RES>, Future<RES>> action) { return Single.create(subscriber -> { try { final Future<RES> result = action.call(new SingleHandlerSupplier<>(subscriber)); subscriber.add(Subscriptions.create(() -> result.cancel(true))); } catch (Throwable t) { Exceptions.throwIfFatal(t); subscriber.onError(t); } }); } }
AwsObservableExt { public static <REQ extends AmazonWebServiceRequest, RES> Single<RES> asyncActionSingle(Func1<SingleHandlerSupplier<RES>, Future<RES>> action) { return Single.create(subscriber -> { try { final Future<RES> result = action.call(new SingleHandlerSupplier<>(subscriber)); subscriber.add(Subscriptions.create(() -> result.cancel(true))); } catch (Throwable t) { Exceptions.throwIfFatal(t); subscriber.onError(t); } }); }  }
AwsObservableExt { public static <REQ extends AmazonWebServiceRequest, RES> Single<RES> asyncActionSingle(Func1<SingleHandlerSupplier<RES>, Future<RES>> action) { return Single.create(subscriber -> { try { final Future<RES> result = action.call(new SingleHandlerSupplier<>(subscriber)); subscriber.add(Subscriptions.create(() -> result.cancel(true))); } catch (Throwable t) { Exceptions.throwIfFatal(t); subscriber.onError(t); } }); }  static Completable asyncActionCompletable(Func1<CompletableHandlerSupplier, Future<?>> action); static Single<RES> asyncActionSingle(Func1<SingleHandlerSupplier<RES>, Future<RES>> action); }
AwsObservableExt { public static <REQ extends AmazonWebServiceRequest, RES> Single<RES> asyncActionSingle(Func1<SingleHandlerSupplier<RES>, Future<RES>> action) { return Single.create(subscriber -> { try { final Future<RES> result = action.call(new SingleHandlerSupplier<>(subscriber)); subscriber.add(Subscriptions.create(() -> result.cancel(true))); } catch (Throwable t) { Exceptions.throwIfFatal(t); subscriber.onError(t); } }); }  static Completable asyncActionCompletable(Func1<CompletableHandlerSupplier, Future<?>> action); static Single<RES> asyncActionSingle(Func1<SingleHandlerSupplier<RES>, Future<RES>> action);  }