HeaderHelper { public static List<AcceptToken> createAcceptedEncodingList(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 createsAcceptedEncodingListWhenHeaderIsNull() { List<AcceptToken> charsetList = HeaderHelper.createAcceptedEncodingList(null); assertEquals(newArrayList(new AcceptToken("*")), charsetList); }
@Test public void createsAcceptedEncodingListWhenHeaderIsEmptyString() { List<AcceptToken> charsetList = HeaderHelper.createAcceptedEncodingList(""); assertEquals(newArrayList(new AcceptToken("*")), charsetList); }
@Test public void createsAcceptedEncodingListFromHeader() { String encodings = "compress;q=0.5, gzip ; q=1.0"; List<AcceptToken> expectedEncodingList = newArrayList(new AcceptToken("gzip"), new AcceptToken("compress", 0.5f)); List<AcceptToken> encodingList = HeaderHelper.createAcceptedEncodingList(encodings); assertEquals(expectedEncodingList, encodingList); }