Remove deprecated code

Closes gh-781
This commit is contained in:
Andy Wilkinson
2022-01-17 13:24:58 +00:00
parent d0bb8ef59d
commit 4cf5892015
6 changed files with 9 additions and 97 deletions

View File

@@ -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 @@ import org.springframework.http.HttpStatus;
*/
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

View File

@@ -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 @@ import org.springframework.http.MediaType;
*/
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}.

View File

@@ -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 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet {
*/
protected abstract void verificationFailed(Set<String> undocumentedParameters, Set<String> 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<String, ParameterDescriptor> getFieldDescriptors() {
return this.descriptorsByName;
}
/**
* Returns a {@code Map} of {@link ParameterDescriptor ParameterDescriptors} that will
* be used to generate the documentation key by their

View File

@@ -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("<a><b>5</b></a>".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(),

View File

@@ -215,30 +215,6 @@ public abstract class RestDocumentationRequestBuilders {
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.

View File

@@ -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 org.springframework.test.web.servlet.request.MockHttpServletRequestBuilde
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 class RestDocumentationRequestBuildersTests {
}
@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) {