UseCase { @SuppressWarnings("unchecked") public void execute(Subscriber useCaseSubscriber) { unsubscribe(); mSubscription = buildUseCaseObservable() .subscribeOn(Schedulers.from(mThreadExecutor)) .observeOn(mPostExecutionThread.getScheduler()) .subscribe(useCaseSubscriber); } UseCase(ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread); @SuppressWarnings("unchecked") void execute(Subscriber useCaseSubscriber); @SuppressWarnings("unchecked") void executeAllBg(Subscriber useCaseSubscriber); @SuppressWarnings("unchecked") void executeUnsubBg(Subscriber useCaseSubscriber); void unsubscribe();  }
@Test public void testBuildUseCaseObservableReturnCorrectResult() { TestSubscriber<Integer> testSubscriber = new TestSubscriber<>(); TestScheduler testScheduler = new TestScheduler(); BDDMockito.given(mockPostExecutionThread.getScheduler()).willReturn(testScheduler); mUseCase.execute(testSubscriber); MatcherAssert.assertThat(testSubscriber.getOnNextEvents().size(), Is.is(0)); }