Skip to content

Commit ef6aa13

Browse files
committed
Merge branch '2.0.x'
Closes gh-826
2 parents fbad11e + 6ab923b commit ef6aa13

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

build.gradle

+1-4
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,8 @@ subprojects { subproject ->
6767
}
6868
}
6969

70-
compileJava {
71-
options.compilerArgs = [ "-Xlint:deprecation", "-Xlint:-options", "-Werror" ]
72-
}
73-
7470
tasks.withType(JavaCompile) {
71+
options.compilerArgs = [ "-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes", "-Xlint:varargs", "-Xlint:options" ]
7572
options.encoding = "UTF-8"
7673
}
7774

spring-restdocs-core/src/test/java/org/springframework/restdocs/config/RestDocumentationConfigurerTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2020 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.
@@ -202,7 +202,7 @@ public void asciidoctorTableCellContentLambaIsNotInstalledWhenUsingNonAsciidocto
202202
public void customDefaultOperationRequestPreprocessor() {
203203
Map<String, Object> configuration = new HashMap<>();
204204
this.configurer.operationPreprocessors()
205-
.withRequestDefaults(Preprocessors.prettyPrint(), Preprocessors.removeHeaders("Foo"))
205+
.withRequestDefaults(Preprocessors.prettyPrint(), Preprocessors.modifyHeaders().remove("Foo"))
206206
.apply(configuration, createContext());
207207
OperationRequestPreprocessor preprocessor = (OperationRequestPreprocessor) configuration
208208
.get(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_REQUEST_PREPROCESSOR);
@@ -217,7 +217,7 @@ public void customDefaultOperationRequestPreprocessor() {
217217
public void customDefaultOperationResponsePreprocessor() {
218218
Map<String, Object> configuration = new HashMap<>();
219219
this.configurer.operationPreprocessors()
220-
.withResponseDefaults(Preprocessors.prettyPrint(), Preprocessors.removeHeaders("Foo"))
220+
.withResponseDefaults(Preprocessors.prettyPrint(), Preprocessors.modifyHeaders().remove("Foo"))
221221
.apply(configuration, createContext());
222222
OperationResponsePreprocessor preprocessor = (OperationResponsePreprocessor) configuration
223223
.get(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_RESPONSE_PREPROCESSOR);

spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentationIntegrationTests.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@
8080
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
8181
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
8282
import static org.springframework.restdocs.operation.preprocess.Preprocessors.maskLinks;
83+
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
8384
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
8485
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
8586
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
86-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
8787
import static org.springframework.restdocs.operation.preprocess.Preprocessors.replacePattern;
8888
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
8989
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
@@ -382,7 +382,7 @@ public void preprocessedRequest() throws Exception {
382382
.andExpect(status().isOk()).andDo(document("original-request"))
383383
.andDo(document("preprocessed-request",
384384
preprocessRequest(prettyPrint(),
385-
removeHeaders("a", HttpHeaders.HOST, HttpHeaders.CONTENT_LENGTH),
385+
modifyHeaders().remove("a").remove(HttpHeaders.HOST).remove(HttpHeaders.CONTENT_LENGTH),
386386
replacePattern(pattern, "\"<<beta>>\""))))
387387
.andReturn();
388388
HttpRequestCondition originalRequest = httpRequest(TemplateFormats.asciidoctor(), RequestMethod.GET, "/");
@@ -414,7 +414,8 @@ public void defaultPreprocessedRequest() throws Exception {
414414
Pattern pattern = Pattern.compile("(\"alpha\")");
415415
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
416416
.apply(documentationConfiguration(this.restDocumentation).operationPreprocessors().withRequestDefaults(
417-
prettyPrint(), removeHeaders("a", HttpHeaders.HOST, HttpHeaders.CONTENT_LENGTH),
417+
prettyPrint(),
418+
modifyHeaders().remove("a").remove(HttpHeaders.HOST).remove(HttpHeaders.CONTENT_LENGTH),
418419
replacePattern(pattern, "\"<<beta>>\"")))
419420
.build();
420421

@@ -445,7 +446,7 @@ public void preprocessedResponse() throws Exception {
445446
mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
446447
.andDo(document("original-response"))
447448
.andDo(document("preprocessed-response", preprocessResponse(prettyPrint(), maskLinks(),
448-
removeHeaders("a"), replacePattern(pattern, "\"<<beta>>\""))));
449+
modifyHeaders().remove("a"), replacePattern(pattern, "\"<<beta>>\""))));
449450

450451
String original = "{\"a\":\"alpha\",\"links\":[{\"rel\":\"rel\"," + "\"href\":\"href\"}]}";
451452
assertThat(new File("build/generated-snippets/original-response/http-response.adoc"))
@@ -465,7 +466,8 @@ public void defaultPreprocessedResponse() throws Exception {
465466
Pattern pattern = Pattern.compile("(\"alpha\")");
466467
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
467468
.apply(documentationConfiguration(this.restDocumentation).operationPreprocessors().withResponseDefaults(
468-
prettyPrint(), maskLinks(), removeHeaders("a"), replacePattern(pattern, "\"<<beta>>\"")))
469+
prettyPrint(), maskLinks(), modifyHeaders().remove("a"),
470+
replacePattern(pattern, "\"<<beta>>\"")))
469471
.build();
470472

471473
mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
@@ -547,7 +549,7 @@ private void assertExpectedSnippetFilesExist(File directory, String... snippets)
547549
}
548550

549551
private Condition<File> content(final Condition<String> delegate) {
550-
return new Condition<File>() {
552+
return new Condition<>() {
551553

552554
@Override
553555
public boolean matches(File value) {

spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationConfigurerTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void nextFilterIsCalled() {
6868
@Test
6969
public void configurationIsAddedToTheContext() {
7070
this.configurer.operationPreprocessors().withRequestDefaults(Preprocessors.prettyPrint())
71-
.withResponseDefaults(Preprocessors.removeHeaders("Foo"))
71+
.withResponseDefaults(Preprocessors.modifyHeaders().remove("Foo"))
7272
.filter(this.requestSpec, this.responseSpec, this.filterContext);
7373
@SuppressWarnings("rawtypes")
7474
ArgumentCaptor<Map> configurationCaptor = ArgumentCaptor.forClass(Map.class);

spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationIntegrationTests.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@
5454
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
5555
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
5656
import static org.springframework.restdocs.operation.preprocess.Preprocessors.maskLinks;
57+
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyHeaders;
5758
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyUris;
5859
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
5960
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
6061
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
61-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
6262
import static org.springframework.restdocs.operation.preprocess.Preprocessors.replacePattern;
6363
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
6464
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
@@ -243,7 +243,7 @@ public void additionalSnippets() throws Exception {
243243
public void responseWithCookie() {
244244
given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation))
245245
.filter(document("set-cookie",
246-
preprocessResponse(removeHeaders(HttpHeaders.DATE, HttpHeaders.CONTENT_TYPE))))
246+
preprocessResponse(modifyHeaders().remove(HttpHeaders.DATE).remove(HttpHeaders.CONTENT_TYPE))))
247247
.get("/set-cookie").then().statusCode(200);
248248
assertExpectedSnippetFilesExist(new File("build/generated-snippets/set-cookie"), "http-request.adoc",
249249
"http-response.adoc", "curl-request.adoc");
@@ -261,7 +261,8 @@ public void preprocessedRequest() throws Exception {
261261
.body("{\"a\":\"alpha\"}").filter(document("original-request"))
262262
.filter(document("preprocessed-request",
263263
preprocessRequest(prettyPrint(), replacePattern(pattern, "\"<<beta>>\""),
264-
modifyUris().removePort(), removeHeaders("a", HttpHeaders.CONTENT_LENGTH))))
264+
modifyUris().removePort(),
265+
modifyHeaders().remove("a").remove(HttpHeaders.CONTENT_LENGTH))))
265266
.get("/").then().statusCode(200);
266267
assertThat(new File("build/generated-snippets/original-request/http-request.adoc"))
267268
.has(content(httpRequest(TemplateFormats.asciidoctor(), RequestMethod.GET, "/").header("a", "alpha")
@@ -281,7 +282,7 @@ public void defaultPreprocessedRequest() throws Exception {
281282
given().port(tomcat.getPort())
282283
.filter(documentationConfiguration(this.restDocumentation).operationPreprocessors().withRequestDefaults(
283284
prettyPrint(), replacePattern(pattern, "\"<<beta>>\""), modifyUris().removePort(),
284-
removeHeaders("a", HttpHeaders.CONTENT_LENGTH)))
285+
modifyHeaders().remove("a").remove(HttpHeaders.CONTENT_LENGTH)))
285286
.header("a", "alpha").header("b", "bravo").contentType("application/json").accept("application/json")
286287
.body("{\"a\":\"alpha\"}").filter(document("default-preprocessed-request")).get("/").then()
287288
.statusCode(200);
@@ -299,7 +300,7 @@ public void preprocessedResponse() throws Exception {
299300
.filter(document("original-response"))
300301
.filter(document("preprocessed-response",
301302
preprocessResponse(prettyPrint(), maskLinks(),
302-
removeHeaders("a", "Transfer-Encoding", "Date", "Server"),
303+
modifyHeaders().remove("a").remove("Transfer-Encoding").remove("Date").remove("Server"),
303304
replacePattern(pattern, "\"<<beta>>\""),
304305
modifyUris().scheme("https").host("api.example.com").removePort())))
305306
.get("/").then().statusCode(200);
@@ -319,7 +320,7 @@ public void defaultPreprocessedResponse() throws Exception {
319320
given().port(tomcat.getPort())
320321
.filter(documentationConfiguration(this.restDocumentation).operationPreprocessors()
321322
.withResponseDefaults(prettyPrint(), maskLinks(),
322-
removeHeaders("a", "Transfer-Encoding", "Date", "Server"),
323+
modifyHeaders().remove("a").remove("Transfer-Encoding").remove("Date").remove("Server"),
323324
replacePattern(pattern, "\"<<beta>>\""),
324325
modifyUris().scheme("https").host("api.example.com").removePort()))
325326
.filter(document("default-preprocessed-response")).get("/").then().statusCode(200);
@@ -378,7 +379,7 @@ private void assertExpectedSnippetFilesExist(File directory, String... snippets)
378379
}
379380

380381
private Condition<File> content(final Condition<String> delegate) {
381-
return new Condition<File>() {
382+
return new Condition<>() {
382383

383384
@Override
384385
public boolean matches(File value) {

0 commit comments

Comments
 (0)