Skip to content

Commit

Permalink
Remove deprecated code
Browse files Browse the repository at this point in the history
Closes gh-781
  • Loading branch information
wilkinsona committed Jan 17, 2022
1 parent d0bb8ef commit 4cf5892
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -16,7 +16,6 @@

package org.springframework.restdocs.payload;

import java.util.Collections;
import java.util.List;

import org.springframework.http.MediaType;
Expand All @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -126,18 +126,6 @@ private void verifyParameterDescriptors(Operation operation) {
*/
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4cf5892

Please sign in to comment.