### Question:
PreparedDeleteByQuery extends PreparedDelete<DeleteResult, DeleteQuery> { @NonNull @Override public Flowable<DeleteResult> asRxFlowable(@NonNull BackpressureStrategy backpressureStrategy) { return RxJavaUtils.createFlowable(storIOSQLite, this, backpressureStrategy); } PreparedDeleteByQuery(@NonNull StorIOSQLite storIOSQLite, @NonNull DeleteQuery deleteQuery, @NonNull DeleteResolver<DeleteQuery> deleteResolver); @NonNull @Override Flowable<DeleteResult> asRxFlowable(@NonNull BackpressureStrategy backpressureStrategy); @NonNull @CheckResult @Override Single<DeleteResult> asRxSingle(); @NonNull @CheckResult @Override Completable asRxCompletable(); @NonNull @Override DeleteQuery getData();  }### Answer:
@Test public void shouldPerformDeletionByQueryFlowable() { final DeleteByQueryStub stub = new DeleteByQueryStub(); final TestSubscriber<DeleteResult> testSubscriber = new TestSubscriber<DeleteResult>(); new PreparedDeleteByQuery.Builder(stub.storIOSQLite, stub.deleteQuery) .withDeleteResolver(stub.deleteResolver) .prepare() .asRxFlowable(MISSING) .subscribe(testSubscriber); testSubscriber.awaitTerminalEvent(); testSubscriber.assertNoErrors(); testSubscriber.assertValue(stub.expectedDeleteResult); verify(stub.storIOSQLite).defaultRxScheduler(); stub.verifyBehaviour(); }
@Test public void shouldWrapExceptionIntoStorIOExceptionFlowable() { final StorIOSQLite storIOSQLite = mock(StorIOSQLite.class); final StorIOSQLite.LowLevel lowLevel = mock(StorIOSQLite.LowLevel.class); when(storIOSQLite.lowLevel()).thenReturn(lowLevel); final DeleteResolver<DeleteQuery> deleteResolver = mock(DeleteResolver.class); when(deleteResolver.performDelete(same(storIOSQLite), any(DeleteQuery.class))) .thenThrow(new IllegalStateException("test exception")); final TestSubscriber<DeleteResult> testSubscriber = new TestSubscriber<DeleteResult>(); new PreparedDeleteByQuery.Builder(storIOSQLite, DeleteQuery.builder().table("test_table").build()) .withDeleteResolver(deleteResolver) .prepare() .asRxFlowable(MISSING) .subscribe(testSubscriber); testSubscriber.awaitTerminalEvent(); testSubscriber.assertNoValues(); testSubscriber.assertError(StorIOException.class); StorIOException expected = (StorIOException) testSubscriber.errors().get(0); IllegalStateException cause = (IllegalStateException) expected.getCause(); assertThat(cause).hasMessage("test exception"); verify(deleteResolver).performDelete(same(storIOSQLite), any(DeleteQuery.class)); verify(storIOSQLite).defaultRxScheduler(); verify(storIOSQLite).interceptors(); verifyNoMoreInteractions(storIOSQLite, lowLevel, deleteResolver); }