@Test public void transformsObjectToStringWithToStringMethodWhenHeaderDelegateDoesNotPresent() throws Exception { RuntimeDelegate runtimeDelegate = mock(RuntimeDelegate.class); RuntimeDelegate.setInstance(runtimeDelegate); Object someObject = mock(Object.class); when(someObject.toString()).thenReturn("<foo>"); assertEquals("<foo>", HeaderHelper.getHeaderAsString(someObject)); }
@SuppressWarnings({"unchecked"}) public static String getHeaderAsString(Object o) { HeaderDelegate headerDelegate = RuntimeDelegate.getInstance().createHeaderDelegate(o.getClass()); if (headerDelegate == null) { return o.toString(); } return headerDelegate.toString(o); }
HeaderHelper { @SuppressWarnings({"unchecked"}) public static String getHeaderAsString(Object o) { HeaderDelegate headerDelegate = RuntimeDelegate.getInstance().createHeaderDelegate(o.getClass()); if (headerDelegate == null) { return o.toString(); } return headerDelegate.toString(o); } }
HeaderHelper { @SuppressWarnings({"unchecked"}) public static String getHeaderAsString(Object o) { HeaderDelegate headerDelegate = RuntimeDelegate.getInstance().createHeaderDelegate(o.getClass()); if (headerDelegate == null) { return o.toString(); } return headerDelegate.toString(o); } private  HeaderHelper(); }
HeaderHelper { @SuppressWarnings({"unchecked"}) public static String getHeaderAsString(Object o) { HeaderDelegate headerDelegate = RuntimeDelegate.getInstance().createHeaderDelegate(o.getClass()); if (headerDelegate == null) { return o.toString(); } return headerDelegate.toString(o); } 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 { @SuppressWarnings({"unchecked"}) public static String getHeaderAsString(Object o) { HeaderDelegate headerDelegate = RuntimeDelegate.getInstance().createHeaderDelegate(o.getClass()); if (headerDelegate == null) { return o.toString(); } return headerDelegate.toString(o); } 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; }