Language { @Override public final String toString() { StringBuilder sb = new StringBuilder(); sb.append(primaryTag); if (!subTag.isEmpty()) { sb.append('-').append(subTag); } return sb.toString(); } Language(Locale locale); String getPrimaryTag(); String getSubTag(); Locale getLocale(); boolean isCompatible(Language other); @Override final String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@UseDataProvider("forTestLanguageToString") @Test public void testLanguageToString(Language language, String expectedResult) { assertEquals(expectedResult, language.toString()); }