Artists { public String getArtistName(int index) { try { Artist artist = getArtist(index); return artist.getName(); } catch (IllegalArgumentException e) { return "unknown"; } } Artists(List<Artist> artists); Artist getArtist(int index); String getArtistName(int index);  }
@Test public void nameIndexInsideRange() { String artist = optionalExamples.getArtistName(0); Assert.assertEquals("John Coltrane", artist); }
@Test public void nameIndexOutsideRange() { String artist = optionalExamples.getArtistName(4); assertEquals("unknown", artist); }