@Test public void loadVocabularyWordsNoCache() { when(cache.getWords(UI_LANG, LEARN_LANG)).thenReturn(Collections.emptyList()); VocabularyWord liveWord = makeWord(WORD, TRANSLATION); addVocabularyData(liveWord); addTranslation(WORD, Collections.singletonList(TRANSLATION)); TestObserver<List<VocabularyWord>> observer = new TestObserver<>(); module.loadVocabularyWords().enqueue(observer); List<VocabularyWord> live = observer.getOnNextEvents().get(0); assertThat(live, contains(liveWord)); }
@Override public Call<List<VocabularyWord>> loadVocabularyWords() { logger.debug("loadVocabularyWords()"); return new Call<List<VocabularyWord>>() { @Override public void enqueue(Action<List<VocabularyWord>> onData, Action<Throwable> onError) { mainExecutor.execute(new GetCachedDataTask(Observers.from(onData, onError))); mainExecutor.execute(new LoadWordsTask(Observers.from(onData, onError))); } @Override public void cancel() { } }; }
RestVocabularyModule implements VocabularyModule { @Override public Call<List<VocabularyWord>> loadVocabularyWords() { logger.debug("loadVocabularyWords()"); return new Call<List<VocabularyWord>>() { @Override public void enqueue(Action<List<VocabularyWord>> onData, Action<Throwable> onError) { mainExecutor.execute(new GetCachedDataTask(Observers.from(onData, onError))); mainExecutor.execute(new LoadWordsTask(Observers.from(onData, onError))); } @Override public void cancel() { } }; } }
RestVocabularyModule implements VocabularyModule { @Override public Call<List<VocabularyWord>> loadVocabularyWords() { logger.debug("loadVocabularyWords()"); return new Call<List<VocabularyWord>>() { @Override public void enqueue(Action<List<VocabularyWord>> onData, Action<Throwable> onError) { mainExecutor.execute(new GetCachedDataTask(Observers.from(onData, onError))); mainExecutor.execute(new LoadWordsTask(Observers.from(onData, onError))); } @Override public void cancel() { } }; } @Inject  RestVocabularyModule(RestService service, TranslationService translationService, AccountModule accountModule,
                                VocabularyWordsRepository provider, @Named(MAIN_EXECUTOR) Executor mainExecutor); }
RestVocabularyModule implements VocabularyModule { @Override public Call<List<VocabularyWord>> loadVocabularyWords() { logger.debug("loadVocabularyWords()"); return new Call<List<VocabularyWord>>() { @Override public void enqueue(Action<List<VocabularyWord>> onData, Action<Throwable> onError) { mainExecutor.execute(new GetCachedDataTask(Observers.from(onData, onError))); mainExecutor.execute(new LoadWordsTask(Observers.from(onData, onError))); } @Override public void cancel() { } }; } @Inject  RestVocabularyModule(RestService service, TranslationService translationService, AccountModule accountModule,
                                VocabularyWordsRepository provider, @Named(MAIN_EXECUTOR) Executor mainExecutor); @Override Call<List<VocabularyWord>> loadVocabularyWords(); @Override Call<List<VocabularyWord>> refreshVocabularyWords(); }
RestVocabularyModule implements VocabularyModule { @Override public Call<List<VocabularyWord>> loadVocabularyWords() { logger.debug("loadVocabularyWords()"); return new Call<List<VocabularyWord>>() { @Override public void enqueue(Action<List<VocabularyWord>> onData, Action<Throwable> onError) { mainExecutor.execute(new GetCachedDataTask(Observers.from(onData, onError))); mainExecutor.execute(new LoadWordsTask(Observers.from(onData, onError))); } @Override public void cancel() { } }; } @Inject  RestVocabularyModule(RestService service, TranslationService translationService, AccountModule accountModule,
                                VocabularyWordsRepository provider, @Named(MAIN_EXECUTOR) Executor mainExecutor); @Override Call<List<VocabularyWord>> loadVocabularyWords(); @Override Call<List<VocabularyWord>> refreshVocabularyWords(); static final String MAIN_EXECUTOR; }