@Test public void c1c2Error() { toV2Completable(rx.Completable.error(new RuntimeException("Forced failure"))).test() .assertFailureAndMessage(RuntimeException.class, "Forced failure"); }
@Test public void c1m2Error() { toV2Maybe(rx.Completable.error(new RuntimeException("Forced failure"))).test() .assertFailureAndMessage(RuntimeException.class, "Forced failure"); }
@Override public Completable rxStart() { return Completable.error(err); } }
@Override public Completable warDeployAsync(File warFile, String appName) { try { return warDeployAsync(new FileInputStream(warFile), appName); } catch (IOException e) { return Completable.error(e); } }
@Override public Completable rxStop() { return Completable.error(err); } }
@Override public Completable zipDeployAsync(File zipFile) { try { return zipDeployAsync(new FileInputStream(zipFile)); } catch (IOException e) { return Completable.error(e); } }
@Override public Completable zipDeployAsync(File zipFile) { try { return zipDeployAsync(new FileInputStream(zipFile)); } catch (IOException e) { return Completable.error(e); } } }
@Override public Completable warDeployAsync(File warFile, String appName) { try { return warDeployAsync(new FileInputStream(warFile), appName); } catch (IOException e) { return Completable.error(e); } }
@Override public Completable zipDeployAsync(File zipFile) { try { return zipDeployAsync(new FileInputStream(zipFile)); } catch (IOException e) { return Completable.error(e); } }
@Override public Completable zipDeployAsync(File zipFile) { try { return zipDeployAsync(new FileInputStream(zipFile)); } catch (IOException e) { return Completable.error(e); } } }
Completable zipDeployAsync(InputStream zipFile) { try { RequestBody body = RequestBody.create(MediaType.parse("application/octet-stream"), ByteStreams.toByteArray(zipFile)); return getCompletable(service.zipDeploy(body)); } catch (IOException e) { return Completable.error(e); } }
Completable warDeployAsync(InputStream warFile, String appName) { try { RequestBody body = RequestBody.create(MediaType.parse("application/octet-stream"), ByteStreams.toByteArray(warFile)); return getCompletable(service.warDeploy(body, appName)); } catch (IOException e) { return Completable.error(e); } }
@NonNull public static Completable asObservableSnack(Activity activity, int msg, int actionMsg, View.OnClickListener action) { Snackbar snackbar = asSnackInternal(activity, msg, actionMsg, action, Snackbar.LENGTH_SHORT); if (snackbar != null) { return asSnackObservableInternal(snackbar); } return Completable.error(new IllegalStateException("Extracted view from activity is null")); }
@Override public Completable init(XMLChunkMeta meta) { return canMerge(meta) .flatMapCompletable(b -> { if (b) { return mergeParents(meta); } return Completable.error(new IllegalArgumentException( "Chunk cannot be merged with this strategy")); }); }
@Override public Completable call(Throwable throwable) { if (throwable instanceof CloudException && ((CloudException) throwable).response().code() == 200) { return Completable.complete(); } else { return Completable.error(throwable); } } });
@Override public Completable call(Throwable throwable) { return conductor.stop() .andThen(Completable.error(new BootstrapException("Could not connect to Cluster/Bucket", throwable))); } });
protected Completable rxAssertEquals(Object expected, Object actual) { Completable completable; try { Assert.assertEquals(expected, actual); completable = Completable.complete(); } catch (AssertionError error) { completable = Completable.error(error); } return completable; }
@Override public Completable call(Completable upstream) { return sqlConnection.rxSetAutoCommit(false).toCompletable() .andThen(upstream) .andThen(sqlConnection.rxCommit().toCompletable()) .onErrorResumeNext(throwable -> { return sqlConnection.rxRollback().toCompletable().onErrorComplete() .andThen(sqlConnection.rxSetAutoCommit(true).toCompletable().onErrorComplete()) .andThen(Completable.error(throwable)); }).andThen(sqlConnection.rxSetAutoCommit(true).toCompletable()); } }
@Override public Completable call(Completable upstream) { return sqlConnection.rxSetAutoCommit(false).toCompletable() .andThen(upstream) .andThen(sqlConnection.rxCommit().toCompletable()) .onErrorResumeNext(throwable -> { return sqlConnection.rxRollback().toCompletable().onErrorComplete() .andThen(sqlConnection.rxSetAutoCommit(true).toCompletable().onErrorComplete()) .andThen(Completable.error(throwable)); }).andThen(sqlConnection.rxSetAutoCommit(true).toCompletable()); } }
private Completable inTransaction(Exception e) throws Exception { return client.rxGetConnection().flatMapCompletable(conn -> { return rxInsertExtraFolks(conn) .andThen(uniqueNames(conn)) .<List<String>>collect(ArrayList::new, List::add).toSingle() .flatMapCompletable(names -> rxAssertEquals(Arrays.asList(namesWithExtraFolks()), names)) .compose(upstream -> e == null ? upstream : upstream.andThen(Completable.error(e))) .compose(SQLClientHelper.txCompletableTransformer(conn)) .andThen(rxAssertAutoCommit(conn)) .doAfterTerminate(conn::close); }); } }