diff --git a/build.gradle b/build.gradle index ed97a8eb..a44720bb 100644 --- a/build.gradle +++ b/build.gradle @@ -67,11 +67,8 @@ subprojects { subproject -> } } - compileJava { - options.compilerArgs = [ "-Xlint:deprecation", "-Xlint:-options", "-Werror" ] - } - tasks.withType(JavaCompile) { + options.compilerArgs = [ "-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes", "-Xlint:varargs", "-Xlint:options" ] options.encoding = "UTF-8" } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/config/RestDocumentationConfigurerTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/config/RestDocumentationConfigurerTests.java index f5f0e708..2141dee8 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/config/RestDocumentationConfigurerTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/config/RestDocumentationConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 2014-2022 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. @@ -202,7 +202,7 @@ public class RestDocumentationConfigurerTests { public void customDefaultOperationRequestPreprocessor() { Map configuration = new HashMap<>(); this.configurer.operationPreprocessors() - .withRequestDefaults(Preprocessors.prettyPrint(), Preprocessors.removeHeaders("Foo")) + .withRequestDefaults(Preprocessors.prettyPrint(), Preprocessors.modifyHeaders().remove("Foo")) .apply(configuration, createContext()); OperationRequestPreprocessor preprocessor = (OperationRequestPreprocessor) configuration .get(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_REQUEST_PREPROCESSOR); @@ -217,7 +217,7 @@ public class RestDocumentationConfigurerTests { public void customDefaultOperationResponsePreprocessor() { Map configuration = new HashMap<>(); this.configurer.operationPreprocessors() - .withResponseDefaults(Preprocessors.prettyPrint(), Preprocessors.removeHeaders("Foo")) + .withResponseDefaults(Preprocessors.prettyPrint(), Preprocessors.modifyHeaders().remove("Foo")) .apply(configuration, createContext()); OperationResponsePreprocessor preprocessor = (OperationResponsePreprocessor) configuration .get(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_RESPONSE_PREPROCESSOR); diff --git a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentationIntegrationTests.java b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentationIntegrationTests.java index ba61054b..fdd858bf 100644 --- a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentationIntegrationTests.java +++ b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentationIntegrationTests.java @@ -80,10 +80,10 @@ import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.docu 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.modifyHeaders; 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; @@ -382,7 +382,7 @@ public class MockMvcRestDocumentationIntegrationTests { .andExpect(status().isOk()).andDo(document("original-request")) .andDo(document("preprocessed-request", preprocessRequest(prettyPrint(), - removeHeaders("a", HttpHeaders.HOST, HttpHeaders.CONTENT_LENGTH), + modifyHeaders().remove("a").remove(HttpHeaders.HOST).remove(HttpHeaders.CONTENT_LENGTH), replacePattern(pattern, "\"<>\"")))) .andReturn(); HttpRequestCondition originalRequest = httpRequest(TemplateFormats.asciidoctor(), RequestMethod.GET, "/"); @@ -414,7 +414,8 @@ public class MockMvcRestDocumentationIntegrationTests { Pattern pattern = Pattern.compile("(\"alpha\")"); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context) .apply(documentationConfiguration(this.restDocumentation).operationPreprocessors().withRequestDefaults( - prettyPrint(), removeHeaders("a", HttpHeaders.HOST, HttpHeaders.CONTENT_LENGTH), + prettyPrint(), + modifyHeaders().remove("a").remove(HttpHeaders.HOST).remove(HttpHeaders.CONTENT_LENGTH), replacePattern(pattern, "\"<>\""))) .build(); @@ -445,7 +446,7 @@ public class MockMvcRestDocumentationIntegrationTests { mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) .andDo(document("original-response")) .andDo(document("preprocessed-response", preprocessResponse(prettyPrint(), maskLinks(), - removeHeaders("a"), replacePattern(pattern, "\"<>\"")))); + modifyHeaders().remove("a"), replacePattern(pattern, "\"<>\"")))); String original = "{\"a\":\"alpha\",\"links\":[{\"rel\":\"rel\"," + "\"href\":\"href\"}]}"; assertThat(new File("build/generated-snippets/original-response/http-response.adoc")) @@ -465,7 +466,8 @@ public class MockMvcRestDocumentationIntegrationTests { Pattern pattern = Pattern.compile("(\"alpha\")"); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context) .apply(documentationConfiguration(this.restDocumentation).operationPreprocessors().withResponseDefaults( - prettyPrint(), maskLinks(), removeHeaders("a"), replacePattern(pattern, "\"<>\""))) + prettyPrint(), maskLinks(), modifyHeaders().remove("a"), + replacePattern(pattern, "\"<>\""))) .build(); mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) @@ -547,7 +549,7 @@ public class MockMvcRestDocumentationIntegrationTests { } private Condition content(final Condition delegate) { - return new Condition() { + return new Condition<>() { @Override public boolean matches(File value) { diff --git a/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationConfigurerTests.java b/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationConfigurerTests.java index 0cebef3b..165294aa 100644 --- a/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationConfigurerTests.java +++ b/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationConfigurerTests.java @@ -68,7 +68,7 @@ public class RestAssuredRestDocumentationConfigurerTests { @Test public void configurationIsAddedToTheContext() { this.configurer.operationPreprocessors().withRequestDefaults(Preprocessors.prettyPrint()) - .withResponseDefaults(Preprocessors.removeHeaders("Foo")) + .withResponseDefaults(Preprocessors.modifyHeaders().remove("Foo")) .filter(this.requestSpec, this.responseSpec, this.filterContext); @SuppressWarnings("rawtypes") ArgumentCaptor configurationCaptor = ArgumentCaptor.forClass(Map.class); diff --git a/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationIntegrationTests.java b/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationIntegrationTests.java index a83a378d..3e56092d 100644 --- a/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationIntegrationTests.java +++ b/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationIntegrationTests.java @@ -54,11 +54,11 @@ 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.modifyHeaders; 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; -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; @@ -243,7 +243,7 @@ public class RestAssuredRestDocumentationIntegrationTests { public void responseWithCookie() { given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("set-cookie", - preprocessResponse(removeHeaders(HttpHeaders.DATE, HttpHeaders.CONTENT_TYPE)))) + preprocessResponse(modifyHeaders().remove(HttpHeaders.DATE).remove(HttpHeaders.CONTENT_TYPE)))) .get("/set-cookie").then().statusCode(200); assertExpectedSnippetFilesExist(new File("build/generated-snippets/set-cookie"), "http-request.adoc", "http-response.adoc", "curl-request.adoc"); @@ -261,7 +261,8 @@ public class RestAssuredRestDocumentationIntegrationTests { .body("{\"a\":\"alpha\"}").filter(document("original-request")) .filter(document("preprocessed-request", preprocessRequest(prettyPrint(), replacePattern(pattern, "\"<>\""), - modifyUris().removePort(), removeHeaders("a", HttpHeaders.CONTENT_LENGTH)))) + modifyUris().removePort(), + modifyHeaders().remove("a").remove(HttpHeaders.CONTENT_LENGTH)))) .get("/").then().statusCode(200); assertThat(new File("build/generated-snippets/original-request/http-request.adoc")) .has(content(httpRequest(TemplateFormats.asciidoctor(), RequestMethod.GET, "/").header("a", "alpha") @@ -281,7 +282,7 @@ public class RestAssuredRestDocumentationIntegrationTests { given().port(tomcat.getPort()) .filter(documentationConfiguration(this.restDocumentation).operationPreprocessors().withRequestDefaults( prettyPrint(), replacePattern(pattern, "\"<>\""), modifyUris().removePort(), - removeHeaders("a", HttpHeaders.CONTENT_LENGTH))) + modifyHeaders().remove("a").remove(HttpHeaders.CONTENT_LENGTH))) .header("a", "alpha").header("b", "bravo").contentType("application/json").accept("application/json") .body("{\"a\":\"alpha\"}").filter(document("default-preprocessed-request")).get("/").then() .statusCode(200); @@ -299,7 +300,7 @@ public class RestAssuredRestDocumentationIntegrationTests { .filter(document("original-response")) .filter(document("preprocessed-response", preprocessResponse(prettyPrint(), maskLinks(), - removeHeaders("a", "Transfer-Encoding", "Date", "Server"), + modifyHeaders().remove("a").remove("Transfer-Encoding").remove("Date").remove("Server"), replacePattern(pattern, "\"<>\""), modifyUris().scheme("https").host("api.example.com").removePort()))) .get("/").then().statusCode(200); @@ -319,7 +320,7 @@ public class RestAssuredRestDocumentationIntegrationTests { given().port(tomcat.getPort()) .filter(documentationConfiguration(this.restDocumentation).operationPreprocessors() .withResponseDefaults(prettyPrint(), maskLinks(), - removeHeaders("a", "Transfer-Encoding", "Date", "Server"), + modifyHeaders().remove("a").remove("Transfer-Encoding").remove("Date").remove("Server"), replacePattern(pattern, "\"<>\""), modifyUris().scheme("https").host("api.example.com").removePort())) .filter(document("default-preprocessed-response")).get("/").then().statusCode(200); @@ -378,7 +379,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } private Condition content(final Condition delegate) { - return new Condition() { + return new Condition<>() { @Override public boolean matches(File value) {