use of com.pushtorefresh.storio3.StorIOException in project storio by pushtorefresh.
the class PreparedDeleteByQueryTest method shouldWrapExceptionIntoStorIOExceptionFlowable.
@Test
public void shouldWrapExceptionIntoStorIOExceptionFlowable() {
final StorIOSQLite storIOSQLite = mock(StorIOSQLite.class);
final StorIOSQLite.LowLevel lowLevel = mock(StorIOSQLite.LowLevel.class);
when(storIOSQLite.lowLevel()).thenReturn(lowLevel);
// noinspection unchecked
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);
// noinspection ThrowableResultOfMethodCallIgnored
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);
}
use of com.pushtorefresh.storio3.StorIOException in project storio by pushtorefresh.
the class PreparedDeleteByQueryTest method shouldWrapExceptionIntoStorIOExceptionSingle.
@Test
public void shouldWrapExceptionIntoStorIOExceptionSingle() {
final StorIOSQLite storIOSQLite = mock(StorIOSQLite.class);
final StorIOSQLite.LowLevel lowLevel = mock(StorIOSQLite.LowLevel.class);
when(storIOSQLite.lowLevel()).thenReturn(lowLevel);
// noinspection unchecked
final DeleteResolver<DeleteQuery> deleteResolver = mock(DeleteResolver.class);
when(deleteResolver.performDelete(same(storIOSQLite), any(DeleteQuery.class))).thenThrow(new IllegalStateException("test exception"));
final TestObserver<DeleteResult> testObserver = new TestObserver<DeleteResult>();
new PreparedDeleteByQuery.Builder(storIOSQLite, DeleteQuery.builder().table("test_table").build()).withDeleteResolver(deleteResolver).prepare().asRxSingle().subscribe(testObserver);
testObserver.awaitTerminalEvent();
testObserver.assertNoValues();
testObserver.assertError(StorIOException.class);
// noinspection ThrowableResultOfMethodCallIgnored
StorIOException expected = (StorIOException) testObserver.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);
}
use of com.pushtorefresh.storio3.StorIOException in project storio by pushtorefresh.
the class PreparedExecuteSQLTest method shouldWrapExceptionIntoStorIOExceptionCompletable.
@Test
public void shouldWrapExceptionIntoStorIOExceptionCompletable() {
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().asRxCompletable().subscribe(testObserver);
testObserver.awaitTerminalEvent();
testObserver.assertNoValues();
testObserver.assertError(StorIOException.class);
// noinspection ThrowableResultOfMethodCallIgnored
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);
}
use of com.pushtorefresh.storio3.StorIOException in project storio by pushtorefresh.
the class PreparedPutContentValuesTest method shouldWrapExceptionIntoStorIOExceptionFlowable.
@Test
public void shouldWrapExceptionIntoStorIOExceptionFlowable() {
final PutContentValuesStub stub = PutContentValuesStub.newPutStubForOneContentValues();
ContentValues contentValues = stub.contentValues.get(0);
IllegalStateException testException = new IllegalStateException("test exception");
doThrow(testException).when(stub.putResolver).performPut(stub.storIOSQLite, contentValues);
final TestSubscriber<Object> testSubscriber = new TestSubscriber<Object>();
stub.storIOSQLite.put().contentValues(contentValues).withPutResolver(stub.putResolver).prepare().asRxFlowable(MISSING).subscribe(testSubscriber);
testSubscriber.awaitTerminalEvent();
testSubscriber.assertNoValues();
testSubscriber.assertError(StorIOException.class);
// noinspection ThrowableResultOfMethodCallIgnored
StorIOException expected = (StorIOException) testSubscriber.errors().get(0);
assertThat(expected).hasMessageStartingWith("Error has occurred during Put operation. contentValues =");
IllegalStateException cause = (IllegalStateException) expected.getCause();
assertThat(cause).hasMessage("test exception");
verify(stub.storIOSQLite).put();
verify(stub.storIOSQLite).defaultRxScheduler();
verify(stub.storIOSQLite).interceptors();
verifyNoMoreInteractions(stub.storIOSQLite, stub.lowLevel);
}
use of com.pushtorefresh.storio3.StorIOException in project storio by pushtorefresh.
the class PreparedDeleteByQueryTest method shouldWrapExceptionIntoStorIOExceptionCompletable.
@Test
public void shouldWrapExceptionIntoStorIOExceptionCompletable() {
final StorIOSQLite storIOSQLite = mock(StorIOSQLite.class);
final StorIOSQLite.LowLevel lowLevel = mock(StorIOSQLite.LowLevel.class);
when(storIOSQLite.lowLevel()).thenReturn(lowLevel);
// noinspection unchecked
final DeleteResolver<DeleteQuery> deleteResolver = mock(DeleteResolver.class);
when(deleteResolver.performDelete(same(storIOSQLite), any(DeleteQuery.class))).thenThrow(new IllegalStateException("test exception"));
final TestObserver<DeleteResult> testObserver = new TestObserver<DeleteResult>();
new PreparedDeleteByQuery.Builder(storIOSQLite, DeleteQuery.builder().table("test_table").build()).withDeleteResolver(deleteResolver).prepare().asRxCompletable().subscribe(testObserver);
testObserver.awaitTerminalEvent();
testObserver.assertNoValues();
testObserver.assertError(StorIOException.class);
// noinspection ThrowableResultOfMethodCallIgnored
StorIOException expected = (StorIOException) testObserver.errors().get(0);
IllegalStateException cause = (IllegalStateException) expected.getCause();
assertThat(cause).hasMessage("test exception");
verify(storIOSQLite).defaultRxScheduler();
verify(deleteResolver).performDelete(same(storIOSQLite), any(DeleteQuery.class));
verify(storIOSQLite).interceptors();
verifyNoMoreInteractions(storIOSQLite, lowLevel, deleteResolver);
}
Aggregations