class Artists {

    public String getArtistName(int index) {
        try {
            Artist artist = getArtist(index);
            return artist.getName();
        } catch (IllegalArgumentException e) {
            return "unknown";
        }
    }

}

class ArtistsTest {

    private final Artists optionalExamples;

    @Test
    public void nameIndexOutsideRange() {

        String artist = optionalExamples.getArtistName(4);
        assertEquals("unknown", artist);
    }

}