### Question:
FlowableOnSubscribeExecuteAsBlocking implements FlowableOnSubscribe<Result> { @Override public void subscribe(@NonNull FlowableEmitter<Result> emitter) throws Exception { try { emitter.onNext(preparedOperation.executeAsBlocking()); emitter.onComplete(); } catch (Exception e) { emitter.onError(e); } } FlowableOnSubscribeExecuteAsBlocking(@NonNull PreparedOperation<Result, WrappedResult, Data> preparedOperation); @Override void subscribe(@NonNull FlowableEmitter<Result> emitter);  }### Answer:
@SuppressWarnings("CheckResult") @Test public void shouldExecuteAsBlockingAfterSubscription() { final PreparedOperation<String, String, String> preparedOperation = mock(PreparedOperation.class); final String expectedResult = "expected_string"; when(preparedOperation.executeAsBlocking()).thenReturn(expectedResult); TestSubscriber<String> testSubscriber = new TestSubscriber<String>(); Flowable .create(new FlowableOnSubscribeExecuteAsBlocking<String, String, String>(preparedOperation), BackpressureStrategy.MISSING) .subscribe(testSubscriber); verify(preparedOperation).executeAsBlocking(); testSubscriber.assertValue(expectedResult); testSubscriber.assertNoErrors(); testSubscriber.assertComplete(); }
@Test public void shouldCallOnError() { Throwable throwable = new IllegalStateException("Test exception"); PreparedOperation<String, String, String> preparedOperation = mock(PreparedOperation.class); when(preparedOperation.executeAsBlocking()).thenThrow(throwable); TestSubscriber<String> testSubscriber = TestSubscriber.create(); Flowable .create(new FlowableOnSubscribeExecuteAsBlocking<String, String, String>(preparedOperation), BackpressureStrategy.MISSING) .subscribe(testSubscriber); testSubscriber.assertError(throwable); testSubscriber.assertNoValues(); testSubscriber.assertNotComplete(); }