Skip to content

Commit fbad11e

Browse files
committed
Update documentation examples to use new modifyHeaders preprocessor
Closes gh-827
1 parent 5b7b304 commit fbad11e

9 files changed

+27
-27
lines changed

docs/src/test/java/com/example/mockmvc/CustomDefaultOperationPreprocessors.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,8 +25,8 @@
2525
import org.springframework.web.context.WebApplicationContext;
2626

2727
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
28+
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
2829
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
29-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
3030

3131
public class CustomDefaultOperationPreprocessors {
3232

@@ -43,7 +43,7 @@ public void setup() {
4343
// tag::custom-default-operation-preprocessors[]
4444
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
4545
.apply(documentationConfiguration(this.restDocumentation).operationPreprocessors()
46-
.withRequestDefaults(removeHeaders("Foo")) // <1>
46+
.withRequestDefaults(modifyHeaders().remove("Foo")) // <1>
4747
.withResponseDefaults(prettyPrint())) // <2>
4848
.build();
4949
// end::custom-default-operation-preprocessors[]

docs/src/test/java/com/example/mockmvc/EveryTestPreprocessing.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,8 +29,8 @@
2929
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
3030
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
3131
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
32+
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
3233
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
33-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
3434
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
3535

3636
public class EveryTestPreprocessing {
@@ -47,7 +47,7 @@ public class EveryTestPreprocessing {
4747
public void setup() {
4848
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
4949
.apply(documentationConfiguration(this.restDocumentation).operationPreprocessors()
50-
.withRequestDefaults(removeHeaders("Foo")) // <1>
50+
.withRequestDefaults(modifyHeaders().remove("Foo")) // <1>
5151
.withResponseDefaults(prettyPrint())) // <2>
5252
.build();
5353
}

docs/src/test/java/com/example/mockmvc/PerTestPreprocessing.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,10 +20,10 @@
2020

2121
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
2222
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
23+
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
2324
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
2425
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
2526
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
26-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
2727
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
2828

2929
public class PerTestPreprocessing {
@@ -33,7 +33,7 @@ public class PerTestPreprocessing {
3333
public void general() throws Exception {
3434
// tag::preprocessing[]
3535
this.mockMvc.perform(get("/")).andExpect(status().isOk())
36-
.andDo(document("index", preprocessRequest(removeHeaders("Foo")), // <1>
36+
.andDo(document("index", preprocessRequest(modifyHeaders().remove("Foo")), // <1>
3737
preprocessResponse(prettyPrint()))); // <2>
3838
// end::preprocessing[]
3939
}

docs/src/test/java/com/example/restassured/CustomDefaultOperationPreprocessors.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,8 +23,8 @@
2323

2424
import org.springframework.restdocs.JUnitRestDocumentation;
2525

26+
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
2627
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
27-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
2828
import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration;
2929

3030
public class CustomDefaultOperationPreprocessors {
@@ -40,7 +40,7 @@ public void setup() {
4040
// tag::custom-default-operation-preprocessors[]
4141
this.spec = new RequestSpecBuilder()
4242
.addFilter(documentationConfiguration(this.restDocumentation).operationPreprocessors()
43-
.withRequestDefaults(removeHeaders("Foo")) // <1>
43+
.withRequestDefaults(modifyHeaders().remove("Foo")) // <1>
4444
.withResponseDefaults(prettyPrint())) // <2>
4545
.build();
4646
// end::custom-default-operation-preprocessors[]

docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,8 +27,8 @@
2727
import static org.hamcrest.CoreMatchers.is;
2828
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
2929
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
30+
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
3031
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
31-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
3232
import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
3333
import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration;
3434

@@ -44,7 +44,7 @@ public class EveryTestPreprocessing {
4444
public void setup() {
4545
this.spec = new RequestSpecBuilder()
4646
.addFilter(documentationConfiguration(this.restDocumentation).operationPreprocessors()
47-
.withRequestDefaults(removeHeaders("Foo")) // <1>
47+
.withRequestDefaults(modifyHeaders().remove("Foo")) // <1>
4848
.withResponseDefaults(prettyPrint())) // <2>
4949
.build();
5050
}

docs/src/test/java/com/example/restassured/PerTestPreprocessing.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,10 +20,10 @@
2020
import io.restassured.specification.RequestSpecification;
2121

2222
import static org.hamcrest.CoreMatchers.is;
23+
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
2324
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
2425
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
2526
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
26-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
2727
import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
2828

2929
public class PerTestPreprocessing {
@@ -32,7 +32,7 @@ public class PerTestPreprocessing {
3232

3333
public void general() throws Exception {
3434
// tag::preprocessing[]
35-
RestAssured.given(this.spec).filter(document("index", preprocessRequest(removeHeaders("Foo")), // <1>
35+
RestAssured.given(this.spec).filter(document("index", preprocessRequest(modifyHeaders().remove("Foo")), // <1>
3636
preprocessResponse(prettyPrint()))) // <2>
3737
.when().get("/").then().assertThat().statusCode(is(200));
3838
// end::preprocessing[]

docs/src/test/java/com/example/webtestclient/CustomDefaultOperationPreprocessors.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,8 +23,8 @@
2323
import org.springframework.restdocs.JUnitRestDocumentation;
2424
import org.springframework.test.web.reactive.server.WebTestClient;
2525

26+
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
2627
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
27-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
2828
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
2929

3030
public class CustomDefaultOperationPreprocessors {
@@ -46,7 +46,7 @@ public void setup() {
4646
.configureClient()
4747
.filter(documentationConfiguration(this.restDocumentation)
4848
.operationPreprocessors()
49-
.withRequestDefaults(removeHeaders("Foo")) // <1>
49+
.withRequestDefaults(modifyHeaders().remove("Foo")) // <1>
5050
.withResponseDefaults(prettyPrint())) // <2>
5151
.build();
5252
// end::custom-default-operation-preprocessors[]

docs/src/test/java/com/example/webtestclient/EveryTestPreprocessing.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,8 +25,8 @@
2525

2626
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
2727
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
28+
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
2829
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
29-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
3030
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document;
3131
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
3232

@@ -48,7 +48,7 @@ public void setup() {
4848
.configureClient()
4949
.filter(documentationConfiguration(this.restDocumentation)
5050
.operationPreprocessors()
51-
.withRequestDefaults(removeHeaders("Foo")) // <1>
51+
.withRequestDefaults(modifyHeaders().remove("Foo")) // <1>
5252
.withResponseDefaults(prettyPrint())) // <2>
5353
.build();
5454
}

docs/src/test/java/com/example/webtestclient/PerTestPreprocessing.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,10 +18,10 @@
1818

1919
import org.springframework.test.web.reactive.server.WebTestClient;
2020

21+
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
2122
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
2223
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
2324
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
24-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
2525
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document;
2626

2727
public class PerTestPreprocessing {
@@ -34,7 +34,7 @@ public void general() {
3434
// tag::preprocessing[]
3535
this.webTestClient.get().uri("/").exchange().expectStatus().isOk().expectBody()
3636
.consumeWith(document("index",
37-
preprocessRequest(removeHeaders("Foo")), // <1>
37+
preprocessRequest(modifyHeaders().remove("Foo")), // <1>
3838
preprocessResponse(prettyPrint()))); // <2>
3939
// end::preprocessing[]
4040
}

0 commit comments

Comments
 (0)