### Question:
HttpHeadersImpl implements HttpHeaders { public List<Locale> getAcceptableLanguages() { List<String> ls = getListValues(HttpHeaders.ACCEPT_LANGUAGE); if (ls.isEmpty()) { return Collections.singletonList(new Locale("*")); } List<Locale> newLs = new ArrayList<>(); Map<Locale, Float> prefs = new HashMap<>(); for (String l : ls) { String[] pair = l.split(";"); Locale locale = HttpUtils.getLocale(pair[0].trim()); newLs.add(locale); if (pair.length > 1) { String[] pair2 = pair[1].split("="); if (pair2.length > 1) { prefs.put(locale, JAXRSUtils.getMediaTypeQualityFactor(pair2[1].trim())); } else { prefs.put(locale, 1F); } } else { prefs.put(locale, 1F); } } if (newLs.size() <= 1) { return newLs; } Collections.sort(newLs, new AcceptLanguageComparator(prefs)); return newLs; } HttpHeadersImpl(Message message); List<MediaType> getAcceptableMediaTypes(); Map<String, Cookie> getCookies(); Locale getLanguage(); MediaType getMediaType(); MultivaluedMap<String, String> getRequestHeaders(); List<Locale> getAcceptableLanguages(); List<String> getRequestHeader(String name); Date getDate(); String getHeaderString(String headerName); int getLength();  }### Answer:
@Test public void testGetNoLanguages() throws Exception { Message m = new MessageImpl(); m.put(Message.PROTOCOL_HEADERS, Collections.emptyMap()); HttpHeaders h = new HttpHeadersImpl(m); List<Locale> locales = h.getAcceptableLanguages(); assertEquals(1, locales.size()); assertEquals("*", locales.get(0).toString()); }
@Test public void testSingleAcceptableLanguages() throws Exception { Message m = createMessage(createHeader(HttpHeaders.ACCEPT_LANGUAGE, "en")); HttpHeaders h = new HttpHeadersImpl(m); List<Locale> languages = h.getAcceptableLanguages(); assertEquals(1, languages.size()); assertEquals(new Locale("en"), languages.get(0)); }
@Test public void testMultipleAcceptableLanguages() throws Exception { MetadataMap<String, String> headers = createHeader(HttpHeaders.ACCEPT_LANGUAGE, "en;q=0.7, en-gb;q=0.8, da, zh-Hans-SG;q=0.9"); Message m = createMessage(headers); HttpHeaders h = new HttpHeadersImpl(m); List<Locale> languages = h.getAcceptableLanguages(); assertEquals(4, languages.size()); assertEquals(new Locale("da"), languages.get(0)); assertEquals(new Locale("zh", "Hans-SG"), languages.get(1)); assertEquals(new Locale("en", "GB"), languages.get(2)); assertEquals(new Locale("en"), languages.get(3)); }