### Question:
PreparedExecuteSQL implements PreparedCompletableOperation<Object, RawQuery> { @NonNull @CheckResult @Override public Single<Object> asRxSingle() { return RxJavaUtils.createSingle(storIOSQLite, this); } PreparedExecuteSQL(@NonNull StorIOSQLite storIOSQLite, @NonNull RawQuery rawQuery); @WorkerThread @NonNull @Override Object executeAsBlocking(); @NonNull @CheckResult @Override Flowable<Object> asRxFlowable(@NonNull BackpressureStrategy backpressureStrategy); @NonNull @CheckResult @Override Single<Object> asRxSingle(); @NonNull @Override Completable asRxCompletable(); @NonNull @Override RawQuery getData();  }### Answer:
@Test public void executeSQLSingleWithNotification() { final Stub stub = Stub.newInstanceApplyNotEmptyAffectedTablesAndTags(); final Single<Object> single = stub.storIOSQLite .executeSQL() .withQuery(stub.rawQuery) .prepare() .asRxSingle(); verify(stub.storIOSQLite).defaultRxScheduler(); stub.verifyBehavior(single); }
@Test public void executeSQLSingleWithoutNotifications() { final Stub stub = Stub.newInstanceDoNotApplyAffectedTablesAndTags(); final Single<Object> single = stub.storIOSQLite .executeSQL() .withQuery(stub.rawQuery) .prepare() .asRxSingle(); verify(stub.storIOSQLite).defaultRxScheduler(); stub.verifyBehavior(single); }
@Test public void shouldWrapExceptionIntoStorIOExceptionSingle() { final Stub stub = Stub.newInstanceApplyNotEmptyAffectedTablesAndTags(); IllegalStateException testException = new IllegalStateException("test exception"); doThrow(testException).when(stub.lowLevel).executeSQL(stub.rawQuery); final TestObserver<Object> testObserver = new TestObserver<Object>(); stub.storIOSQLite .executeSQL() .withQuery(stub.rawQuery) .prepare() .asRxSingle() .subscribe(testObserver); testObserver.awaitTerminalEvent(); testObserver.assertNoValues(); testObserver.assertError(StorIOException.class); StorIOException expected = (StorIOException) testObserver.errors().get(0); IllegalStateException cause = (IllegalStateException) expected.getCause(); assertThat(cause).hasMessage("test exception"); verify(stub.storIOSQLite).executeSQL(); verify(stub.storIOSQLite).defaultRxScheduler(); verify(stub.storIOSQLite).lowLevel(); verify(stub.lowLevel).executeSQL(stub.rawQuery); verify(stub.storIOSQLite).interceptors(); verifyNoMoreInteractions(stub.storIOSQLite, stub.lowLevel); }