Artists { public Artist getArtist(int index) { if (index < 0 || index >= artists.size()) { indexException(index); } return artists.get(index); } Artists(List<Artist> artists); Artist getArtist(int index); String getArtistName(int index);  }
@Test public void indexWithinRange() { Artist artist = optionalExamples.getArtist(0); assertNotNull(artist); }
@Test(expected = IllegalArgumentException.class) public void indexOutsideRange() { optionalExamples.getArtist(4); }