### Question:
AuthorSearchService { public Observable<AuthorCard> makeSearch(String pattern){ return Observable.create(aSubscriber->{ int resNumber=0; int page = 1; HashMap<String, ArrayList<AuthorCard>> colAuthors = null; try { colAuthors = mHttpClientController.searchAuthors(pattern, page); } catch (Exception ex) { Log.e(DEBUG_TAG, "makeSearch: searchAuthors error", ex); aSubscriber.onError(ex); return; } RuleBasedCollator russianCollator = (RuleBasedCollator) Collator.getInstance(new Locale("ru", "RU")); try { russianCollator = new RuleBasedCollator(mSettings.getCollationRule()); } catch (ParseException ex) { Log.e(DEBUG_TAG, "makeSearch: Collator error", ex); aSubscriber.onError(ex); return; } russianCollator.setStrength(Collator.IDENTICAL); russianCollator.setDecomposition(Collator.NO_DECOMPOSITION); while (colAuthors != null) { String[] keys = colAuthors.keySet().toArray(new String[1]); Arrays.sort(keys, russianCollator); int ires = Arrays.binarySearch(keys, pattern, russianCollator); Log.d(DEBUG_TAG, "makeSearch: Page number:" + page + " search result " + ires + " length is " + keys.length); int iStart; if (ires < 0) { iStart = -ires - 1; } else { iStart = ires; } for (int i = iStart; i < keys.length; i++) { String sKey = keys[i]; if (sKey.toLowerCase().startsWith(pattern.toLowerCase())) { for (AuthorCard ac : colAuthors.get(sKey)) { aSubscriber.onNext(ac); ++resNumber; if (resNumber >= SamLibConfig.SEARCH_LIMIT) { aSubscriber.onError(new SamlibSearchLimitExceeded(resNumber+" - "+SamLibConfig.SEARCH_LIMIT)); return ; } } } else { Log.d(DEBUG_TAG, "makeSearch: Search for " + pattern + " stop by substring - " + sKey + " " + keys.length + " " + iStart + " - " + ires); aSubscriber.onCompleted(); return ; } } ++page; try { colAuthors = mHttpClientController.searchAuthors(pattern, page); } catch (Exception ex) { Log.e(DEBUG_TAG,"makeSearch: searchAuthors2 error: "+ex); aSubscriber.onError(ex); return; } } aSubscriber.onCompleted(); }); } AuthorSearchService(HttpClientController httpClientController, AbstractSettings settings); Observable<AuthorCard> makeSearch(String pattern);  }### Answer:
@Test(timeout = 10000) public void testMakeSearch() throws Exception { mAuthorCards = new ArrayList<>(); mAuthorSearchService.makeSearch(PATTERN) .subscribe( authorCard -> { mAuthorCards.add(authorCard); }, throwable -> { mError = true; Log.e(DEBUG_TAG, "Error", throwable); }); assertFalse(mError); assertFalse(mAuthorCards.isEmpty()); for (AuthorCard authorCard : mAuthorCards) { Log.i(DEBUG_TAG, "> " + authorCard.getName()); } }