@Test public void failsParseQualityValueWhenStringIsLongerThanFiveCharacters() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Quality value string has more then 5 characters"); HeaderHelper.parseQualityValue("0.7777"); }
static float parseQualityValue(String qString) { if (qString.length() > 5) { throw new IllegalArgumentException("Quality value string has more then 5 characters"); } float qValue; try { qValue = Float.valueOf(qString); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid quality value '%s'", qString)); } if (qValue > 1.0F) { throw new IllegalArgumentException("Quality value can't be greater then 1.0"); } return qValue; }
HeaderHelper { static float parseQualityValue(String qString) { if (qString.length() > 5) { throw new IllegalArgumentException("Quality value string has more then 5 characters"); } float qValue; try { qValue = Float.valueOf(qString); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid quality value '%s'", qString)); } if (qValue > 1.0F) { throw new IllegalArgumentException("Quality value can't be greater then 1.0"); } return qValue; } }
HeaderHelper { static float parseQualityValue(String qString) { if (qString.length() > 5) { throw new IllegalArgumentException("Quality value string has more then 5 characters"); } float qValue; try { qValue = Float.valueOf(qString); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid quality value '%s'", qString)); } if (qValue > 1.0F) { throw new IllegalArgumentException("Quality value can't be greater then 1.0"); } return qValue; } private  HeaderHelper(); }
HeaderHelper { static float parseQualityValue(String qString) { if (qString.length() > 5) { throw new IllegalArgumentException("Quality value string has more then 5 characters"); } float qValue; try { qValue = Float.valueOf(qString); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid quality value '%s'", qString)); } if (qValue > 1.0F) { throw new IllegalArgumentException("Quality value can't be greater then 1.0"); } return qValue; } 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); }
HeaderHelper { static float parseQualityValue(String qString) { if (qString.length() > 5) { throw new IllegalArgumentException("Quality value string has more then 5 characters"); } float qValue; try { qValue = Float.valueOf(qString); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid quality value '%s'", qString)); } if (qValue > 1.0F) { throw new IllegalArgumentException("Quality value can't be greater then 1.0"); } return qValue; } 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; }