use of com.pushtorefresh.storio3.operations.PreparedOperation in project storio by pushtorefresh.
the class SingleOnSubscribeExecuteAsBlockingOptionalTest method shouldCallOnErrorIfExceptionOccurred.
@SuppressWarnings("CheckResult")
@Test
public void shouldCallOnErrorIfExceptionOccurred() {
// noinspection unchecked
final PreparedOperation<Object, Optional<Object>, Object> preparedOperation = mock(PreparedOperation.class);
StorIOException expectedException = new StorIOException("test exception");
when(preparedOperation.executeAsBlocking()).thenThrow(expectedException);
TestObserver<Optional<Object>> testObserver = new TestObserver<Optional<Object>>();
Single<Optional<Object>> single = Single.create(new SingleOnSubscribeExecuteAsBlockingOptional<Object, Object>(preparedOperation));
verifyZeroInteractions(preparedOperation);
single.subscribe(testObserver);
testObserver.assertError(expectedException);
testObserver.assertNotComplete();
verify(preparedOperation).executeAsBlocking();
}
use of com.pushtorefresh.storio3.operations.PreparedOperation in project storio by pushtorefresh.
the class CompletableOnSubscribeExecuteAsBlockingTest method shouldExecuteAsBlockingAfterSubscription.
@SuppressWarnings("ResourceType")
@Test
public void shouldExecuteAsBlockingAfterSubscription() {
final PreparedCompletableOperation preparedOperation = mock(PreparedCompletableOperation.class);
TestObserver testObserver = new TestObserver();
verifyZeroInteractions(preparedOperation);
Completable completable = Completable.create(new CompletableOnSubscribeExecuteAsBlocking(preparedOperation));
verifyZeroInteractions(preparedOperation);
completable.subscribe(testObserver);
testObserver.assertNoErrors();
testObserver.assertComplete();
verify(preparedOperation).executeAsBlocking();
verify(preparedOperation, never()).asRxFlowable(any(BackpressureStrategy.class));
verify(preparedOperation, never()).asRxSingle();
verify(preparedOperation, never()).asRxCompletable();
}
use of com.pushtorefresh.storio3.operations.PreparedOperation in project storio by pushtorefresh.
the class MaybeOnSubscribeExecuteAsBlockingTest method shouldCallOnErrorIfExceptionOccurred.
@SuppressWarnings("CheckResult")
@Test
public void shouldCallOnErrorIfExceptionOccurred() {
// noinspection unchecked
final PreparedMaybeOperation<Object, Object, Object> preparedOperation = mock(PreparedMaybeOperation.class);
StorIOException expectedException = new StorIOException("test exception");
when(preparedOperation.executeAsBlocking()).thenThrow(expectedException);
TestObserver<Object> testObserver = new TestObserver<Object>();
Maybe<Object> maybe = Maybe.create(new MaybeOnSubscribeExecuteAsBlocking<Object, Object, Object>(preparedOperation));
verifyZeroInteractions(preparedOperation);
maybe.subscribe(testObserver);
testObserver.assertError(expectedException);
testObserver.assertNotComplete();
verify(preparedOperation).executeAsBlocking();
}
use of com.pushtorefresh.storio3.operations.PreparedOperation in project storio by pushtorefresh.
the class ChainImpl method proceed.
// can be null on PreparedGetObject
@Nullable
@Override
public <Result, WrappedResult, Data> Result proceed(@NonNull PreparedOperation<Result, WrappedResult, Data> operation) {
if (!interceptors.hasNext()) {
throw new IllegalStateException("proceed was called on empty iterator");
}
calls++;
// Confirm that this is the only call to chain.proceed().
if (calls > 1) {
throw new IllegalStateException("nextInterceptor " + interceptors.previous() + " must call proceed() exactly once");
}
// Call the nextChain nextInterceptor in the chain.
final Interceptor nextInterceptor = interceptors.next();
final ChainImpl nextChain = new ChainImpl(interceptors);
return nextInterceptor.intercept(operation, nextChain);
}
use of com.pushtorefresh.storio3.operations.PreparedOperation in project storio by pushtorefresh.
the class SchedulerChecker method check.
private void check(@NonNull PreparedOperation operation) {
final PreparedOperation operationSpy = spy(operation);
verify(storIOSQLite).defaultRxScheduler();
operationSpy.asRxFlowable(MISSING).subscribe();
verify(operationSpy, never()).executeAsBlocking();
scheduler.triggerActions();
verify(operationSpy).executeAsBlocking();
}
Aggregations