@Test public void checkContentTypeCases() { final String invalidContentType = "invalid"; final Predicate<HttpHeaders> jsonContentTypeValidator = headers -> headers.contains(CONTENT_TYPE, APPLICATION_JSON); checkContentType(headersWithContentType(APPLICATION_JSON), jsonContentTypeValidator); expectedException.expect(instanceOf(SerializationException.class)); expectedException.expectMessage(containsString(invalidContentType)); checkContentType(headersWithContentType(of(invalidContentType)), jsonContentTypeValidator); }
static void checkContentType(final HttpHeaders headers, Predicate<HttpHeaders> contentTypePredicate) { if (!contentTypePredicate.test(headers)) { throw new SerializationException("Unexpected headers, can not deserialize. Headers: " + headers.toString(DEFAULT_DEBUG_HEADER_FILTER)); } }
HeaderUtils { static void checkContentType(final HttpHeaders headers, Predicate<HttpHeaders> contentTypePredicate) { if (!contentTypePredicate.test(headers)) { throw new SerializationException("Unexpected headers, can not deserialize. Headers: " + headers.toString(DEFAULT_DEBUG_HEADER_FILTER)); } } }
HeaderUtils { static void checkContentType(final HttpHeaders headers, Predicate<HttpHeaders> contentTypePredicate) { if (!contentTypePredicate.test(headers)) { throw new SerializationException("Unexpected headers, can not deserialize. Headers: " + headers.toString(DEFAULT_DEBUG_HEADER_FILTER)); } } private  HeaderUtils(); }
HeaderUtils { static void checkContentType(final HttpHeaders headers, Predicate<HttpHeaders> contentTypePredicate) { if (!contentTypePredicate.test(headers)) { throw new SerializationException("Unexpected headers, can not deserialize. Headers: " + headers.toString(DEFAULT_DEBUG_HEADER_FILTER)); } } private  HeaderUtils(); static boolean isTransferEncodingChunked(final HttpHeaders headers); static boolean domainMatches(final CharSequence requestDomain, @Nullable final CharSequence cookieDomain); static boolean pathMatches(final CharSequence requestPath, @Nullable final CharSequence cookiePath); static boolean isSetCookieNameMatches(final CharSequence setCookieString,
                                                 final CharSequence setCookieName); @Nullable static HttpSetCookie parseSetCookie(final CharSequence setCookieString,
                                               final CharSequence setCookieName,
                                               final boolean validate); @Nullable static HttpCookiePair parseCookiePair(final CharSequence cookieString,
                                                 final CharSequence cookiePairName); @Nullable static CharSequence removeCookiePairs(final CharSequence cookieString,
                                                 final CharSequence cookiePairName); static boolean hasContentType(final HttpHeaders headers,
                                         final CharSequence expectedContentType,
                                         @Nullable final Charset expectedCharset); }
HeaderUtils { static void checkContentType(final HttpHeaders headers, Predicate<HttpHeaders> contentTypePredicate) { if (!contentTypePredicate.test(headers)) { throw new SerializationException("Unexpected headers, can not deserialize. Headers: " + headers.toString(DEFAULT_DEBUG_HEADER_FILTER)); } } private  HeaderUtils(); static boolean isTransferEncodingChunked(final HttpHeaders headers); static boolean domainMatches(final CharSequence requestDomain, @Nullable final CharSequence cookieDomain); static boolean pathMatches(final CharSequence requestPath, @Nullable final CharSequence cookiePath); static boolean isSetCookieNameMatches(final CharSequence setCookieString,
                                                 final CharSequence setCookieName); @Nullable static HttpSetCookie parseSetCookie(final CharSequence setCookieString,
                                               final CharSequence setCookieName,
                                               final boolean validate); @Nullable static HttpCookiePair parseCookiePair(final CharSequence cookieString,
                                                 final CharSequence cookiePairName); @Nullable static CharSequence removeCookiePairs(final CharSequence cookieString,
                                                 final CharSequence cookiePairName); static boolean hasContentType(final HttpHeaders headers,
                                         final CharSequence expectedContentType,
                                         @Nullable final Charset expectedCharset); static final BiFunction<? super CharSequence, ? super CharSequence, CharSequence> DEFAULT_HEADER_FILTER; }