Skip to content

Commit ce17a92

Browse files
committed
Polish contribution
Closes gh-15978
1 parent cf89ebc commit ce17a92

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7695,6 +7695,28 @@ generate the default snippets. The following example shows a
76957695

76967696

76977697

7698+
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-docs-web-test-client]]
7699+
===== Auto-configured Spring REST Docs Tests with WebTestClient
7700+
`@AutoConfigureRestDocs` can also be used with `WebTestClient`. You can inject it by using
7701+
`@Autowired` and use it in your tests as you normally would when using `@WebFluxTest` and
7702+
Spring REST Docs, as shown in the following example:
7703+
7704+
[source,java,indent=0]
7705+
----
7706+
include::{code-examples}/test/autoconfigure/restdocs/webclient/UsersDocumentationTests.java[tag=source]
7707+
----
7708+
7709+
If you require more control over Spring REST Docs configuration than offered by the
7710+
attributes of `@AutoConfigureRestDocs`, you can use a
7711+
`RestDocsWebTestClientConfigurationCustomizer` bean, as shown in the following example:
7712+
7713+
[source,java,indent=0]
7714+
----
7715+
include::{code-examples}/test/autoconfigure/restdocs/webclient/AdvancedConfigurationExample.java[tag=configuration]
7716+
----
7717+
7718+
7719+
76987720
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-docs-rest-assured]]
76997721
===== Auto-configured Spring REST Docs Tests with REST Assured
77007722
`@AutoConfigureRestDocs` makes a `RequestSpecification` bean, preconfigured to use Spring
@@ -7716,25 +7738,7 @@ bean can be used, as shown in the following example:
77167738
include::{code-examples}/test/autoconfigure/restdocs/restassured/AdvancedConfigurationExample.java[tag=configuration]
77177739
----
77187740

7719-
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-docs-web-test-client]]
7720-
===== Auto-configured Spring REST Docs Tests with WebTestClient
7721-
`@AutoConfigureRestDocs` could be used in conjunction with a `@WebFluxTest` to generate REST Docs.
7722-
`@AutoConfigureRestDocs` customizes the `WebTestClient` bean to use Spring REST Docs. You can
7723-
inject it by using `@Autowired` and use it in your tests. Here is a quick sample:
7724-
7725-
[source,java,indent=0]
7726-
----
7727-
include::{code-examples}/test/autoconfigure/restdocs/webclient/UsersDocumentationTests.java[tag=source]
7728-
----
7729-
7730-
If you require more control over Spring REST Docs configuration than offered by the
7731-
attributes of `@AutoConfigureRestDocs`, you can use a
7732-
`RestDocsWebTestClientConfigurationCustomizer` bean, as shown in the following example:
77337741

7734-
[source,java,indent=0]
7735-
----
7736-
include::{code-examples}/test/autoconfigure/restdocs/webclient/AdvancedRestDocsWebTestClientConfigurationExample.java[tag=configuration]
7737-
----
77387742

77397743
[[boot-features-testing-spring-boot-applications-testing-auto-configured-additional-auto-config]]
77407744
==== Additional Auto-configuration and Slicing
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.boot.docs.test.autoconfigure.restdocs.webclient;
1718

1819
import org.springframework.boot.test.autoconfigure.restdocs.RestDocsWebTestClientConfigurationCustomizer;
1920
import org.springframework.boot.test.context.TestConfiguration;
2021
import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentationConfigurer;
2122

22-
public class AdvancedRestDocsWebTestClientConfigurationExample {
23+
public class AdvancedConfigurationExample {
2324

2425
// tag::configuration[]
2526
@TestConfiguration
26-
static class CustomizationConfiguration
27+
public static class CustomizationConfiguration
2728
implements RestDocsWebTestClientConfigurationCustomizer {
2829

2930
@Override

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/webclient/UsersDocumentationTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.boot.docs.test.autoconfigure.restdocs.webclient;
1718

1819
// tag::source[]
19-
2020
import org.junit.jupiter.api.Test;
2121
import org.junit.runner.RunWith;
2222

@@ -40,7 +40,6 @@ public class UsersDocumentationTests {
4040
void listUsers() {
4141
this.webTestClient.get().uri("/").exchange().expectStatus().isOk().expectBody()
4242
.consumeWith(document("list-users"));
43-
4443
}
4544

4645
}

0 commit comments

Comments
 (0)