### Question:
SingleOnSubscribeExecuteAsBlocking implements SingleOnSubscribe<Result> { @Override public void subscribe(@NonNull SingleEmitter<Result> emitter) throws Exception { try { final Result value = preparedOperation.executeAsBlocking(); emitter.onSuccess(value); } catch (Exception e) { emitter.onError(e); } } SingleOnSubscribeExecuteAsBlocking(@NonNull PreparedOperation<Result, WrappedResult, Data> preparedOperation); @Override void subscribe(@NonNull SingleEmitter<Result> emitter);  }### Answer:
@SuppressWarnings("CheckResult") @Test public void shouldExecuteAsBlockingAfterSubscription() { final PreparedOperation<String, String, String> preparedOperation = mock(PreparedOperation.class); String expectedResult = "test"; when(preparedOperation.executeAsBlocking()).thenReturn(expectedResult); TestObserver<String> testObserver = new TestObserver<String>(); verifyZeroInteractions(preparedOperation); Single<String> single = Single.create(new SingleOnSubscribeExecuteAsBlocking<String, String, String>(preparedOperation)); verifyZeroInteractions(preparedOperation); single.subscribe(testObserver); testObserver.assertValue(expectedResult); testObserver.assertNoErrors(); testObserver.assertComplete(); verify(preparedOperation).executeAsBlocking(); }
@SuppressWarnings("CheckResult") @Test public void shouldCallOnErrorIfExceptionOccurred() { final PreparedOperation<Object, Object, Object> preparedOperation = mock(PreparedOperation.class); StorIOException expectedException = new StorIOException("test exception"); when(preparedOperation.executeAsBlocking()).thenThrow(expectedException); TestObserver<Object> testObserver = new TestObserver<Object>(); Single<Object> single = Single.create(new SingleOnSubscribeExecuteAsBlocking<Object, Object, Object>(preparedOperation)); verifyZeroInteractions(preparedOperation); single.subscribe(testObserver); testObserver.assertError(expectedException); testObserver.assertNotComplete(); verify(preparedOperation).executeAsBlocking(); }