### Question:
CompletableOnSubscribeExecuteAsBlocking implements CompletableOnSubscribe { @Override public void subscribe(@NonNull CompletableEmitter emitter) throws Exception { try { preparedOperation.executeAsBlocking(); emitter.onComplete(); } catch (Exception e) { emitter.onError(e); } } CompletableOnSubscribeExecuteAsBlocking(@NonNull PreparedOperation preparedOperation); @Override void subscribe(@NonNull CompletableEmitter emitter);  }### Answer:
@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(); }
@SuppressWarnings({"ThrowableInstanceNeverThrown", "ResourceType"}) @Test public void shouldCallOnErrorIfExceptionOccurred() { final PreparedCompletableOperation preparedOperation = mock(PreparedCompletableOperation.class); StorIOException expectedException = new StorIOException("test exception"); when(preparedOperation.executeAsBlocking()).thenThrow(expectedException); TestObserver testObserver = new TestObserver(); Completable completable = Completable.create(new CompletableOnSubscribeExecuteAsBlocking(preparedOperation)); verifyZeroInteractions(preparedOperation); completable.subscribe(testObserver); testObserver.assertError(expectedException); testObserver.assertNotComplete(); verify(preparedOperation).executeAsBlocking(); verify(preparedOperation, never()).asRxFlowable(any(BackpressureStrategy.class)); verify(preparedOperation, never()).asRxSingle(); verify(preparedOperation, never()).asRxCompletable(); }