Search in sources :

Example 1 with PreparedWriteOperation

use of com.pushtorefresh.storio.operations.PreparedWriteOperation in project storio by pushtorefresh.

the class OnSubscribeExecuteAsBlockingCompletableTest method shouldCallOnErrorIfExceptionOccurred.

@SuppressWarnings({ "ThrowableInstanceNeverThrown", "ResourceType" })
@Test
public void shouldCallOnErrorIfExceptionOccurred() {
    final PreparedWriteOperation preparedOperation = mock(PreparedWriteOperation.class);
    StorIOException expectedException = new StorIOException("test exception");
    when(preparedOperation.executeAsBlocking()).thenThrow(expectedException);
    TestSubscriber testSubscriber = new TestSubscriber();
    Completable completable = Completable.create(OnSubscribeExecuteAsBlockingCompletable.newInstance(preparedOperation));
    verifyZeroInteractions(preparedOperation);
    completable.subscribe(testSubscriber);
    testSubscriber.assertError(expectedException);
    testSubscriber.assertTerminalEvent();
    verify(preparedOperation).executeAsBlocking();
    verify(preparedOperation, never()).asRxObservable();
    verify(preparedOperation, never()).asRxSingle();
    verify(preparedOperation, never()).asRxCompletable();
}
Also used : Completable(rx.Completable) PreparedWriteOperation(com.pushtorefresh.storio.operations.PreparedWriteOperation) StorIOException(com.pushtorefresh.storio.StorIOException) TestSubscriber(rx.observers.TestSubscriber) Test(org.junit.Test)

Example 2 with PreparedWriteOperation

use of com.pushtorefresh.storio.operations.PreparedWriteOperation in project storio by pushtorefresh.

the class OnSubscribeExecuteAsBlockingCompletableTest method shouldExecuteAsBlockingAfterSubscription.

@SuppressWarnings("ResourceType")
@Test
public void shouldExecuteAsBlockingAfterSubscription() {
    final PreparedWriteOperation preparedOperation = mock(PreparedWriteOperation.class);
    TestSubscriber testSubscriber = new TestSubscriber();
    verifyZeroInteractions(preparedOperation);
    Completable completable = Completable.create(OnSubscribeExecuteAsBlockingCompletable.newInstance(preparedOperation));
    verifyZeroInteractions(preparedOperation);
    completable.subscribe(testSubscriber);
    testSubscriber.assertNoErrors();
    testSubscriber.assertCompleted();
    verify(preparedOperation).executeAsBlocking();
    verify(preparedOperation, never()).asRxObservable();
    verify(preparedOperation, never()).asRxSingle();
    verify(preparedOperation, never()).asRxCompletable();
}
Also used : Completable(rx.Completable) PreparedWriteOperation(com.pushtorefresh.storio.operations.PreparedWriteOperation) TestSubscriber(rx.observers.TestSubscriber) Test(org.junit.Test)

Aggregations

PreparedWriteOperation (com.pushtorefresh.storio.operations.PreparedWriteOperation)2 Test (org.junit.Test)2 Completable (rx.Completable)2 TestSubscriber (rx.observers.TestSubscriber)2 StorIOException (com.pushtorefresh.storio.StorIOException)1