@CheckReturnValue
  public static Disposable reloadDictionaryInBackground(@NonNull Dictionary dictionary) {
    return Observable.<Dictionary>create(emitter -> emitter.onNext(dictionary))
        .subscribeOn(RxSchedulers.background())
        .map(
            d -> {
              d.loadDictionary();
              return d;
            })
        .observeOn(RxSchedulers.mainThread())
        .unsubscribeOn(RxSchedulers.background())
        .subscribe(
            d -> Logger.d("DictionaryBackgroundLoader", "Reloading of %s done.", d),
            throwable ->
                Logger.e(
                    "DictionaryBackgroundLoader",
                    throwable,
                    "Reloading of %s failed with error '%s'.",
                    dictionary,
                    throwable.getMessage()));
  }
@Test
  public void testReloadFailedToLoad() {
    Dictionary dictionary = Mockito.mock(Dictionary.class);
    final RuntimeException runtimeException = new RuntimeException();

    Mockito.doThrow(runtimeException).when(dictionary).loadDictionary();
    final Disposable disposable =
        DictionaryBackgroundLoader.reloadDictionaryInBackground(dictionary);

    TestRxSchedulers.drainAllTasks();

    final InOrder inOrder = Mockito.inOrder(dictionary);
    inOrder.verify(dictionary).loadDictionary();
    inOrder.verify(dictionary, Mockito.never()).close();
    inOrder.verifyNoMoreInteractions();

    disposable.dispose();
    TestRxSchedulers.drainAllTasks();
    Mockito.verify(dictionary, Mockito.never()).close();
  }