Configure checkstyle and update code to comply
This commit configures Checkstyle and updates the build to comply with that configuration. The Eclipse JDT metadata has also been updated so that the output of Eclipse’s code formatting and clean-up is compliant with Checkstyle. The use of the latest version (6.10.1) of Checkstyle has required an upgrade to Gradle 2.7. Gradle hardcode’s the name of the Checkstyle’s main class which has changed between version 5 (Gradle’s default) and version 6. Closes gh-119
This commit is contained in:
@@ -21,13 +21,14 @@ import org.springframework.mock.web.MockHttpServletRequest;
|
||||
/**
|
||||
* Abstract configurer that declares methods that are internal to the documentation
|
||||
* configuration implementation.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
abstract class AbstractConfigurer {
|
||||
|
||||
/**
|
||||
* Applies the configuration, possibly by modifying the given {@code request}
|
||||
* Applies the configuration, possibly by modifying the given {@code request}.
|
||||
*
|
||||
* @param request the request that may be modified
|
||||
*/
|
||||
abstract void apply(MockHttpServletRequest request);
|
||||
|
||||
@@ -23,9 +23,9 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
/**
|
||||
* Base class for {@link NestedConfigurer} implementations.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
* @param <PARENT> The type of the configurer's parent
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
abstract class AbstractNestedConfigurer<PARENT extends MockMvcConfigurer> extends
|
||||
AbstractConfigurer implements NestedConfigurer<PARENT>, MockMvcConfigurer {
|
||||
|
||||
@@ -21,10 +21,9 @@ import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* An adapter to expose an {@link Enumeration} as an {@link Iterable}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
* @param <T> the type of the Enumeration's contents
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
final class IterableEnumeration<T> implements Iterable<T> {
|
||||
|
||||
@@ -57,8 +56,8 @@ final class IterableEnumeration<T> implements Iterable<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code Iterable} that will iterate over the given {@code enumeration}
|
||||
*
|
||||
* Creates an {@code Iterable} that will iterate over the given {@code enumeration}.
|
||||
*
|
||||
* @param <T> the type of the enumeration's elements
|
||||
* @param enumeration The enumeration to expose as an {@code Iterable}
|
||||
* @return the iterable
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.restdocs.mockmvc;
|
||||
|
||||
import static org.springframework.restdocs.mockmvc.IterableEnumeration.iterable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
@@ -43,10 +41,12 @@ import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import static org.springframework.restdocs.mockmvc.IterableEnumeration.iterable;
|
||||
|
||||
/**
|
||||
* A factory for creating an {@link OperationRequest} from a
|
||||
* {@link MockHttpServletRequest}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
*/
|
||||
@@ -62,7 +62,7 @@ class MockMvcOperationRequestFactory {
|
||||
|
||||
/**
|
||||
* Creates a new {@code OperationRequest} derived from the given {@code mockRequest}.
|
||||
*
|
||||
*
|
||||
* @param mockRequest the request
|
||||
* @return the {@code OperationRequest}
|
||||
* @throws Exception if the request could not be created
|
||||
|
||||
@@ -25,14 +25,14 @@ import org.springframework.restdocs.operation.StandardOperationResponse;
|
||||
/**
|
||||
* A factory for creating an {@link OperationResponse} derived from a
|
||||
* {@link MockHttpServletResponse}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class MockMvcOperationResponseFactory {
|
||||
|
||||
/**
|
||||
* Create a new {@code OperationResponse} derived from the given {@code mockResponse}.
|
||||
*
|
||||
*
|
||||
* @param mockResponse the response
|
||||
* @return the {@code OperationResponse}
|
||||
*/
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.springframework.test.web.servlet.setup.ConfigurableMockMvcBuilder;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Static factory methods for documenting RESTful APIs using Spring MVC Test
|
||||
*
|
||||
* Static factory methods for documenting RESTful APIs using Spring MVC Test.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public abstract class MockMvcRestDocumentation {
|
||||
@@ -39,7 +39,7 @@ public abstract class MockMvcRestDocumentation {
|
||||
/**
|
||||
* Provides access to a {@link MockMvcConfigurer} that can be used to configure a
|
||||
* {@link MockMvc} instance using the given {@code restDocumentation}.
|
||||
*
|
||||
*
|
||||
* @param restDocumentation the REST documentation
|
||||
* @return the configurer
|
||||
* @see ConfigurableMockMvcBuilder#apply(MockMvcConfigurer)
|
||||
@@ -52,7 +52,7 @@ public abstract class MockMvcRestDocumentation {
|
||||
/**
|
||||
* Documents the API call with the given {@code identifier} using the given
|
||||
* {@code snippets}.
|
||||
*
|
||||
*
|
||||
* @param identifier an identifier for the API call that is being documented
|
||||
* @param snippets the snippets that will document the API call
|
||||
* @return a Mock MVC {@code ResultHandler} that will produce the documentation
|
||||
@@ -68,7 +68,7 @@ public abstract class MockMvcRestDocumentation {
|
||||
* Documents the API call with the given {@code identifier} using the given
|
||||
* {@code snippets}. The given {@code requestPreprocessor} is applied to the request
|
||||
* before it is documented.
|
||||
*
|
||||
*
|
||||
* @param identifier an identifier for the API call that is being documented
|
||||
* @param requestPreprocessor the request preprocessor
|
||||
* @param snippets the snippets that will document the API call
|
||||
@@ -86,7 +86,7 @@ public abstract class MockMvcRestDocumentation {
|
||||
* Documents the API call with the given {@code identifier} using the given
|
||||
* {@code snippets}. The given {@code responsePreprocessor} is applied to the request
|
||||
* before it is documented.
|
||||
*
|
||||
*
|
||||
* @param identifier an identifier for the API call that is being documented
|
||||
* @param responsePreprocessor the response preprocessor
|
||||
* @param snippets the snippets that will document the API call
|
||||
@@ -105,7 +105,7 @@ public abstract class MockMvcRestDocumentation {
|
||||
* {@code snippets}. The given {@code requestPreprocessor} and
|
||||
* {@code responsePreprocessor} are applied to the request and response respectively
|
||||
* before they are documented.
|
||||
*
|
||||
*
|
||||
* @param identifier an identifier for the API call that is being documented
|
||||
* @param requestPreprocessor the request preprocessor
|
||||
* @param responsePreprocessor the response preprocessor
|
||||
|
||||
@@ -20,15 +20,15 @@ import org.springframework.test.web.servlet.setup.MockMvcConfigurer;
|
||||
|
||||
/**
|
||||
* A configurer that is nested and, therefore, has a parent.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
* @param <PARENT> The parent's type
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
interface NestedConfigurer<PARENT extends MockMvcConfigurer> {
|
||||
|
||||
/**
|
||||
* Returns the configurer's parent
|
||||
*
|
||||
* Returns the configurer's parent.
|
||||
*
|
||||
* @return the parent
|
||||
*/
|
||||
PARENT and();
|
||||
|
||||
@@ -33,8 +33,8 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
/**
|
||||
* A {@link MockMvcConfigurer} that can be used to configure the documentation
|
||||
*
|
||||
* A {@link MockMvcConfigurer} that can be used to configure the documentation.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Dmitriy Mayboroda
|
||||
* @see ConfigurableMockMvcBuilder#apply(MockMvcConfigurer)
|
||||
@@ -55,7 +55,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter
|
||||
/**
|
||||
* Creates a new {code RestDocumentationMockMvcConfigurer} that will use the given
|
||||
* {@code restDocumentation} when configuring MockMvc.
|
||||
*
|
||||
*
|
||||
* @param restDocumentation the rest documentation
|
||||
* @see MockMvcRestDocumentation#documentationConfiguration(RestDocumentation)
|
||||
*/
|
||||
@@ -69,7 +69,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter
|
||||
/**
|
||||
* Returns a {@link UriConfigurer} that can be used to configure the request URIs that
|
||||
* will be documented.
|
||||
*
|
||||
*
|
||||
* @return the URI configurer
|
||||
*/
|
||||
public UriConfigurer uris() {
|
||||
@@ -79,7 +79,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter
|
||||
/**
|
||||
* Returns a {@link SnippetConfigurer} that can be used to configure the snippets that
|
||||
* will be generated.
|
||||
*
|
||||
*
|
||||
* @return the snippet configurer
|
||||
*/
|
||||
public SnippetConfigurer snippets() {
|
||||
@@ -88,7 +88,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter
|
||||
|
||||
/**
|
||||
* Configures the {@link TemplateEngine} that will be used for snippet rendering.
|
||||
*
|
||||
*
|
||||
* @param templateEngine the template engine to use
|
||||
* @return {@code this}
|
||||
*/
|
||||
@@ -100,7 +100,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter
|
||||
/**
|
||||
* Configures the {@link WriterResolver} that will be used to resolve a writer for a
|
||||
* snippet.
|
||||
*
|
||||
*
|
||||
* @param writerResolver The writer resolver to use
|
||||
* @return {@code this}
|
||||
*/
|
||||
@@ -115,7 +115,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter
|
||||
return this.requestPostProcessor;
|
||||
}
|
||||
|
||||
private static class ContentLengthHeaderConfigurer extends AbstractConfigurer {
|
||||
private static final class ContentLengthHeaderConfigurer extends AbstractConfigurer {
|
||||
|
||||
@Override
|
||||
void apply(MockHttpServletRequest request) {
|
||||
@@ -128,7 +128,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter
|
||||
|
||||
}
|
||||
|
||||
private static class TemplateEngineConfigurer extends AbstractConfigurer {
|
||||
private static final class TemplateEngineConfigurer extends AbstractConfigurer {
|
||||
|
||||
private TemplateEngine templateEngine = new MustacheTemplateEngine(
|
||||
new StandardTemplateResourceResolver());
|
||||
@@ -144,7 +144,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter
|
||||
|
||||
}
|
||||
|
||||
private static class WriterResolverConfigurer extends AbstractConfigurer {
|
||||
private static final class WriterResolverConfigurer extends AbstractConfigurer {
|
||||
|
||||
private WriterResolver writerResolver;
|
||||
|
||||
@@ -167,7 +167,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter
|
||||
|
||||
}
|
||||
|
||||
private static class ConfigurerApplyingRequestPostProcessor implements
|
||||
private static final class ConfigurerApplyingRequestPostProcessor implements
|
||||
RequestPostProcessor {
|
||||
|
||||
private final RestDocumentation restDocumentation;
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
* template and makes it available for documentation. Required when
|
||||
* {@link RequestDocumentation#pathParameters(org.springframework.restdocs.request.ParameterDescriptor...)
|
||||
* ) documenting path parameters} and recommended for general usage.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @see MockMvcRequestBuilders
|
||||
* @see RequestDocumentation#pathParameters(org.springframework.restdocs.request.ParameterDescriptor...)
|
||||
@@ -47,7 +47,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a GET 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 GET request
|
||||
@@ -60,7 +60,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a GET request.
|
||||
*
|
||||
*
|
||||
* @param uri the URL
|
||||
* @return the builder for the GET request
|
||||
*/
|
||||
@@ -71,7 +71,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a POST 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 POST request
|
||||
@@ -84,7 +84,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a POST request.
|
||||
*
|
||||
*
|
||||
* @param uri the URL
|
||||
* @return the builder for the POST request
|
||||
*/
|
||||
@@ -95,7 +95,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a PUT 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 PUT request
|
||||
@@ -108,7 +108,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a PUT request.
|
||||
*
|
||||
*
|
||||
* @param uri the URL
|
||||
* @return the builder for the PUT request
|
||||
*/
|
||||
@@ -119,7 +119,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a PATCH 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 PATCH request
|
||||
@@ -132,7 +132,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a PATCH request.
|
||||
*
|
||||
*
|
||||
* @param uri the URL
|
||||
* @return the builder for the PATCH request
|
||||
*/
|
||||
@@ -143,7 +143,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a DELETE 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 DELETE request
|
||||
@@ -156,7 +156,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a DELETE request.
|
||||
*
|
||||
*
|
||||
* @param uri the URL
|
||||
* @return the builder for the DELETE request
|
||||
*/
|
||||
@@ -167,7 +167,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for an OPTIONS 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 OPTIONS request
|
||||
@@ -180,7 +180,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for an OPTIONS request.
|
||||
*
|
||||
*
|
||||
* @param uri the URL
|
||||
* @return the builder for the OPTIONS request
|
||||
*/
|
||||
@@ -191,7 +191,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a HEAD 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 HEAD request
|
||||
@@ -204,7 +204,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a HEAD request.
|
||||
*
|
||||
*
|
||||
* @param uri the URL
|
||||
* @return the builder for the HEAD request
|
||||
*/
|
||||
@@ -215,7 +215,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a request with the given HTTP
|
||||
* method. The url template will be captured and made available for documentation.
|
||||
*
|
||||
*
|
||||
* @param httpMethod the HTTP method
|
||||
* @param urlTemplate a URL template; the resulting URL will be encoded
|
||||
* @param urlVariables zero or more URL variables
|
||||
@@ -241,7 +241,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} 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
|
||||
@@ -255,7 +255,7 @@ public abstract class RestDocumentationRequestBuilders {
|
||||
|
||||
/**
|
||||
* Create a {@link MockHttpServletRequestBuilder} for a multipart request.
|
||||
*
|
||||
*
|
||||
* @param uri the URL
|
||||
* @return the builder for the file upload request
|
||||
*/
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.restdocs.mockmvc;
|
||||
|
||||
import static org.springframework.restdocs.mockmvc.IterableEnumeration.iterable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -35,9 +33,11 @@ import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.ResultHandler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import static org.springframework.restdocs.mockmvc.IterableEnumeration.iterable;
|
||||
|
||||
/**
|
||||
* A Spring MVC Test {@code ResultHandler} for documenting RESTful APIs.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Andreas Evers
|
||||
* @see MockMvcRestDocumentation#document(String, Snippet...)
|
||||
@@ -105,7 +105,7 @@ public class RestDocumentationResultHandler implements ResultHandler {
|
||||
/**
|
||||
* Adds the given {@code snippets} such that that are documented when this result
|
||||
* handler is called.
|
||||
*
|
||||
*
|
||||
* @param snippets the snippets to add
|
||||
* @return this {@code ResultDocumentationResultHandler}
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ public class RestDocumentationResultHandler implements ResultHandler {
|
||||
return combinedSnippets;
|
||||
}
|
||||
|
||||
static final class IdentityOperationRequestPreprocessor implements
|
||||
private static final class IdentityOperationRequestPreprocessor implements
|
||||
OperationRequestPreprocessor {
|
||||
|
||||
@Override
|
||||
@@ -133,7 +133,7 @@ public class RestDocumentationResultHandler implements ResultHandler {
|
||||
|
||||
}
|
||||
|
||||
static final class IdentityOperationResponsePreprocessor implements
|
||||
private static final class IdentityOperationResponsePreprocessor implements
|
||||
OperationResponsePreprocessor {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.restdocs.snippet.WriterResolver;
|
||||
|
||||
/**
|
||||
* A configurer that can be used to configure the generated documentation snippets.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class SnippetConfigurer extends
|
||||
@@ -38,7 +38,8 @@ public class SnippetConfigurer extends
|
||||
HttpDocumentation.httpResponse());
|
||||
|
||||
/**
|
||||
* The default encoding for documentation snippets
|
||||
* The default encoding for documentation snippets.
|
||||
*
|
||||
* @see #withEncoding(String)
|
||||
*/
|
||||
public static final String DEFAULT_SNIPPET_ENCODING = "UTF-8";
|
||||
@@ -52,6 +53,7 @@ public class SnippetConfigurer extends
|
||||
/**
|
||||
* Configures any documentation snippets to be written using the given
|
||||
* {@code encoding}. The default is UTF-8.
|
||||
*
|
||||
* @param encoding the encoding
|
||||
* @return {@code this}
|
||||
*/
|
||||
@@ -70,7 +72,7 @@ public class SnippetConfigurer extends
|
||||
|
||||
/**
|
||||
* Configures the documentation snippets that will be produced by default.
|
||||
*
|
||||
*
|
||||
* @param defaultSnippets the default snippets
|
||||
* @return {@code this}
|
||||
*/
|
||||
|
||||
@@ -19,26 +19,30 @@ package org.springframework.restdocs.mockmvc;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
/**
|
||||
* A configurer that can be used to configure the documented URIs
|
||||
*
|
||||
* A configurer that can be used to configure the documented URIs.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class UriConfigurer extends AbstractNestedConfigurer<RestDocumentationMockMvcConfigurer> {
|
||||
public class UriConfigurer extends
|
||||
AbstractNestedConfigurer<RestDocumentationMockMvcConfigurer> {
|
||||
|
||||
/**
|
||||
* The default scheme for documented URIs
|
||||
* The default scheme for documented URIs.
|
||||
*
|
||||
* @see #withScheme(String)
|
||||
*/
|
||||
public static final String DEFAULT_SCHEME = "http";
|
||||
|
||||
/**
|
||||
* The defalt host for documented URIs
|
||||
* The defalt host for documented URIs.
|
||||
*
|
||||
* @see #withHost(String)
|
||||
*/
|
||||
public static final String DEFAULT_HOST = "localhost";
|
||||
|
||||
/**
|
||||
* The default port for documented URIs
|
||||
* The default port for documented URIs.
|
||||
*
|
||||
* @see #withPort(int)
|
||||
*/
|
||||
public static final int DEFAULT_PORT = 8080;
|
||||
@@ -49,14 +53,14 @@ public class UriConfigurer extends AbstractNestedConfigurer<RestDocumentationMoc
|
||||
|
||||
private int port = DEFAULT_PORT;
|
||||
|
||||
protected UriConfigurer(RestDocumentationMockMvcConfigurer parent) {
|
||||
UriConfigurer(RestDocumentationMockMvcConfigurer parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures any documented URIs to use the given {@code scheme}. The default is
|
||||
* {@code http}.
|
||||
*
|
||||
*
|
||||
* @param scheme The URI scheme
|
||||
* @return {@code this}
|
||||
*/
|
||||
@@ -68,7 +72,7 @@ public class UriConfigurer extends AbstractNestedConfigurer<RestDocumentationMoc
|
||||
/**
|
||||
* Configures any documented URIs to use the given {@code host}. The default is
|
||||
* {@code localhost}.
|
||||
*
|
||||
*
|
||||
* @param host The URI host
|
||||
* @return {@code this}
|
||||
*/
|
||||
@@ -80,7 +84,7 @@ public class UriConfigurer extends AbstractNestedConfigurer<RestDocumentationMoc
|
||||
/**
|
||||
* Configures any documented URIs to use the given {@code port}. The default is
|
||||
* {@code 8080}.
|
||||
*
|
||||
*
|
||||
* @param port The URI port
|
||||
* @return {@code this}
|
||||
*/
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
/**
|
||||
* Core classes for using Spring REST Docs with Spring Test's MockMvc.
|
||||
*/
|
||||
package org.springframework.restdocs.mockmvc;
|
||||
package org.springframework.restdocs.mockmvc;
|
||||
|
||||
|
||||
@@ -16,15 +16,6 @@
|
||||
|
||||
package org.springframework.restdocs.mockmvc;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.hasEntry;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
@@ -37,14 +28,22 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.restdocs.mockmvc.MockMvcOperationRequestFactory;
|
||||
import org.springframework.restdocs.operation.OperationRequest;
|
||||
import org.springframework.restdocs.operation.OperationRequestPart;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.hasEntry;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link MockMvcOperationRequestFactory}
|
||||
* Tests for {@link MockMvcOperationRequestFactory}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@@ -183,13 +182,13 @@ public class MockMvcOperationRequestFactoryTests {
|
||||
MockHttpServletRequest mockRequest = MockMvcRequestBuilders.get("/foo")
|
||||
.buildRequest(new MockServletContext());
|
||||
Part mockPart = mock(Part.class);
|
||||
when(mockPart.getHeaderNames()).thenReturn(Arrays.asList("a", "b"));
|
||||
when(mockPart.getHeaders("a")).thenReturn(Arrays.asList("alpha"));
|
||||
when(mockPart.getHeaders("b")).thenReturn(Arrays.asList("bravo", "banana"));
|
||||
when(mockPart.getInputStream()).thenReturn(
|
||||
given(mockPart.getHeaderNames()).willReturn(Arrays.asList("a", "b"));
|
||||
given(mockPart.getHeaders("a")).willReturn(Arrays.asList("alpha"));
|
||||
given(mockPart.getHeaders("b")).willReturn(Arrays.asList("bravo", "banana"));
|
||||
given(mockPart.getInputStream()).willReturn(
|
||||
new ByteArrayInputStream(new byte[] { 1, 2, 3, 4 }));
|
||||
when(mockPart.getName()).thenReturn("part-name");
|
||||
when(mockPart.getSubmittedFileName()).thenReturn("submitted.txt");
|
||||
given(mockPart.getName()).willReturn("part-name");
|
||||
given(mockPart.getSubmittedFileName()).willReturn("submitted.txt");
|
||||
mockRequest.addPart(mockPart);
|
||||
OperationRequest request = this.factory.createOperationRequest(mockRequest);
|
||||
assertThat(request.getParts().size(), is(1));
|
||||
@@ -207,14 +206,14 @@ public class MockMvcOperationRequestFactoryTests {
|
||||
MockHttpServletRequest mockRequest = MockMvcRequestBuilders.get("/foo")
|
||||
.buildRequest(new MockServletContext());
|
||||
Part mockPart = mock(Part.class);
|
||||
when(mockPart.getHeaderNames()).thenReturn(Arrays.asList("a", "b"));
|
||||
when(mockPart.getHeaders("a")).thenReturn(Arrays.asList("alpha"));
|
||||
when(mockPart.getHeaders("b")).thenReturn(Arrays.asList("bravo", "banana"));
|
||||
when(mockPart.getInputStream()).thenReturn(
|
||||
given(mockPart.getHeaderNames()).willReturn(Arrays.asList("a", "b"));
|
||||
given(mockPart.getHeaders("a")).willReturn(Arrays.asList("alpha"));
|
||||
given(mockPart.getHeaders("b")).willReturn(Arrays.asList("bravo", "banana"));
|
||||
given(mockPart.getInputStream()).willReturn(
|
||||
new ByteArrayInputStream(new byte[] { 1, 2, 3, 4 }));
|
||||
when(mockPart.getName()).thenReturn("part-name");
|
||||
when(mockPart.getSubmittedFileName()).thenReturn("submitted.png");
|
||||
when(mockPart.getContentType()).thenReturn("image/png");
|
||||
given(mockPart.getName()).willReturn("part-name");
|
||||
given(mockPart.getSubmittedFileName()).willReturn("submitted.png");
|
||||
given(mockPart.getContentType()).willReturn("image/png");
|
||||
mockRequest.addPart(mockPart);
|
||||
OperationRequest request = this.factory.createOperationRequest(mockRequest);
|
||||
assertThat(request.getParts().size(), is(1));
|
||||
|
||||
@@ -16,36 +16,6 @@
|
||||
|
||||
package org.springframework.restdocs.mockmvc;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.restdocs.curl.CurlDocumentation.curlRequest;
|
||||
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
|
||||
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.maskLinks;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.replacePattern;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
|
||||
import static org.springframework.restdocs.snippet.Attributes.attributes;
|
||||
import static org.springframework.restdocs.snippet.Attributes.key;
|
||||
import static org.springframework.restdocs.test.SnippetMatchers.codeBlock;
|
||||
import static org.springframework.restdocs.test.SnippetMatchers.httpRequest;
|
||||
import static org.springframework.restdocs.test.SnippetMatchers.httpResponse;
|
||||
import static org.springframework.restdocs.test.SnippetMatchers.snippet;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
@@ -80,11 +50,40 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.restdocs.curl.CurlDocumentation.curlRequest;
|
||||
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
|
||||
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.maskLinks;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
|
||||
import static org.springframework.restdocs.operation.preprocess.Preprocessors.replacePattern;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
|
||||
import static org.springframework.restdocs.snippet.Attributes.attributes;
|
||||
import static org.springframework.restdocs.snippet.Attributes.key;
|
||||
import static org.springframework.restdocs.test.SnippetMatchers.codeBlock;
|
||||
import static org.springframework.restdocs.test.SnippetMatchers.httpRequest;
|
||||
import static org.springframework.restdocs.test.SnippetMatchers.httpResponse;
|
||||
import static org.springframework.restdocs.test.SnippetMatchers.snippet;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* Integration tests for Spring REST Docs
|
||||
*
|
||||
* Integration tests for using Spring REST Docs with Spring Test's Mock MVC.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Dewet Diener
|
||||
*/
|
||||
@@ -371,9 +370,12 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test configuration that enables Spring MVC.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
static class TestConfiguration extends WebMvcConfigurerAdapter {
|
||||
static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
public TestController testController() {
|
||||
@@ -383,7 +385,7 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
}
|
||||
|
||||
@RestController
|
||||
static class TestController {
|
||||
private static class TestController {
|
||||
|
||||
@RequestMapping(value = "/", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, Object>> foo() {
|
||||
|
||||
@@ -16,12 +16,6 @@
|
||||
|
||||
package org.springframework.restdocs.mockmvc;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Rule;
|
||||
@@ -33,6 +27,12 @@ import org.springframework.test.web.servlet.request.RequestPostProcessor;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link RestDocumentationMockMvcConfigurer}.
|
||||
*
|
||||
|
||||
@@ -16,6 +16,16 @@
|
||||
|
||||
package org.springframework.restdocs.mockmvc;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -29,20 +39,9 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuild
|
||||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put;
|
||||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.request;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
|
||||
/**
|
||||
* Tests for {@link RestDocumentationRequestBuilders}
|
||||
*
|
||||
* Tests for {@link RestDocumentationRequestBuilders}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-2015 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.restdocs.mockmvc.test;
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.restdocs.RestDocumentationContext;
|
||||
import org.springframework.restdocs.snippet.RestDocumentationContextPlaceholderResolver;
|
||||
import org.springframework.restdocs.snippet.StandardWriterResolver;
|
||||
import org.springframework.restdocs.snippet.WriterResolver;
|
||||
import org.springframework.restdocs.templates.StandardTemplateResourceResolver;
|
||||
import org.springframework.restdocs.templates.TemplateEngine;
|
||||
import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.RequestBuilder;
|
||||
import org.springframework.web.servlet.FlashMap;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* A minimal stub implementation of {@link MvcResult}
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
*/
|
||||
public class StubMvcResult implements MvcResult {
|
||||
|
||||
private final MockHttpServletRequest request;
|
||||
|
||||
private final MockHttpServletResponse response;
|
||||
|
||||
public static StubMvcResult result() {
|
||||
return new StubMvcResult();
|
||||
}
|
||||
|
||||
public static StubMvcResult result(RequestBuilder requestBuilder) {
|
||||
return new StubMvcResult(requestBuilder);
|
||||
}
|
||||
|
||||
public static StubMvcResult result(RequestBuilder requestBuilder,
|
||||
MockHttpServletResponse response) {
|
||||
return new StubMvcResult(requestBuilder, response);
|
||||
}
|
||||
|
||||
public static StubMvcResult result(MockHttpServletRequest request) {
|
||||
return new StubMvcResult(request);
|
||||
}
|
||||
|
||||
public static StubMvcResult result(MockHttpServletResponse response) {
|
||||
return new StubMvcResult(response);
|
||||
}
|
||||
|
||||
public static StubMvcResult result(MockHttpServletRequest request,
|
||||
MockHttpServletResponse response) {
|
||||
return new StubMvcResult(request, response);
|
||||
}
|
||||
|
||||
private StubMvcResult() {
|
||||
this(new MockHttpServletRequest(), new MockHttpServletResponse());
|
||||
}
|
||||
|
||||
private StubMvcResult(MockHttpServletRequest request) {
|
||||
this(request, new MockHttpServletResponse());
|
||||
}
|
||||
|
||||
private StubMvcResult(MockHttpServletResponse response) {
|
||||
this(new MockHttpServletRequest(), response);
|
||||
}
|
||||
|
||||
private StubMvcResult(RequestBuilder requestBuilder, MockHttpServletResponse response) {
|
||||
this(requestBuilder.buildRequest(new MockServletContext()), response);
|
||||
}
|
||||
|
||||
private StubMvcResult(MockHttpServletRequest request, MockHttpServletResponse response) {
|
||||
this.request = request;
|
||||
if (this.request.getAttribute(TemplateEngine.class.getName()) == null) {
|
||||
this.request.setAttribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(new StandardTemplateResourceResolver()));
|
||||
}
|
||||
RestDocumentationContext context = new RestDocumentationContext(null, null, null);
|
||||
this.request.setAttribute(RestDocumentationContext.class.getName(), context);
|
||||
if (this.request.getAttribute(WriterResolver.class.getName()) == null) {
|
||||
this.request.setAttribute(WriterResolver.class.getName(),
|
||||
new StandardWriterResolver(
|
||||
new RestDocumentationContextPlaceholderResolver(context)));
|
||||
}
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
private StubMvcResult(RequestBuilder requestBuilder) {
|
||||
this(requestBuilder.buildRequest(new MockServletContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MockHttpServletRequest getRequest() {
|
||||
return this.request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MockHttpServletResponse getResponse() {
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getHandler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerInterceptor[] getInterceptors() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView getModelAndView() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Exception getResolvedException() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlashMap getFlashMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAsyncResult() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAsyncResult(long timeToWait) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-2015 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.restdocs.mockmvc.test;
|
||||
|
||||
import org.springframework.restdocs.RestDocumentationContext;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
|
||||
public class TestRequestBuilders {
|
||||
|
||||
private TestRequestBuilders() {
|
||||
|
||||
}
|
||||
|
||||
public static MockHttpServletRequestBuilder get(String urlTemplate,
|
||||
Object... urlVariables) {
|
||||
return org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get(
|
||||
urlTemplate, urlVariables).requestAttr(
|
||||
RestDocumentationContext.class.getName(),
|
||||
new RestDocumentationContext(null, null, null));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user