RxExamples { public Observable<Artist> search(String searchedName, String searchedNationality, int maxResults) { return getSavedArtists() .filter(name -> name.contains(searchedName)) .flatMap(this::lookupArtist) .filter(artist -> artist.getNationality() .contains(searchedNationality)) .take(maxResults); } RxExamples(List<Artist> savedArtists); Observable<Artist> search(String searchedName,
                                 String searchedNationality,
                                 int maxResults); void creationCodeSample();  }
@Test public void filtersAlbums() throws InterruptedException { RxExamples examples = new RxExamples(SampleData.getThreeArtists()); Artist artist = examples.search("John", "UK", 5) .toBlockingObservable() .single(); assertEquals(SampleData.johnLennon, artist); }