@@ -0,0 +1,3472 @@
+/**%0A * Copyright 2017 Palantir Technologies%0A *%0A * Licensed under the BSD-3 License (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://opensource.org/licenses/BSD-3-Clause%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.palantir.atlasdb.http;%0A%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.never;%0Aimport static org.mockito.Mockito.verify;%0A%0Aimport java.io.IOException;%0Aimport java.lang.reflect.Type;%0Aimport java.util.Collection;%0Aimport java.util.Map;%0A%0Aimport javax.ws.rs.core.MediaType;%0A%0Aimport org.junit.Test;%0A%0Aimport com.google.common.collect.ImmutableList;%0Aimport com.google.common.collect.ImmutableMap;%0Aimport com.google.common.net.HttpHeaders;%0A%0Aimport feign.Response;%0Aimport feign.codec.Decoder;%0A%0Apublic class TextDelegateDecoderTest %7B%0A    private static final int HTTP_OK = 200;%0A    private static final String REASON = %22reason%22;%0A    private static final String CONTENT_TYPE_ALT_CASING_1 = %22content-type%22;%0A    private static final String CONTENT_TYPE_ALT_CASING_2 = %22COnTeNt-tYPe%22;%0A%0A    private final Decoder delegate = mock(Decoder.class);%0A    private final TextDelegateDecoder textDelegateDecoder = new TextDelegateDecoder(delegate);%0A%0A    @Test%0A    public void delegatesApplicationJsonContent() throws IOException %7B%0A        Response response = createSingleHeaderResponse(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);%0A        verifyDelegated(response);%0A    %7D%0A%0A    @Test%0A    public void decodesTextPlainContent() throws IOException %7B%0A        Response response = createSingleHeaderResponse(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);%0A        verifyNotDelegated(response);%0A    %7D%0A%0A    @Test%0A    public void decodesTextPlainContentRegardlessOfCase() throws IOException %7B%0A        Response response1 = createSingleHeaderResponse(CONTENT_TYPE_ALT_CASING_1, MediaType.TEXT_PLAIN);%0A        verifyNotDelegated(response1);%0A%0A        Response response2 = createSingleHeaderResponse(CONTENT_TYPE_ALT_CASING_2, MediaType.TEXT_PLAIN);%0A        verifyNotDelegated(response2);%0A    %7D%0A%0A    @Test%0A    public void delegatesContentWithMultipleDistinctContentTypes() throws IOException %7B%0A        Response response = createSingleHeaderResponse(HttpHeaders.CONTENT_TYPE,%0A                MediaType.TEXT_PLAIN, MediaType.APPLICATION_OCTET_STREAM);%0A%0A        verifyDelegated(response);%0A    %7D%0A%0A    private Response createResponse(Map%3CString, Collection%3CString%3E%3E headerMap) %7B%0A        return Response.create(HTTP_OK, REASON, headerMap, mock(Response.Body.class));%0A    %7D%0A%0A    private Response createSingleHeaderResponse(String header, String... values) %7B%0A        return createResponse(ImmutableMap.of(header, ImmutableList.copyOf(values)));%0A    %7D%0A%0A    private void verifyDelegated(Response response) throws IOException %7B%0A        textDelegateDecoder.decode(response, mock(Type.class));%0A        verify(delegate).decode(any(), any());%0A    %7D%0A%0A    private void verifyNotDelegated(Response response) throws IOException %7B%0A        textDelegateDecoder.decode(response, String.class);%0A        verify(delegate, never()).decode(any(), any());%0A    %7D%0A%7D%0A

Add tests for text delegate decoder.