From 4cf5892015c79f4f6d056fc0e09982898592a648 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 17 Jan 2022 13:24:58 +0000 Subject: [PATCH] Remove deprecated code Closes gh-781 --- .../operation/OperationResponseFactory.java | 16 ------------- .../restdocs/payload/FieldTypeResolver.java | 17 +------------ .../request/AbstractParametersSnippet.java | 14 +---------- .../payload/FieldTypeResolverTests.java | 23 +----------------- .../RestDocumentationRequestBuilders.java | 24 ------------------- ...RestDocumentationRequestBuildersTests.java | 12 +++++----- 6 files changed, 9 insertions(+), 97 deletions(-) diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.java index 3b9c99145..17f835a6d 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.java @@ -17,7 +17,6 @@ package org.springframework.restdocs.operation; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; /** * A factory for creating {@link OperationResponse OperationResponses}. @@ -26,21 +25,6 @@ */ public class OperationResponseFactory { - /** - * Creates a new {@link OperationResponse}. If the response has any content, the given - * {@code headers} will be augmented to ensure that they include a - * {@code Content-Length} header. - * @param status the status of the response - * @param headers the response's headers - * @param content the content of the response - * @return the {@code OperationResponse} - * @deprecated since 2.0.4 in favor of {@link #create(int, HttpHeaders, byte[])} - */ - @Deprecated - public OperationResponse create(HttpStatus status, HttpHeaders headers, byte[] content) { - return this.create(status.value(), headers, content); - } - /** * Creates a new {@link OperationResponse}. If the response has any content, the given * {@code headers} will be augmented to ensure that they include a diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypeResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypeResolver.java index 6c8397c39..7f574a9e9 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypeResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypeResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.restdocs.payload; -import java.util.Collections; import java.util.List; import org.springframework.http.MediaType; @@ -30,20 +29,6 @@ */ public interface FieldTypeResolver { - /** - * Create a {@code FieldTypeResolver} for the given {@code content} and - * {@code contentType}. - * @param content the payload that the {@code FieldTypeResolver} should handle - * @param contentType the content type of the payload - * @return the {@code FieldTypeResolver} - * @deprecated since 2.0.4 in favor of - * {@link #forContentWithDescriptors(byte[], MediaType, List)} - */ - @Deprecated - static FieldTypeResolver forContent(byte[] content, MediaType contentType) { - return forContentWithDescriptors(content, contentType, Collections.emptyList()); - } - /** * Create a {@code FieldTypeResolver} for the given {@code content} and * {@code contentType}, described by the given {@code descriptors}. diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/AbstractParametersSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/AbstractParametersSnippet.java index 523d65c81..cce7a7d1a 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/AbstractParametersSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/AbstractParametersSnippet.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -126,18 +126,6 @@ private void verifyParameterDescriptors(Operation operation) { */ protected abstract void verificationFailed(Set undocumentedParameters, Set missingParameters); - /** - * Returns a {@code Map} of {@link ParameterDescriptor ParameterDescriptors} that will - * be used to generate the documentation key by their - * {@link ParameterDescriptor#getName()}. - * @return the map of path descriptors - * @deprecated since 1.1.0 in favor of {@link #getParameterDescriptors()} - */ - @Deprecated - protected final Map getFieldDescriptors() { - return this.descriptorsByName; - } - /** * Returns a {@code Map} of {@link ParameterDescriptor ParameterDescriptors} that will * be used to generate the documentation key by their diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/FieldTypeResolverTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/FieldTypeResolverTests.java index 17d3edf5b..8ed7fbe19 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/FieldTypeResolverTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/FieldTypeResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,27 +36,6 @@ public class FieldTypeResolverTests { @Rule public ExpectedException thrownException = ExpectedException.none(); - @Test - @Deprecated - public void whenForContentCalledWithJsonContentThenReturnsJsonFieldTypeResolver() { - assertThat(FieldTypeResolver.forContent("{\"field\": \"value\"}".getBytes(), MediaType.APPLICATION_JSON)) - .isInstanceOf(JsonContentHandler.class); - } - - @Test - @Deprecated - public void whenForContentCalledWithXmlContentThenReturnsXmlContentHandler() { - assertThat(FieldTypeResolver.forContent("5".getBytes(), MediaType.APPLICATION_XML)) - .isInstanceOf(XmlContentHandler.class); - } - - @Test - @Deprecated - public void whenForContentIsCalledWithInvalidContentThenExceptionIsThrown() { - this.thrownException.expect(PayloadHandlingException.class); - FieldTypeResolver.forContent("some".getBytes(), MediaType.APPLICATION_XML); - } - @Test public void whenForContentWithDescriptorsCalledWithJsonContentThenReturnsJsonFieldTypeResolver() { assertThat(FieldTypeResolver.forContentWithDescriptors("{\"field\": \"value\"}".getBytes(), diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuilders.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuilders.java index 9c305139f..6dc03adb8 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuilders.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuilders.java @@ -215,30 +215,6 @@ public static MockHttpServletRequestBuilder request(HttpMethod httpMethod, URI u return MockMvcRequestBuilders.request(httpMethod, uri); } - /** - * Create a {@link MockMultipartHttpServletRequestBuilder} for a multipart request. - * The url template will be captured and made available for documentation. - * @param urlTemplate a URL template; the resulting URL will be encoded - * @param urlVariables zero or more URL variables - * @return the builder for the file upload request - * @deprecated since 2.0.6 in favor of {@link #multipart(String, Object...)} - */ - @Deprecated - public static MockMultipartHttpServletRequestBuilder fileUpload(String urlTemplate, Object... urlVariables) { - return multipart(urlTemplate, urlVariables); - } - - /** - * Create a {@link MockMultipartHttpServletRequestBuilder} for a multipart request. - * @param uri the URL - * @return the builder for the file upload request - * @deprecated since 2.0.6 in favor of {@link #multipart(URI)} - */ - @Deprecated - public static MockMultipartHttpServletRequestBuilder fileUpload(URI uri) { - return multipart(uri); - } - /** * Create a {@link MockMultipartHttpServletRequestBuilder} for a multipart request. * The URL template will be captured and made available for documentation. diff --git a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuildersTests.java b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuildersTests.java index 83203f65a..d4498f3ef 100644 --- a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuildersTests.java +++ b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuildersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,9 +30,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.fileUpload; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.head; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.multipart; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.options; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.patch; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; @@ -130,13 +130,13 @@ public void requestUri() { } @Test - public void fileUploadTemplate() { - assertTemplate(fileUpload("/{template}", "t"), HttpMethod.POST); + public void multipartTemplate() { + assertTemplate(multipart("/{template}", "t"), HttpMethod.POST); } @Test - public void fileUploadUri() { - assertUri(fileUpload(URI.create("/uri")), HttpMethod.POST); + public void multipartUri() { + assertUri(multipart(URI.create("/uri")), HttpMethod.POST); } private void assertTemplate(MockHttpServletRequestBuilder builder, HttpMethod httpMethod) {