@Test public void ct2ToCt1() { final int[] calls = { 0 }; CompletableTransformer transformer = new CompletableTransformer() { @Override public Completable apply(Completable o) { return o.doOnComplete(new io.reactivex.functions.Action() { @Override public void run() { calls[0]++; } }); } }; rx.Completable.complete() .compose(toV1Transformer(transformer)) .test() .assertResult(); assertEquals(1, calls[0]); }
/** * Generates a {@link Completable} from {@link SQLConnection} operations executed inside a transaction. * * @param client the {@link SQLClient} * @param sourceSupplier a user-provided function returning a {@link Completable} generated by interacting with the given {@link SQLConnection} * @return a {@link Completable} generated from {@link SQLConnection} operations executed inside a transaction */ public static Completable inTransactionCompletable(SQLClient client, Function<SQLConnection, Completable> sourceSupplier) { return usingConnectionCompletable(client, conn -> sourceSupplier.apply(conn).compose(txCompletableTransformer(conn))); }
/** * Generates a {@link Completable} from {@link SQLConnection} operations executed inside a transaction. * * @param client the {@link SQLClient} * @param sourceSupplier a user-provided function returning a {@link Completable} generated by interacting with the given {@link SQLConnection} * @return a {@link Completable} generated from {@link SQLConnection} operations executed inside a transaction */ public static Completable inTransactionCompletable(SQLClient client, Function<SQLConnection, Completable> sourceSupplier) { return usingConnectionCompletable(client, conn -> sourceSupplier.apply(conn).compose(txCompletableTransformer(conn))); }
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); }); } }