void () { List<SearchResult> results = myRangeSearch.getSearchResultsList(); Iterator<SearchResult> iterator = results.iterator(); SearchResult current = iterator.next(); while (iterator.hasNext()) { SearchResult previous = current; current = iterator.next(); boolean isRightOrder = previous.startPosition.pageNumber < current.startPosition.pageNumber || previous.startPosition.pageNumber == current.startPosition.pageNumber && previous.startPosition.symbolOffsetInPage < current.startPosition.symbolOffsetInPage; if (!isRightOrder) { StringBuilder message = new StringBuilder(); message.append(String.format("Order check is failed at ([%s] , [%s])", previous.toString(), current.toString())); message.append("\nAll search results:"); for (SearchResult result : results) { message.append("\n ").append(result); } Assert.fail(message.toString()); return; } } isAllDoneAsExpected = true; }