HeaderHelper { public static List<AcceptToken> createAcceptedCharsetList(String header) { if (isNullOrEmpty(header) || "*".equals(header)) { return ACCEPT_ALL_TOKENS; } return LIST_TOKEN_PRODUCER.createQualitySortedList(header); } private  HeaderHelper(); static List<AcceptMediaType> createAcceptMediaTypeList(String header); static List<AcceptLanguage> createAcceptedLanguageList(String header); static List<AcceptToken> createAcceptedCharsetList(String header); static List<AcceptToken> createAcceptedEncodingList(String header); static List<Cookie> parseCookies(String cookiesString); static NewCookie parseNewCookie(String newCookieString); static Date parseDateHeader(String header); static String formatDate(Date date); static long getContentLengthLong(MultivaluedMap<String, String> httpHeaders); @SuppressWarnings({"unchecked"}) static String getHeaderAsString(Object o); static String convertToString(Collection<String> collection); static final Comparator<QualityValue> QUALITY_VALUE_COMPARATOR; }
@Test public void createsAcceptedCharsetListWhenHeaderIsNull() { List<AcceptToken> charsetList = HeaderHelper.createAcceptedCharsetList(null); assertEquals(newArrayList(new AcceptToken("*")), charsetList); }
@Test public void createAcceptedCharsetListWhenHeaderIsEmptyString() { List<AcceptToken> charsetList = HeaderHelper.createAcceptedCharsetList(""); assertEquals(newArrayList(new AcceptToken("*")), charsetList); }
@Test public void createsAcceptedCharsetListFromHeader() { String charsets = "Windows-1251,utf-8; q =0.9,*;q=0.7"; List<AcceptToken> expectedCharsetList = newArrayList(new AcceptToken("windows-1251"), new AcceptToken("utf-8", 0.9f), new AcceptToken("*", 0.7f)); List<AcceptToken> charsetList = HeaderHelper.createAcceptedCharsetList(charsets); assertEquals(expectedCharsetList, charsetList); }