ArtistIndexService { protected void setArtistSortName(List<Artist> artists, String[] ignoredArticles) { for (Artist artist : artists) { artist.setSortName(artist.getName()); for (int i = 0; i < ignoredArticles.length; i++) { if (artist.getName().toUpperCase().startsWith(ignoredArticles[i] + " ")) { artist.setSortName(artist.getName().substring(ignoredArticles[i].length()+1)); } } } }  Map<String, List<Artist>> getIndexedArtists(List<Artist> artists); SortedMap<String, List<Artist>> getIndexedArtists(List<Integer> indexes, String indexLetter, List<Artist> artists); void setSettingsService(SettingsService settingsService);  }
@Test public void buildSortName() { Artist a = new Artist("Farrar"), b = new Artist("The Beatles"); List<Artist> artists = Arrays.asList(a, b); artistIndexService.setArtistSortName(artists, new String[]{"THE", "EL", "LOS"}); Assert.assertEquals("Farrar", a.getSortName()); Assert.assertEquals("Beatles", b.getSortName()); }