use of com.pushtorefresh.storio3.StorIOException in project storio by pushtorefresh.
the class PreparedPutContentValuesIterableTest method shouldWrapExceptionIntoStorIOExceptionCompletable.
@Test
public void shouldWrapExceptionIntoStorIOExceptionCompletable() {
final PutContentValuesStub stub = PutContentValuesStub.newPutStubForMultipleContentValues(true);
IllegalStateException testException = new IllegalStateException("test exception");
doThrow(testException).when(stub.putResolver).performPut(eq(stub.storIOSQLite), any(ContentValues.class));
final TestObserver testObserver = new TestObserver();
stub.storIOSQLite.put().contentValues(stub.contentValues).withPutResolver(stub.putResolver).prepare().asRxCompletable().subscribe(testObserver);
testObserver.awaitTerminalEvent();
testObserver.assertNoValues();
testObserver.assertError(StorIOException.class);
// noinspection ThrowableResultOfMethodCallIgnored
StorIOException expected = (StorIOException) testObserver.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).lowLevel();
verify(stub.lowLevel).beginTransaction();
verify(stub.lowLevel).endTransaction();
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 PreparedPutContentValuesTest method shouldWrapExceptionIntoStorIOExceptionCompletable.
@Test
public void shouldWrapExceptionIntoStorIOExceptionCompletable() {
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 TestObserver testObserver = new TestObserver();
stub.storIOSQLite.put().contentValues(contentValues).withPutResolver(stub.putResolver).prepare().asRxCompletable().subscribe(testObserver);
testObserver.awaitTerminalEvent();
testObserver.assertNoValues();
testObserver.assertError(StorIOException.class);
// noinspection ThrowableResultOfMethodCallIgnored
StorIOException expected = (StorIOException) testObserver.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 PreparedPutContentValuesTest method shouldWrapExceptionIntoStorIOExceptionSingle.
@Test
public void shouldWrapExceptionIntoStorIOExceptionSingle() {
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 TestObserver<Object> testObserver = new TestObserver<Object>();
stub.storIOSQLite.put().contentValues(contentValues).withPutResolver(stub.putResolver).prepare().asRxSingle().subscribe(testObserver);
testObserver.awaitTerminalEvent();
testObserver.assertNoValues();
testObserver.assertError(StorIOException.class);
// noinspection ThrowableResultOfMethodCallIgnored
StorIOException expected = (StorIOException) testObserver.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 PreparedGetCursorTest method shouldWrapExceptionIntoStorIOExceptionForSingle.
@Test
public void shouldWrapExceptionIntoStorIOExceptionForSingle() {
final StorIOSQLite storIOSQLite = mock(StorIOSQLite.class);
// noinspection unchecked
final GetResolver<Cursor> getResolver = mock(GetResolver.class);
when(getResolver.performGet(eq(storIOSQLite), any(Query.class))).thenThrow(new IllegalStateException("test exception"));
final TestObserver<Cursor> testObserver = new TestObserver<Cursor>();
new PreparedGetCursor.Builder(storIOSQLite).withQuery(Query.builder().table("test_table").build()).withGetResolver(getResolver).prepare().asRxSingle().subscribe(testObserver);
testObserver.awaitTerminalEvent(60, SECONDS);
testObserver.assertError(StorIOException.class);
StorIOException storIOException = (StorIOException) testObserver.errors().get(0);
IllegalStateException cause = (IllegalStateException) storIOException.getCause();
assertThat(cause).hasMessage("test exception");
}
Aggregations