title: How to use switchIfEmpty RxJava
body: <p>The logic here is that if the ratings in the database are empty, then I want to get them from the API. I have the following code:</p>
  
  <pre><code>Observable.from(settingsRatingRepository.getRatingsFromDB())
              .toList()
              .switchIfEmpty(settingsRatingRepository.getSettingsRatingModulesFromAPI())
              .compose(schedulerProvider.getSchedulers())
              .subscribe(ratingsList -&gt; {
                  view.loadRatingLevels(ratingsList, hideLocks);
              }, this::handleError);
  </code></pre>
  
  <p>The <code>getRatingsFromDB()</code> call returns <code>List&lt;SettingRating&gt;</code>, but the API call returns <code>Observable&lt;List&lt;SettingRating&gt;&gt;</code>.</p>
  
  <p>However, when I unit test this, when I pass an empty list from the database call, it does not execute the API call. Can someone pls help me in this matter. This is my unit test code:</p>
  
  <pre><code>when(mockSettingsRatingsRepository.getRatingsFromDB()).thenReturn(Collections.emptyList());
  List&lt;SettingsRating&gt; settingsRatings = MockContentHelper.letRepositoryReturnSettingsRatingsFromApi(mockSettingsRatingsRepository);
  
  settingsParentalPresenter.onViewLoad(false);
  
  verify(mockView).loadRatingLevels(settingsRatings, false);
  </code></pre>