@Test public void testUsesStringDecoderWithTextPlain() throws Exception { headers.put(HttpHeaders.CONTENT_TYPE, ImmutableSet.of(MediaType.TEXT_PLAIN)); Response response = Response.create(200, "OK", headers, "text response", StandardCharsets.UTF_8); Object decodedObject = textDelegateDecoder.decode(response, String.class); assertThat(decodedObject).isEqualTo("text response"); verifyNoMoreInteractions(delegate); }
@Override public Object decode(Response response, Type type) throws IOException, FeignException { Collection<String> contentTypes = HeaderAccessUtils.caseInsensitiveGet(response.headers(), HttpHeaders.CONTENT_TYPE); if (contentTypes == null) { contentTypes = ImmutableSet.of(); } if (contentTypes.size() == 1 && Iterables.getOnlyElement(contentTypes, "").startsWith(MediaType.TEXT_PLAIN)) { Object decoded = stringDecoder.decode(response, type); if (decoded == null) { return ""; } return decoded; } return delegate.decode(response, type); }
TextDelegateDecoder implements Decoder { @Override public Object decode(Response response, Type type) throws IOException, FeignException { Collection<String> contentTypes = HeaderAccessUtils.caseInsensitiveGet(response.headers(), HttpHeaders.CONTENT_TYPE); if (contentTypes == null) { contentTypes = ImmutableSet.of(); } if (contentTypes.size() == 1 && Iterables.getOnlyElement(contentTypes, "").startsWith(MediaType.TEXT_PLAIN)) { Object decoded = stringDecoder.decode(response, type); if (decoded == null) { return ""; } return decoded; } return delegate.decode(response, type); } }
TextDelegateDecoder implements Decoder { @Override public Object decode(Response response, Type type) throws IOException, FeignException { Collection<String> contentTypes = HeaderAccessUtils.caseInsensitiveGet(response.headers(), HttpHeaders.CONTENT_TYPE); if (contentTypes == null) { contentTypes = ImmutableSet.of(); } if (contentTypes.size() == 1 && Iterables.getOnlyElement(contentTypes, "").startsWith(MediaType.TEXT_PLAIN)) { Object decoded = stringDecoder.decode(response, type); if (decoded == null) { return ""; } return decoded; } return delegate.decode(response, type); } TextDelegateDecoder(Decoder delegate); }
TextDelegateDecoder implements Decoder { @Override public Object decode(Response response, Type type) throws IOException, FeignException { Collection<String> contentTypes = HeaderAccessUtils.caseInsensitiveGet(response.headers(), HttpHeaders.CONTENT_TYPE); if (contentTypes == null) { contentTypes = ImmutableSet.of(); } if (contentTypes.size() == 1 && Iterables.getOnlyElement(contentTypes, "").startsWith(MediaType.TEXT_PLAIN)) { Object decoded = stringDecoder.decode(response, type); if (decoded == null) { return ""; } return decoded; } return delegate.decode(response, type); } TextDelegateDecoder(Decoder delegate); @Override Object decode(Response response, Type type); }
TextDelegateDecoder implements Decoder { @Override public Object decode(Response response, Type type) throws IOException, FeignException { Collection<String> contentTypes = HeaderAccessUtils.caseInsensitiveGet(response.headers(), HttpHeaders.CONTENT_TYPE); if (contentTypes == null) { contentTypes = ImmutableSet.of(); } if (contentTypes.size() == 1 && Iterables.getOnlyElement(contentTypes, "").startsWith(MediaType.TEXT_PLAIN)) { Object decoded = stringDecoder.decode(response, type); if (decoded == null) { return ""; } return decoded; } return delegate.decode(response, type); } TextDelegateDecoder(Decoder delegate); @Override Object decode(Response response, Type type);  }