BookServiceImpl implements BookService { @Override public Observable<List<FireLanguage>> getLanguages() { return bookDatabase.getLanguages().flatMap(filterEnabledLanguages()); } BookServiceImpl(BookDatabase bookDatabase); @Override Observable<List<FireLanguage>> getLanguages(); @Override Observable<List<FireBookDetails>> getBooksForLanguage(final FireLanguage language); @Override Observable<List<FireContributor>> getContributorsForBook(final FireBookDetails book); @Override Observable<List<FireBookDetails>> getDownloadedBooks(); @Override Observable<List<FireBookDetails>> searchBooks(final String searchTerm);  }
@Test public void testGetLanguages() throws Exception { FireLanguage fireLanguage = new FireLanguage("English", "EN", true, "id123"); ArrayList<FireLanguage> fireLanguages = new ArrayList<>(); fireLanguages.add(fireLanguage); when(bookDatabase.getLanguages()).thenReturn(Observable.<List<FireLanguage>>just(fireLanguages)); TestSubscriber<List<FireLanguage>> testSubscriber = new TestSubscriber<>(); bookService.getLanguages().subscribe(testSubscriber); verify(bookDatabase).getLanguages(); testSubscriber.awaitTerminalEvent(); testSubscriber.assertNoErrors(); final List<List<FireLanguage>> result = testSubscriber.getOnNextEvents(); assertEquals("English", result.get(0).get(0).getLanguageName()); }