diff --git a/docs/src/docs/asciidoc/customizing-requests-and-responses.adoc b/docs/src/docs/asciidoc/customizing-requests-and-responses.adoc index 458e47a1..f47b9fd0 100644 --- a/docs/src/docs/asciidoc/customizing-requests-and-responses.adoc +++ b/docs/src/docs/asciidoc/customizing-requests-and-responses.adoc @@ -143,12 +143,13 @@ parameters. [[customizing-requests-and-responses-preprocessors-modify-uris]] ==== Modifying URIs -TIP: If you are using MockMvc or WebTestclient, URIs should be customized by -<>. +TIP: If you are using MockMvc or a WebTestClient that is not bound to a server, +URIs should be customized by <>. -`modifyUris` on `RestAssuredPreprocessors` can be used to modify any URIs in a request -or a response. When using REST Assured, this allows you to customize the URIs that appear -in the documentation while testing a local instance of the service. +`modifyUris` on `Preprocessors` can be used to modify any URIs in a request +or a response. When using REST Assured or WebTestClient bound to a server, this +allows you to customize the URIs that appear in the documentation while testing a +local instance of the service. diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/Preprocessors.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/Preprocessors.java index 23a31037..4aa19a63 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/Preprocessors.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/Preprocessors.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2015 the original author or authors. + * Copyright 2014-2018 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. @@ -151,4 +151,15 @@ public final class Preprocessors { return new ParametersModifyingOperationPreprocessor(); } + /** + * Returns a {@code UriModifyingOperationPreprocessor} that will modify URIs in the + * request or response by changing one or more of their host, scheme, and port. + * + * @return the preprocessor + * @since 2.0.1 + */ + public static UriModifyingOperationPreprocessor modifyUris() { + return new UriModifyingOperationPreprocessor(); + } + } diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/UriModifyingOperationPreprocessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/UriModifyingOperationPreprocessor.java index f2980721..ae28056f 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/UriModifyingOperationPreprocessor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/UriModifyingOperationPreprocessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2018 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. @@ -51,7 +51,7 @@ import org.springframework.web.util.UriComponentsBuilder; * * * @author Andy Wilkinson - * @since 1.2.0 + * @since 2.0.1 */ public class UriModifyingOperationPreprocessor implements OperationPreprocessor { diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/UriModifyingOperationPreprocessorTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/UriModifyingOperationPreprocessorTests.java index f861c1f7..27278eb5 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/UriModifyingOperationPreprocessorTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/UriModifyingOperationPreprocessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2018 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. diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/operation/preprocess/RestAssuredPreprocessors.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/operation/preprocess/RestAssuredPreprocessors.java index 8d94649f..49b669a1 100644 --- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/operation/preprocess/RestAssuredPreprocessors.java +++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/operation/preprocess/RestAssuredPreprocessors.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2018 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. @@ -19,6 +19,7 @@ package org.springframework.restdocs.restassured3.operation.preprocess; import org.springframework.restdocs.operation.Operation; import org.springframework.restdocs.operation.OperationRequest; import org.springframework.restdocs.operation.OperationResponse; +import org.springframework.restdocs.operation.preprocess.Preprocessors; import org.springframework.restdocs.operation.preprocess.UriModifyingOperationPreprocessor; /** @@ -30,7 +31,10 @@ import org.springframework.restdocs.operation.preprocess.UriModifyingOperationPr * * @author Andy Wilkinson * @since 1.1.0 + * @deprecated since 2.0.1 in favor of {@link Preprocessors} and, specifically, + * {@link Preprocessors#modifyUris()} */ +@Deprecated public abstract class RestAssuredPreprocessors { private RestAssuredPreprocessors() { @@ -42,7 +46,9 @@ public abstract class RestAssuredPreprocessors { * request or response by changing one or more of their host, scheme, and port. * * @return the preprocessor + * @deprecated since 2.0.1 in favor of {@link Preprocessors#modifyUris()} */ + @Deprecated public static UriModifyingOperationPreprocessor modifyUris() { return new UriModifyingOperationPreprocessor(); } diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/operation/preprocess/UriModifyingOperationPreprocessor.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/operation/preprocess/UriModifyingOperationPreprocessor.java index 25c69714..267dbc24 100644 --- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/operation/preprocess/UriModifyingOperationPreprocessor.java +++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/operation/preprocess/UriModifyingOperationPreprocessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2018 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. @@ -37,9 +37,11 @@ import org.springframework.restdocs.operation.preprocess.OperationPreprocessor; * * @author Andy Wilkinson * @since 1.2.0 - * @deprecated use {@link org.springframework.restdocs.operation.preprocess.UriModifyingOperationPreprocessor} instead + * @deprecated since 2.0.1 in favor of + * {@link org.springframework.restdocs.operation.preprocess.UriModifyingOperationPreprocessor} */ @Deprecated -public class UriModifyingOperationPreprocessor extends org.springframework.restdocs.operation.preprocess.UriModifyingOperationPreprocessor { +public class UriModifyingOperationPreprocessor extends + org.springframework.restdocs.operation.preprocess.UriModifyingOperationPreprocessor { } diff --git a/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentationIntegrationTests.java b/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentationIntegrationTests.java index fde03e74..57ff2a10 100644 --- a/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentationIntegrationTests.java +++ b/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentationIntegrationTests.java @@ -43,6 +43,7 @@ import static org.springframework.restdocs.headers.HeaderDocumentation.responseH import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel; import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links; import static org.springframework.restdocs.operation.preprocess.Preprocessors.maskLinks; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyUris; 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; @@ -59,7 +60,6 @@ import static org.springframework.restdocs.request.RequestDocumentation.requestP import static org.springframework.restdocs.request.RequestDocumentation.requestParts; import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document; import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration; -import static org.springframework.restdocs.restassured3.operation.preprocess.RestAssuredPreprocessors.modifyUris; import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; import static org.springframework.restdocs.test.SnippetMatchers.codeBlock; import static org.springframework.restdocs.test.SnippetMatchers.httpRequest; diff --git a/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/operation/preprocess/UriModifyingOperationPreprocessorTests.java b/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/operation/preprocess/UriModifyingOperationPreprocessorTests.java index e55a98a6..fb34f816 100644 --- a/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/operation/preprocess/UriModifyingOperationPreprocessorTests.java +++ b/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/operation/preprocess/UriModifyingOperationPreprocessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2018 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. @@ -41,7 +41,6 @@ import static org.junit.Assert.assertThat; * Tests for {@link UriModifyingOperationPreprocessor}. * * @author Andy Wilkinson - * @deprecated use {@link org.springframework.restdocs.operation.preprocess.UriModifyingOperationPreprocessorTests} instead */ @Deprecated public class UriModifyingOperationPreprocessorTests {