From 244a734232dd85c28f05740ad3fe5c278b939792 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 8 Aug 2018 14:08:15 +0100 Subject: [PATCH] Adopt Spring Java Format for code formatting and style --- build.gradle | 6 +- config/checkstyle/checkstyle-header.txt | 17 -- .../checkstyle/checkstyle-import-control.xml | 12 - config/checkstyle/checkstyle-suppressions.xml | 8 - config/checkstyle/checkstyle.xml | 159 +----------- gradle.properties | 3 +- .../restdocs/JUnitRestDocumentation.java | 1 - .../restdocs/ManualRestDocumentation.java | 2 - .../restdocs/RestDocumentation.java | 1 - .../restdocs/RestDocumentationContext.java | 14 +- .../RestDocumentationContextProvider.java | 1 - .../restdocs/cli/CliDocumentation.java | 14 +- .../restdocs/cli/CliOperationRequest.java | 3 +- .../restdocs/cli/CommandFormatter.java | 7 +- .../cli/ConcatenatingCommandFormatter.java | 7 +- .../restdocs/cli/CurlRequestSnippet.java | 13 +- .../restdocs/cli/HttpieRequestSnippet.java | 14 +- .../restdocs/config/AbstractConfigurer.java | 1 - .../config/AbstractNestedConfigurer.java | 4 +- .../restdocs/config/NestedConfigurer.java | 5 +- .../config/RestDocumentationConfigurer.java | 12 +- .../restdocs/config/SnippetConfigurer.java | 11 +- .../restdocs/constraints/Constraint.java | 3 - .../ConstraintDescriptionResolver.java | 3 +- .../constraints/ConstraintDescriptions.java | 6 +- .../constraints/ConstraintResolver.java | 1 - ...ceBundleConstraintDescriptionResolver.java | 5 +- .../ValidatorConstraintResolver.java | 3 +- .../restdocs/curl/CurlDocumentation.java | 4 - .../restdocs/curl/CurlRequestSnippet.java | 10 +- .../restdocs/curl/package-info.java | 1 - .../RestDocumentationGenerationException.java | 2 - .../generate/RestDocumentationGenerator.java | 9 +- .../headers/AbstractHeadersSnippet.java | 5 - .../restdocs/headers/HeaderDescriptor.java | 3 - .../restdocs/headers/HeaderDocumentation.java | 11 +- .../headers/RequestHeadersSnippet.java | 2 - .../headers/ResponseHeadersSnippet.java | 2 - .../restdocs/http/HttpDocumentation.java | 4 - .../restdocs/http/HttpRequestSnippet.java | 5 +- .../restdocs/http/HttpResponseSnippet.java | 5 +- .../hypermedia/AtomLinkExtractor.java | 4 +- .../restdocs/hypermedia/HalLinkExtractor.java | 2 +- .../hypermedia/HypermediaDocumentation.java | 27 +- .../restdocs/hypermedia/Link.java | 32 ++- .../restdocs/hypermedia/LinkDescriptor.java | 4 - .../restdocs/hypermedia/LinkExtractor.java | 5 +- .../restdocs/hypermedia/LinksSnippet.java | 6 - .../operation/AbstractOperationMessage.java | 6 +- .../operation/ConversionException.java | 2 - .../restdocs/operation/Operation.java | 4 - .../restdocs/operation/OperationRequest.java | 10 +- .../operation/OperationRequestFactory.java | 28 +-- .../operation/OperationRequestPart.java | 5 - .../OperationRequestPartFactory.java | 1 - .../restdocs/operation/OperationResponse.java | 4 - .../operation/OperationResponseFactory.java | 19 +- .../restdocs/operation/Parameters.java | 2 - .../restdocs/operation/QueryStringParser.java | 1 - .../restdocs/operation/RequestConverter.java | 5 +- .../restdocs/operation/RequestCookie.java | 5 +- .../restdocs/operation/ResponseConverter.java | 5 +- .../restdocs/operation/StandardOperation.java | 1 - .../operation/StandardOperationRequest.java | 3 +- .../StandardOperationRequestPart.java | 1 - .../operation/StandardOperationResponse.java | 1 - .../operation/preprocess/ContentModifier.java | 1 - ...ContentModifyingOperationPreprocessor.java | 1 - ...elegatingOperationRequestPreprocessor.java | 1 - ...legatingOperationResponsePreprocessor.java | 1 - .../operation/preprocess/HeaderFilter.java | 1 - .../preprocess/OperationPreprocessor.java | 2 - .../OperationPreprocessorAdapter.java | 2 - .../OperationRequestPreprocessor.java | 1 - .../OperationResponsePreprocessor.java | 1 - ...ametersModifyingOperationPreprocessor.java | 4 - .../PatternReplacingContentModifier.java | 1 - .../operation/preprocess/Preprocessors.java | 9 - .../restdocs/payload/AbstractBodySnippet.java | 18 +- .../payload/AbstractFieldsSnippet.java | 23 +- .../restdocs/payload/ContentHandler.java | 3 - .../restdocs/payload/FieldDescriptor.java | 7 +- .../payload/FieldDoesNotExistException.java | 3 +- .../FieldPathPayloadSubsectionExtractor.java | 5 +- .../payload/FieldTypeRequiredException.java | 3 +- .../FieldTypesDoNotMatchException.java | 1 - .../restdocs/payload/JsonFieldProcessor.java | 6 +- .../payload/PayloadDocumentation.java | 72 +----- .../payload/PayloadHandlingException.java | 2 - .../payload/PayloadSubsectionExtractor.java | 7 +- .../restdocs/payload/RequestBodySnippet.java | 9 +- .../payload/RequestFieldsSnippet.java | 12 - .../payload/RequestPartBodySnippet.java | 8 +- .../payload/RequestPartFieldsSnippet.java | 12 - .../restdocs/payload/ResponseBodySnippet.java | 9 +- .../payload/ResponseFieldsSnippet.java | 12 - .../request/AbstractParametersSnippet.java | 19 +- .../restdocs/request/ParameterDescriptor.java | 4 - .../request/PathParametersSnippet.java | 8 +- .../request/RequestDocumentation.java | 46 +--- .../request/RequestParametersSnippet.java | 4 - .../request/RequestPartDescriptor.java | 4 - .../restdocs/request/RequestPartsSnippet.java | 4 - .../restdocs/snippet/AbstractDescriptor.java | 4 - .../restdocs/snippet/Attributes.java | 20 +- .../restdocs/snippet/IgnorableDescriptor.java | 2 - .../snippet/ModelCreationException.java | 2 - .../snippet/PlaceholderResolverFactory.java | 1 - ...cumentationContextPlaceholderResolver.java | 4 - .../restdocs/snippet/Snippet.java | 1 - .../restdocs/snippet/SnippetException.java | 1 - .../snippet/StandardWriterResolver.java | 2 - .../restdocs/snippet/TemplatedSnippet.java | 19 +- .../restdocs/snippet/WriterResolver.java | 2 - .../StandardTemplateResourceResolver.java | 2 - .../restdocs/templates/Template.java | 7 +- .../restdocs/templates/TemplateEngine.java | 1 - .../restdocs/templates/TemplateFormat.java | 2 - .../restdocs/templates/TemplateFormats.java | 2 - .../templates/TemplateResourceResolver.java | 1 - .../templates/mustache/MustacheTemplate.java | 10 +- .../mustache/MustacheTemplateEngine.java | 5 - .../restdocs/AbstractSnippetTests.java | 11 +- ...dleConstraintDescriptionResolverTests.java | 1 + .../RequestHeadersSnippetFailureTests.java | 7 +- .../ResponseHeadersSnippetFailureTests.java | 7 +- .../hypermedia/LinksSnippetFailureTests.java | 5 +- .../AsciidoctorRequestFieldsSnippetTests.java | 21 +- .../ResponseFieldsSnippetFailureTests.java | 5 +- .../PathParametersSnippetFailureTests.java | 5 +- .../RequestParametersSnippetFailureTests.java | 7 +- .../RequestPartsSnippetFailureTests.java | 7 +- .../snippet/StandardWriterResolverTests.java | 4 +- ...StandardTemplateResourceResolverTests.java | 3 +- .../restdocs/test/OperationBuilder.java | 8 +- .../restdocs/test/OutputCapture.java | 1 - .../restdocs/test/SnippetConditions.java | 18 +- .../restdocs/mockmvc/IterableEnumeration.java | 7 +- .../mockmvc/MockMvcRequestConverter.java | 12 +- .../mockmvc/MockMvcRestDocumentation.java | 6 - .../MockMvcRestDocumentationConfigurer.java | 3 +- .../RestDocumentationRequestBuilders.java | 17 -- .../RestDocumentationResultHandler.java | 5 +- .../restdocs/mockmvc/UriConfigurer.java | 11 +- ...kMvcRestDocumentationIntegrationTests.java | 113 +++++---- .../RestAssuredRequestConverter.java | 6 +- .../RestAssuredRestDocumentation.java | 7 +- .../restassured/RestDocumentationFilter.java | 5 +- .../preprocess/RestAssuredPreprocessors.java | 3 +- .../UriModifyingOperationPreprocessor.java | 8 +- .../RestAssuredRequestConverter.java | 6 +- .../RestAssuredRestDocumentation.java | 7 +- .../restassured3/RestDocumentationFilter.java | 5 +- .../preprocess/RestAssuredPreprocessors.java | 3 +- .../UriModifyingOperationPreprocessor.java | 8 +- ...uredRestDocumentationIntegrationTests.java | 237 +++++++++++------- ...uredRestDocumentationIntegrationTests.java | 75 ++++-- 157 files changed, 531 insertions(+), 1119 deletions(-) delete mode 100644 config/checkstyle/checkstyle-header.txt delete mode 100644 config/checkstyle/checkstyle-import-control.xml delete mode 100644 config/checkstyle/checkstyle-suppressions.xml diff --git a/build.gradle b/build.gradle index 41b4cadd..73b6be36 100644 --- a/build.gradle +++ b/build.gradle @@ -3,11 +3,13 @@ buildscript { mavenCentral() maven { url 'https://repo.spring.io/plugins-release' } maven { url 'https://plugins.gradle.org/m2/' } + mavenLocal() } dependencies { classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7' classpath 'io.spring.gradle:spring-io-plugin:0.0.8.RELEASE' classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2' + classpath "io.spring.javaformat:spring-javaformat-gradle-plugin:$javaFormatVersion" } } @@ -15,6 +17,7 @@ allprojects { group = 'org.springframework.restdocs' repositories { mavenCentral() + mavenLocal() } } @@ -103,7 +106,7 @@ subprojects { } configure(subprojects - project(":docs")) { subproject -> - + apply plugin: 'io.spring.javaformat' apply plugin: 'checkstyle' apply from: "${rootProject.projectDir}/gradle/publish-maven.gradle" @@ -134,6 +137,7 @@ configure(subprojects - project(":docs")) { subproject -> } dependencies { + checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:$javaFormatVersion" jacoco 'org.jacoco:org.jacoco.agent::runtime' } diff --git a/config/checkstyle/checkstyle-header.txt b/config/checkstyle/checkstyle-header.txt deleted file mode 100644 index 154aaa1a..00000000 --- a/config/checkstyle/checkstyle-header.txt +++ /dev/null @@ -1,17 +0,0 @@ -^\Q/*\E$ -^\Q * Copyright \E20\d\d\-20\d\d\Q the original author or authors.\E$ -^\Q *\E$ -^\Q * Licensed under the Apache License, Version 2.0 (the "License");\E$ -^\Q * you may not use this file except in compliance with the License.\E$ -^\Q * You may obtain a copy of the License at\E$ -^\Q *\E$ -^\Q * http://www.apache.org/licenses/LICENSE-2.0\E$ -^\Q *\E$ -^\Q * Unless required by applicable law or agreed to in writing, software\E$ -^\Q * distributed under the License is distributed on an "AS IS" BASIS,\E$ -^\Q * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\E$ -^\Q * See the License for the specific language governing permissions and\E$ -^\Q * limitations under the License.\E$ -^\Q */\E$ -^$ -^.*$ diff --git a/config/checkstyle/checkstyle-import-control.xml b/config/checkstyle/checkstyle-import-control.xml deleted file mode 100644 index af08f1a2..00000000 --- a/config/checkstyle/checkstyle-import-control.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/config/checkstyle/checkstyle-suppressions.xml b/config/checkstyle/checkstyle-suppressions.xml deleted file mode 100644 index f74d9234..00000000 --- a/config/checkstyle/checkstyle-suppressions.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index c264942e..5f9503d2 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -1,156 +1,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index a3a52bc2..6266034c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,3 @@ +javaFormatVersion=0.0.7-SNAPSHOT version=1.2.6.BUILD-SNAPSHOT -org.gradle.daemon=false +org.gradle.daemon=false \ No newline at end of file diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/JUnitRestDocumentation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/JUnitRestDocumentation.java index 8825137e..464a91f5 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/JUnitRestDocumentation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/JUnitRestDocumentation.java @@ -43,7 +43,6 @@ public class JUnitRestDocumentation /** * Creates a new {@code JUnitRestDocumentation} instance that will generate snippets * to the given {@code outputDirectory}. - * * @param outputDirectory the output directory */ public JUnitRestDocumentation(String outputDirectory) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/ManualRestDocumentation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/ManualRestDocumentation.java index 472832ff..e658d16b 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/ManualRestDocumentation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/ManualRestDocumentation.java @@ -46,7 +46,6 @@ public final class ManualRestDocumentation implements RestDocumentationContextPr /** * Creates a new {@code ManualRestDocumentation} instance that will generate snippets * to the given {@code outputDirectory}. - * * @param outputDirectory the output directory */ public ManualRestDocumentation(String outputDirectory) { @@ -62,7 +61,6 @@ public final class ManualRestDocumentation implements RestDocumentationContextPr * {@link RestDocumentationContext} for the test on the given {@code testClass} with * the given {@code testMethodName}. Must be followed by a call to * {@link #afterTest()} once the test has completed. - * * @param testClass the test class * @param testMethodName the name of the test method * @throws IllegalStateException if a context has already be created diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentation.java index 6018ed69..91af48da 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentation.java @@ -43,7 +43,6 @@ public class RestDocumentation implements TestRule, RestDocumentationContextProv /** * Creates a new {@code RestDocumentation} instance that will generate snippets to the * given {@code outputDirectory}. - * * @param outputDirectory the output directory */ public RestDocumentation(String outputDirectory) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationContext.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationContext.java index d76fc220..d7d1e9d5 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationContext.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationContext.java @@ -39,7 +39,6 @@ public final class RestDocumentationContext { * Creates a new {@code RestDocumentationContext} for a test on the given * {@code testClass} with given {@code testMethodName} that will generate * documentation to the given {@code outputDirectory}. - * * @param testClass the class whose test is being executed * @param testMethodName the name of the test method that is being executed * @param outputDirectory the directory to which documentation should be written. @@ -55,8 +54,7 @@ public final class RestDocumentationContext { /** * Returns the class whose tests are currently executing. - * - * @return The test class + * @return the test class */ public Class getTestClass() { return this.testClass; @@ -64,8 +62,7 @@ public final class RestDocumentationContext { /** * Returns the name of the test method that is currently executing. - * - * @return The name of the test method + * @return the name of the test method */ public String getTestMethodName() { return this.testMethodName; @@ -73,8 +70,7 @@ public final class RestDocumentationContext { /** * Returns the current step count and then increments it. - * - * @return The step count prior to it being incremented + * @return the step count prior to it being incremented */ int getAndIncrementStepCount() { return this.stepCount.getAndIncrement(); @@ -82,8 +78,7 @@ public final class RestDocumentationContext { /** * Returns the current step count. - * - * @return The current step count + * @return the current step count */ public int getStepCount() { return this.stepCount.get(); @@ -91,7 +86,6 @@ public final class RestDocumentationContext { /** * Returns the output directory to which generated snippets should be written. - * * @return the output directory */ public File getOutputDirectory() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationContextProvider.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationContextProvider.java index e2a94aa5..e12cd4ba 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationContextProvider.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationContextProvider.java @@ -28,7 +28,6 @@ public interface RestDocumentationContextProvider { /** * Returns a {@link RestDocumentationContext} for the operation that is about to be * performed. - * * @return the context for the operation */ RestDocumentationContext beforeOperation(); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliDocumentation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliDocumentation.java index 4f44f964..8d62c32b 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliDocumentation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliDocumentation.java @@ -41,7 +41,6 @@ public abstract class CliDocumentation { /** * Returns a new {@code Snippet} that will document the curl request for the API * operation. - * * @return the snippet that will document the curl request */ public static Snippet curlRequest() { @@ -52,7 +51,6 @@ public abstract class CliDocumentation { * Returns a new {@code Snippet} that will document the curl request for the API * operation. The given {@code attributes} will be available during snippet * generation. - * * @param attributes the attributes * @return the snippet that will document the curl request */ @@ -64,7 +62,6 @@ public abstract class CliDocumentation { * Returns a new {@code Snippet} that will document the curl request for the API * operation. The given {@code commandFormatter} will be used to format the curl * command in the snippet. - * * @param commandFormatter the command formatter * @return the snippet that will document the curl request * @since 1.2.0 @@ -78,7 +75,6 @@ public abstract class CliDocumentation { * operation. The given {@code attributes} will be available during snippet * generation. The given {@code commandFormatter} will be used to format the curl * command in the snippet. - * * @param attributes the attributes * @param commandFormatter the command formatter * @return the snippet that will document the curl request @@ -92,7 +88,6 @@ public abstract class CliDocumentation { /** * Returns a new {@code Snippet} that will document the HTTPie request for the API * operation. - * * @return the snippet that will document the HTTPie request */ public static Snippet httpieRequest() { @@ -103,7 +98,6 @@ public abstract class CliDocumentation { * Returns a new {@code Snippet} that will document the HTTPie request for the API * operation. The given {@code attributes} will be available during snippet * generation. - * * @param attributes the attributes * @return the snippet that will document the HTTPie request */ @@ -115,7 +109,6 @@ public abstract class CliDocumentation { * Returns a new {@code Snippet} that will document the HTTPie request for the API * operation. The given {@code commandFormatter} will be used to format the HTTPie * command in the snippet. - * * @param commandFormatter the command formatter * @return the snippet that will document the HTTPie request * @since 1.2.0 @@ -129,7 +122,6 @@ public abstract class CliDocumentation { * operation. The given {@code attributes} will be available during snippet * generation. The given {@code commandFormatter} will be used to format the HTTPie * command in the snippet snippet. - * * @param attributes the attributes * @param commandFormatter the command formatter * @return the snippet that will document the HTTPie request @@ -142,8 +134,7 @@ public abstract class CliDocumentation { /** * Creates a new {@code CommandFormatter} that produces multi-line output. - * - * @return A multi-line {@code CommandFormatter} + * @return a multi-line {@code CommandFormatter} */ public static CommandFormatter multiLineFormat() { return new ConcatenatingCommandFormatter(" \\%n "); @@ -151,8 +142,7 @@ public abstract class CliDocumentation { /** * Creates a new {@code CommandFormatter} that produces single-line output. - * - * @return A single-line {@code CommandFormatter} + * @return a single-line {@code CommandFormatter} */ public static CommandFormatter singleLineFormat() { return new ConcatenatingCommandFormatter(" "); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliOperationRequest.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliOperationRequest.java index e3fb116b..6c57edae 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliOperationRequest.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliOperationRequest.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. @@ -133,6 +133,7 @@ final class CliOperationRequest implements OperationRequest { private interface HeaderFilter { boolean allow(String name, List value); + } private static final class BasicAuthHeaderFilter implements HeaderFilter { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CommandFormatter.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CommandFormatter.java index da6d43ce..5d591eda 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CommandFormatter.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CommandFormatter.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. @@ -29,9 +29,8 @@ public interface CommandFormatter { /** * Formats a list of {@code elements} into a single {@code String}. - * - * @param elements The {@code String} elements to be formatted - * @return A single formatted {@code String} + * @param elements the {@code String} elements to be formatted + * @return a single formatted {@code String} */ String format(List elements); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/ConcatenatingCommandFormatter.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/ConcatenatingCommandFormatter.java index 69523f87..7a9cd0a6 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/ConcatenatingCommandFormatter.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/ConcatenatingCommandFormatter.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. @@ -35,9 +35,8 @@ final class ConcatenatingCommandFormatter implements CommandFormatter { /** * Concatenates a list of {@code String}s with a specified separator. - * - * @param elements A list of {@code String}s to be concatenated - * @return Concatenated list of {@code String}s as one {@code String} + * @param elements a list of {@code String}s to be concatenated + * @return concatenated list of {@code String}s as one {@code String} */ @Override public String format(List elements) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CurlRequestSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CurlRequestSnippet.java index 056b7194..861fb643 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CurlRequestSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CurlRequestSnippet.java @@ -45,7 +45,6 @@ import org.springframework.util.StringUtils; * @see CliDocumentation#curlRequest() * @see CliDocumentation#curlRequest(CommandFormatter) * @see CliDocumentation#curlRequest(Map) - * @see CliDocumentation#curlRequest(Map, CommandFormatter) */ public class CurlRequestSnippet extends TemplatedSnippet { @@ -53,7 +52,6 @@ public class CurlRequestSnippet extends TemplatedSnippet { /** * Creates a new {@code CurlRequestSnippet} with no additional attributes. - * * @deprecated since 1.2.0 in favor of {@link #CurlRequestSnippet(CommandFormatter)} */ @Deprecated @@ -64,8 +62,7 @@ public class CurlRequestSnippet extends TemplatedSnippet { /** * Creates a new {@code CurlRequestSnippet} that will use the given * {@code commandFormatter} to format the curl command. - * - * @param commandFormatter The formatter + * @param commandFormatter the formatter */ protected CurlRequestSnippet(CommandFormatter commandFormatter) { this(null, commandFormatter); @@ -74,8 +71,7 @@ public class CurlRequestSnippet extends TemplatedSnippet { /** * Creates a new {@code CurlRequestSnippet} with the given additional * {@code attributes} that will be included in the model during template rendering. - * - * @param attributes The additional attributes + * @param attributes the additional attributes * @deprecated since 1.2.0 in favor of * {@link #CurlRequestSnippet(Map, CommandFormatter)} */ @@ -88,9 +84,8 @@ public class CurlRequestSnippet extends TemplatedSnippet { * Creates a new {@code CurlRequestSnippet} with the given additional * {@code attributes} that will be included in the model during template rendering. * The given {@code commandFormaatter} will be used to format the curl command. - * - * @param attributes The additional attributes - * @param commandFormatter The formatter for generating the snippet + * @param attributes the additional attributes + * @param commandFormatter the formatter for generating the snippet */ protected CurlRequestSnippet(Map attributes, CommandFormatter commandFormatter) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/HttpieRequestSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/HttpieRequestSnippet.java index 7cb346a2..e3f65365 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/HttpieRequestSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/HttpieRequestSnippet.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. @@ -53,7 +53,6 @@ public class HttpieRequestSnippet extends TemplatedSnippet { /** * Creates a new {@code HttpieRequestSnippet} with no additional attributes. - * * @deprecated since 1.2.0 in favor of {@link #HttpieRequestSnippet(CommandFormatter)} */ @Deprecated @@ -64,8 +63,7 @@ public class HttpieRequestSnippet extends TemplatedSnippet { /** * Creates a new {@code HttpieRequestSnippet} that will use the given * {@code commandFormatter} to format the HTTPie command. - * - * @param commandFormatter The formatter + * @param commandFormatter the formatter */ protected HttpieRequestSnippet(CommandFormatter commandFormatter) { this(null, commandFormatter); @@ -74,8 +72,7 @@ public class HttpieRequestSnippet extends TemplatedSnippet { /** * Creates a new {@code HttpieRequestSnippet} with the given additional * {@code attributes} that will be included in the model during template rendering. - * - * @param attributes The additional attributes + * @param attributes the additional attributes * @deprecated since 1.2.0 in favor of * {@link #HttpieRequestSnippet(Map, CommandFormatter)} */ @@ -88,9 +85,8 @@ public class HttpieRequestSnippet extends TemplatedSnippet { * Creates a new {@code HttpieRequestSnippet} with the given additional * {@code attributes} that will be included in the model during template rendering. * The given {@code commandFormaatter} will be used to format the HTTPie command. - * - * @param attributes The additional attributes - * @param commandFormatter The formatter for generating the snippet + * @param attributes the additional attributes + * @param commandFormatter the formatter for generating the snippet */ protected HttpieRequestSnippet(Map attributes, CommandFormatter commandFormatter) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/AbstractConfigurer.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/AbstractConfigurer.java index fd46b376..db02a9c8 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/AbstractConfigurer.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/AbstractConfigurer.java @@ -31,7 +31,6 @@ public abstract class AbstractConfigurer { /** * Applies the configurer to the given {@code configuration}. - * * @param configuration the configuration to be configured * @param context the current documentation context */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/AbstractNestedConfigurer.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/AbstractNestedConfigurer.java index 0af74d65..becabbe2 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/AbstractNestedConfigurer.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/AbstractNestedConfigurer.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. @@ -19,7 +19,7 @@ package org.springframework.restdocs.config; /** * Base class for {@link NestedConfigurer} implementations. * - * @param The type of the configurer's parent + * @param the type of the configurer's parent * @author Andy Wilkinson * @since 1.1.0 */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/NestedConfigurer.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/NestedConfigurer.java index 0e91e33c..18aa2410 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/NestedConfigurer.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/NestedConfigurer.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,7 +19,7 @@ package org.springframework.restdocs.config; /** * A configurer that is nested and, therefore, has a parent. * - * @param The parent's type + * @param the parent's type * @author Andy Wilkinson * @since 1.1.0 */ @@ -27,7 +27,6 @@ interface NestedConfigurer { /** * Returns the configurer's parent. - * * @return the parent */ PARENT and(); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/RestDocumentationConfigurer.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/RestDocumentationConfigurer.java index 59444e65..d97227b0 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/RestDocumentationConfigurer.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/config/RestDocumentationConfigurer.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. @@ -35,8 +35,8 @@ import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; /** * Abstract base class for the configuration of Spring REST Docs. * - * @param The concrete type of the {@link SnippetConfigurer}. - * @param The concrete type of this configurer, to be returned from methods that + * @param the concrete type of the {@link SnippetConfigurer}. + * @param the concrete type of this configurer, to be returned from methods that * support chaining * @author Andy Wilkinson * @since 1.1.0 @@ -50,14 +50,12 @@ public abstract class RestDocumentationConfigurer The type of the configurer's parent - * @param The concrete type of the configurer to be returned from chained methods + * @param the type of the configurer's parent + * @param the concrete type of the configurer to be returned from chained methods * @author Andy Wilkinson * @since 1.1.0 */ @@ -67,7 +67,6 @@ public abstract class SnippetConfigurer /** * Creates a new {@code SnippetConfigurer} with the given {@code parent}. - * * @param parent the parent */ protected SnippetConfigurer(PARENT parent) { @@ -86,7 +85,6 @@ public abstract class SnippetConfigurer /** * Configures any documentation snippets to be written using the given * {@code encoding}. The default is UTF-8. - * * @param encoding the encoding * @return {@code this} */ @@ -98,7 +96,6 @@ public abstract class SnippetConfigurer /** * Configures the documentation snippets that will be produced by default. - * * @param defaultSnippets the default snippets * @return {@code this} * @see #withAdditionalDefaults(Snippet...) @@ -111,7 +108,6 @@ public abstract class SnippetConfigurer /** * Configures additional documentation snippets that will be produced by default. - * * @param additionalDefaultSnippets the additional default snippets * @return {@code this} * @see #withDefaults(Snippet...) @@ -124,7 +120,6 @@ public abstract class SnippetConfigurer /** * Configures the format of the documentation snippet templates. - * * @param format the snippet template format * @return {@code this} */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/Constraint.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/Constraint.java index 31a3fd51..ebba7a88 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/Constraint.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/Constraint.java @@ -32,7 +32,6 @@ public class Constraint { /** * Creates a new {@code Constraint} with the given {@code name} and * {@code configuration}. - * * @param name the name * @param configuration the configuration */ @@ -43,7 +42,6 @@ public class Constraint { /** * Returns the name of the constraint. - * * @return the name */ public String getName() { @@ -52,7 +50,6 @@ public class Constraint { /** * Returns the configuration of the constraint. - * * @return the configuration */ public Map getConfiguration() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintDescriptionResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintDescriptionResolver.java index 6122ced7..706d85bd 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintDescriptionResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintDescriptionResolver.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. @@ -25,7 +25,6 @@ public interface ConstraintDescriptionResolver { /** * Resolves the description for the given {@code constraint}. - * * @param constraint the constraint * @return the description */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintDescriptions.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintDescriptions.java index c5585798..18322838 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintDescriptions.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintDescriptions.java @@ -38,7 +38,6 @@ public class ConstraintDescriptions { * Constraints will be resolved using a {@link ValidatorConstraintResolver} and * descriptions will be resolved using a * {@link ResourceBundleConstraintDescriptionResolver}. - * * @param clazz the class */ public ConstraintDescriptions(Class clazz) { @@ -51,7 +50,6 @@ public class ConstraintDescriptions { * Constraints will be resolved using the given {@code constraintResolver} and * descriptions will be resolved using a * {@link ResourceBundleConstraintDescriptionResolver}. - * * @param clazz the class * @param constraintResolver the constraint resolver */ @@ -64,7 +62,6 @@ public class ConstraintDescriptions { * Create a new {@code ConstraintDescriptions} for the given {@code clazz}. * Constraints will be resolved using a {@link ValidatorConstraintResolver} and * descriptions will be resolved using the given {@code descriptionResolver}. - * * @param clazz the class * @param descriptionResolver the description resolver */ @@ -77,7 +74,6 @@ public class ConstraintDescriptions { * Create a new {@code ConstraintDescriptions} for the given {@code clazz}. * Constraints will be resolved using the given {@code constraintResolver} and * descriptions will be resolved using the given {@code descriptionResolver}. - * * @param clazz the class * @param constraintResolver the constraint resolver * @param descriptionResolver the description resolver @@ -91,7 +87,6 @@ public class ConstraintDescriptions { /** * Returns a list of the descriptions for the constraints on the given property. - * * @param property the property * @return the list of constraint descriptions */ @@ -105,4 +100,5 @@ public class ConstraintDescriptions { Collections.sort(descriptions); return descriptions; } + } diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintResolver.java index ed5ce37a..9a7490da 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintResolver.java @@ -28,7 +28,6 @@ public interface ConstraintResolver { /** * Resolves and returns the constraints for the given {@code property} on the given * {@code clazz}. If there are no constraints, an empty list is returned. - * * @param property the property * @param clazz the class * @return the list of constraints, never {@code null} diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ResourceBundleConstraintDescriptionResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ResourceBundleConstraintDescriptionResolver.java index c55596c3..12d97d13 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ResourceBundleConstraintDescriptionResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ResourceBundleConstraintDescriptionResolver.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. @@ -118,7 +118,6 @@ public class ResourceBundleConstraintDescriptionResolver /** * Creates a new {@code ResourceBundleConstraintDescriptionResolver} that will resolve * descriptions by looking them up in the given {@code resourceBundle}. - * * @param resourceBundle the resource bundle */ public ResourceBundleConstraintDescriptionResolver(ResourceBundle resourceBundle) { @@ -169,7 +168,7 @@ public class ResourceBundleConstraintDescriptionResolver @Override public String resolvePlaceholder(String placeholderName) { Object replacement = this.constraint.getConfiguration().get(placeholderName); - return replacement != null ? replacement.toString() : null; + return (replacement != null) ? replacement.toString() : null; } } diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ValidatorConstraintResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ValidatorConstraintResolver.java index d5ced6c5..61051685 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ValidatorConstraintResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ValidatorConstraintResolver.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. @@ -54,7 +54,6 @@ public class ValidatorConstraintResolver implements ConstraintResolver { /** * Creates a new {@code ValidatorConstraintResolver} that will use the given * {@code Validator} to resolve constraints. - * * @param validator the validator */ public ValidatorConstraintResolver(Validator validator) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/CurlDocumentation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/CurlDocumentation.java index 123c7a66..8b4e2070 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/CurlDocumentation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/CurlDocumentation.java @@ -41,9 +41,7 @@ public abstract class CurlDocumentation { /** * Returns a new {@code Snippet} that will document the curl request for the API * operation. - * * @return the snippet that will document the curl request - * * @deprecated Since 1.1 in favor of * {@link org.springframework.restdocs.cli.CliDocumentation#curlRequest()}. */ @@ -56,10 +54,8 @@ public abstract class CurlDocumentation { * Returns a new {@code Snippet} that will document the curl request for the API * operation. The given {@code attributes} will be available during snippet * generation. - * * @param attributes the attributes * @return the snippet that will document the curl request - * * @deprecated Since 1.1 in favor of * {@link org.springframework.restdocs.cli.CliDocumentation#curlRequest(Map)}. */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/CurlRequestSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/CurlRequestSnippet.java index 18148392..33285066 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/CurlRequestSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/CurlRequestSnippet.java @@ -26,7 +26,7 @@ import org.springframework.restdocs.snippet.Snippet; * @author Andy Wilkinson * @author Paul-Christian Volkmer * @author Raman Gupta - * @deprecated Since 1.1 in favor of + * @deprecated since 1.1 in favor of * {@link org.springframework.restdocs.cli.CurlRequestSnippet}. */ @Deprecated @@ -35,8 +35,7 @@ public class CurlRequestSnippet /** * Creates a new {@code CurlRequestSnippet} with no additional attributes. - * - * @deprecated Since 1.1 in favor of + * @deprecated since 1.1 in favor of * {@link org.springframework.restdocs.cli.CurlRequestSnippet}. */ @Deprecated @@ -46,9 +45,8 @@ public class CurlRequestSnippet /** * Creates a new {@code CurlRequestSnippet} with additional attributes. - * @param attributes The additional attributes. - * - * @deprecated Since 1.1 in favor of + * @param attributes the additional attributes. + * @deprecated since 1.1 in favor of * {@link org.springframework.restdocs.cli.CurlRequestSnippet}. */ @Deprecated diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/package-info.java index e614e2b8..8f930c07 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/curl/package-info.java @@ -16,7 +16,6 @@ /** * Documenting the curl command required to make a request to a RESTful API. - * * @deprecated Since 1.1 in favor of functionality in * {@code org.springframework.restdocs.cli} */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/generate/RestDocumentationGenerationException.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/generate/RestDocumentationGenerationException.java index 2db29ea0..17e10152 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/generate/RestDocumentationGenerationException.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/generate/RestDocumentationGenerationException.java @@ -27,7 +27,6 @@ public class RestDocumentationGenerationException extends RuntimeException { /** * Creates a new {@code RestDocumentationException} with the given {@code cause}. - * * @param cause the cause */ public RestDocumentationGenerationException(Throwable cause) { @@ -37,7 +36,6 @@ public class RestDocumentationGenerationException extends RuntimeException { /** * Creates a new {@code RestDocumentationException} with the given {@code message} and * {@code cause}. - * * @param message the message * @param cause the cause */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/generate/RestDocumentationGenerator.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/generate/RestDocumentationGenerator.java index 53ca064d..84b1a9c3 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/generate/RestDocumentationGenerator.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/generate/RestDocumentationGenerator.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. @@ -75,7 +75,6 @@ public final class RestDocumentationGenerator { * {@code responseConverter} are used to convert the operation's request and response * into generic {@code OperationRequest} and {@code OperationResponse} instances that * can then be documented. The given documentation {@code snippets} will be produced. - * * @param identifier the identifier for the operation * @param requestConverter the request converter * @param responseConverter the response converter @@ -97,7 +96,6 @@ public final class RestDocumentationGenerator { * can then be documented. The given {@code requestPreprocessor} is applied to the * request before it is documented. The given documentation {@code snippets} will be * produced. - * * @param identifier the identifier for the operation * @param requestConverter the request converter * @param responseConverter the response converter @@ -120,7 +118,6 @@ public final class RestDocumentationGenerator { * can then be documented. The given {@code responsePreprocessor} is applied to the * response before it is documented. The given documentation {@code snippets} will be * produced. - * * @param identifier the identifier for the operation * @param requestConverter the request converter * @param responseConverter the response converter @@ -144,7 +141,6 @@ public final class RestDocumentationGenerator { * can then be documented. The given {@code requestPreprocessor} and * {@code responsePreprocessor} are applied to the request and response before they * are documented. The given documentation {@code snippets} will be produced. - * * @param identifier the identifier for the operation * @param requestConverter the request converter * @param responseConverter the response converter @@ -176,7 +172,6 @@ public final class RestDocumentationGenerator { /** * Handles the given {@code request} and {@code response}, producing documentation * snippets for them using the given {@code configuration}. - * * @param request the request * @param response the request * @param configuration the configuration @@ -204,7 +199,6 @@ public final class RestDocumentationGenerator { /** * Adds the given {@code snippets} such that they are documented when this handler is * called. - * * @param snippets the snippets to add * @deprecated since 1.1 in favor of {@link #withSnippets(Snippet...)} */ @@ -217,7 +211,6 @@ public final class RestDocumentationGenerator { * Creates a new {@link RestDocumentationGenerator} with the same configuration as * this one other than its snippets. The new generator will use the given * {@code snippets}. - * * @param snippets the snippets * @return the new generator */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/AbstractHeadersSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/AbstractHeadersSnippet.java index 6b52f16f..d91f5d8b 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/AbstractHeadersSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/AbstractHeadersSnippet.java @@ -44,7 +44,6 @@ public abstract class AbstractHeadersSnippet extends TemplatedSnippet { * {@code -headers}. The headers will be documented using the given * {@code descriptors} and the given {@code attributes} will be included in the model * during template rendering. - * * @param type the type of the headers * @param descriptors the header descriptors * @param attributes the additional attributes @@ -91,7 +90,6 @@ public abstract class AbstractHeadersSnippet extends TemplatedSnippet { * Finds the headers that are missing from the operation. A header is missing if it is * described by one of the {@code headerDescriptors} but is not present in the * operation. - * * @param operation the operation * @return descriptors for the headers that are missing from the operation */ @@ -111,7 +109,6 @@ public abstract class AbstractHeadersSnippet extends TemplatedSnippet { /** * Extracts the names of the headers from the request or response of the given * {@code operation}. - * * @param operation the operation * @return the header names */ @@ -120,7 +117,6 @@ public abstract class AbstractHeadersSnippet extends TemplatedSnippet { /** * Returns the list of {@link HeaderDescriptor HeaderDescriptors} that will be used to * generate the documentation. - * * @return the header descriptors */ protected final List getHeaderDescriptors() { @@ -129,7 +125,6 @@ public abstract class AbstractHeadersSnippet extends TemplatedSnippet { /** * Returns a model for the given {@code descriptor}. - * * @param descriptor the descriptor * @return the model */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/HeaderDescriptor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/HeaderDescriptor.java index b0e332ab..e7e5192b 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/HeaderDescriptor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/HeaderDescriptor.java @@ -43,7 +43,6 @@ public class HeaderDescriptor extends AbstractDescriptor { /** * Marks the header as optional. - * * @return {@code this} */ public final HeaderDescriptor optional() { @@ -53,7 +52,6 @@ public class HeaderDescriptor extends AbstractDescriptor { /** * Returns the name for the header. - * * @return the header name */ public final String getName() { @@ -62,7 +60,6 @@ public class HeaderDescriptor extends AbstractDescriptor { /** * Returns {@code true} if the described header is optional, otherwise {@code false}. - * * @return {@code true} if the described header is optional, otherwise {@code false} */ public final boolean isOptional() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/HeaderDocumentation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/HeaderDocumentation.java index 9f32638e..8fe81f9d 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/HeaderDocumentation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/HeaderDocumentation.java @@ -38,8 +38,7 @@ public abstract class HeaderDocumentation { /** * Creates a {@code HeaderDescriptor} that describes a header with the given * {@code name}. - * - * @param name The name of the header + * @param name the name of the header * @return a {@code HeaderDescriptor} ready for further configuration */ public static HeaderDescriptor headerWithName(String name) { @@ -52,7 +51,6 @@ public abstract class HeaderDocumentation { *

* If a header is documented, is not marked as optional, and is not present in the * request, a failure will occur. - * * @param descriptors the descriptions of the request's headers * @return the snippet that will document the request headers * @see #headerWithName(String) @@ -67,7 +65,6 @@ public abstract class HeaderDocumentation { *

* If a header is documented, is not marked as optional, and is not present in the * request, a failure will occur. - * * @param descriptors the descriptions of the request's headers * @return the snippet that will document the request headers * @see #headerWithName(String) @@ -84,7 +81,6 @@ public abstract class HeaderDocumentation { *

* If a header is documented, is not marked as optional, and is not present in the * request, a failure will occur. - * * @param attributes the attributes * @param descriptors the descriptions of the request's headers * @return the snippet that will document the request headers @@ -102,7 +98,6 @@ public abstract class HeaderDocumentation { *

* If a header is documented, is not marked as optional, and is not present in the * request, a failure will occur. - * * @param attributes the attributes * @param descriptors the descriptions of the request's headers * @return the snippet that will document the request headers @@ -119,7 +114,6 @@ public abstract class HeaderDocumentation { *

* If a header is documented, is not marked as optional, and is not present in the * request, a failure will occur. - * * @param descriptors the descriptions of the response's headers * @return the snippet that will document the response headers * @see #headerWithName(String) @@ -135,7 +129,6 @@ public abstract class HeaderDocumentation { *

* If a header is documented, is not marked as optional, and is not present in the * request, a failure will occur. - * * @param descriptors the descriptions of the response's headers * @return the snippet that will document the response headers * @see #headerWithName(String) @@ -153,7 +146,6 @@ public abstract class HeaderDocumentation { *

* If a header is documented, is not marked as optional, and is not present in the * response, a failure will occur. - * * @param attributes the attributes * @param descriptors the descriptions of the response's headers * @return the snippet that will document the response headers @@ -172,7 +164,6 @@ public abstract class HeaderDocumentation { *

* If a header is documented, is not marked as optional, and is not present in the * response, a failure will occur. - * * @param attributes the attributes * @param descriptors the descriptions of the response's headers * @return the snippet that will document the response headers diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/RequestHeadersSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/RequestHeadersSnippet.java index 71ec61ab..039b88bd 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/RequestHeadersSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/RequestHeadersSnippet.java @@ -38,7 +38,6 @@ public class RequestHeadersSnippet extends AbstractHeadersSnippet { /** * Creates a new {@code RequestHeadersSnippet} that will document the headers in the * request using the given {@code descriptors}. - * * @param descriptors the descriptors */ protected RequestHeadersSnippet(List descriptors) { @@ -49,7 +48,6 @@ public class RequestHeadersSnippet extends AbstractHeadersSnippet { * Creates a new {@code RequestHeadersSnippet} that will document the headers in the * request using the given {@code descriptors}. The given {@code attributes} will be * included in the model during template rendering. - * * @param descriptors the descriptors * @param attributes the additional attributes */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/ResponseHeadersSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/ResponseHeadersSnippet.java index 8b9ec45c..59a369be 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/ResponseHeadersSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/ResponseHeadersSnippet.java @@ -38,7 +38,6 @@ public class ResponseHeadersSnippet extends AbstractHeadersSnippet { /** * Creates a new {@code ResponseHeadersSnippet} that will document the headers in the * response using the given {@code descriptors}. - * * @param descriptors the descriptors */ protected ResponseHeadersSnippet(List descriptors) { @@ -49,7 +48,6 @@ public class ResponseHeadersSnippet extends AbstractHeadersSnippet { * Creates a new {@code ResponseHeadersSnippet} that will document the headers in the * response using the given {@code descriptors}. The given {@code attributes} will be * included in the model during template rendering. - * * @param descriptors the descriptors * @param attributes the additional attributes */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpDocumentation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpDocumentation.java index 5d872fe2..df77c2c2 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpDocumentation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpDocumentation.java @@ -33,7 +33,6 @@ public abstract class HttpDocumentation { /** * Returns a new {@code Snippet} that will document the HTTP request for the API * operation. - * * @return the snippet that will document the HTTP request */ public static HttpRequestSnippet httpRequest() { @@ -44,7 +43,6 @@ public abstract class HttpDocumentation { * Returns a new {@code Snippet} that will document the HTTP request for the API * operation. The given {@code attributes} will be available during snippet * generation. - * * @param attributes the attributes * @return the snippet that will document the HTTP request */ @@ -55,7 +53,6 @@ public abstract class HttpDocumentation { /** * Returns a {@code Snippet} that will document the HTTP response for the API * operation. - * * @return the snippet that will document the HTTP response */ public static HttpResponseSnippet httpResponse() { @@ -66,7 +63,6 @@ public abstract class HttpDocumentation { * Returns a {@code Snippet} that will document the HTTP response for the API * operation. The given {@code attributes} will be available during snippet * generation. - * * @param attributes the attributes * @return the snippet that will document the HTTP response */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpRequestSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpRequestSnippet.java index 236a5a46..c624c1ca 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpRequestSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpRequestSnippet.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. @@ -57,8 +57,7 @@ public class HttpRequestSnippet extends TemplatedSnippet { /** * Creates a new {@code HttpRequestSnippet} with the given additional * {@code attributes} that will be included in the model during template rendering. - * - * @param attributes The additional attributes + * @param attributes the additional attributes */ protected HttpRequestSnippet(Map attributes) { super("http-request", attributes); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpResponseSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpResponseSnippet.java index c9fd1f71..d21f089c 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpResponseSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/HttpResponseSnippet.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. @@ -47,8 +47,7 @@ public class HttpResponseSnippet extends TemplatedSnippet { /** * Creates a new {@code HttpResponseSnippet} with the given additional * {@code attributes} that will be included in the model during template rendering. - * - * @param attributes The additional attributes + * @param attributes the additional attributes */ protected HttpResponseSnippet(Map attributes) { super("http-response", attributes); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/AtomLinkExtractor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/AtomLinkExtractor.java index 71a2d8dc..53814a1b 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/AtomLinkExtractor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/AtomLinkExtractor.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. @@ -53,7 +53,7 @@ class AtomLinkExtractor extends AbstractJsonLinkExtractor { if (relObject instanceof String && hrefObject instanceof String) { Object titleObject = linkMap.get("title"); return new Link((String) relObject, (String) hrefObject, - titleObject instanceof String ? (String) titleObject : null); + (titleObject instanceof String) ? (String) titleObject : null); } return null; } diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HalLinkExtractor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HalLinkExtractor.java index 866a8322..4e4b1ebd 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HalLinkExtractor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HalLinkExtractor.java @@ -72,7 +72,7 @@ class HalLinkExtractor extends AbstractJsonLinkExtractor { if (hrefObject instanceof String) { Object titleObject = possibleLinkMap.get("title"); return new Link(rel, (String) hrefObject, - titleObject instanceof String ? (String) titleObject : null); + (titleObject instanceof String) ? (String) titleObject : null); } } return null; diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HypermediaDocumentation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HypermediaDocumentation.java index e07bb8dd..a3590724 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HypermediaDocumentation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HypermediaDocumentation.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. @@ -34,8 +34,7 @@ public abstract class HypermediaDocumentation { /** * Creates a {@code LinkDescriptor} that describes a link with the given {@code rel}. - * - * @param rel The rel of the link + * @param rel the rel of the link * @return a {@code LinkDescriptor} ready for further configuration */ public static LinkDescriptor linkWithRel(String rel) { @@ -59,7 +58,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param descriptors the descriptions of the response's links * @return the snippet that will document the links */ @@ -84,7 +82,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param descriptors the descriptions of the response's links * @return the snippet that will document the links */ @@ -103,7 +100,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param descriptors the descriptions of the response's links * @return the snippet that will document the links */ @@ -122,7 +118,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param descriptors the descriptions of the response's links * @return the snippet that will document the links */ @@ -148,7 +143,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param attributes the attributes * @param descriptors the descriptions of the response's links * @return the snippet that will document the links @@ -176,7 +170,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param attributes the attributes * @param descriptors the descriptions of the response's links * @return the snippet that will document the links @@ -198,7 +191,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param attributes the attributes * @param descriptors the descriptions of the response's links * @return the snippet that will document the links @@ -220,7 +212,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param attributes the attributes * @param descriptors the descriptions of the response's links * @return the snippet that will document the links @@ -248,7 +239,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param linkExtractor used to extract the links from the response * @param descriptors the descriptions of the response's links * @return the snippet that will document the links @@ -275,7 +265,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param linkExtractor used to extract the links from the response * @param descriptors the descriptions of the response's links * @return the snippet that will document the links @@ -296,7 +285,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param linkExtractor used to extract the links from the response * @param descriptors the descriptions of the response's links * @return the snippet that will document the links @@ -317,7 +305,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param linkExtractor used to extract the links from the response * @param descriptors the descriptions of the response's links * @return the snippet that will document the links @@ -345,7 +332,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param attributes the attributes * @param linkExtractor used to extract the links from the response * @param descriptors the descriptions of the response's links @@ -374,7 +360,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param attributes the attributes * @param linkExtractor used to extract the links from the response * @param descriptors the descriptions of the response's links @@ -397,7 +382,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param attributes the attributes * @param linkExtractor used to extract the links from the response * @param descriptors the descriptions of the response's links @@ -420,7 +404,6 @@ public abstract class HypermediaDocumentation { * If a descriptor does not have a {@link LinkDescriptor#description(Object) * description}, the {@link Link#getTitle() title} of the link will be used. If the * link does not have a title a failure will occur. - * * @param attributes the attributes * @param linkExtractor used to extract the links from the response * @param descriptors the descriptions of the response's links @@ -445,8 +428,7 @@ public abstract class HypermediaDocumentation { * } * } * - * - * @return The extractor for HAL-style links + * @return the extractor for HAL-style links */ public static LinkExtractor halLinks() { return new HalLinkExtractor(); @@ -466,8 +448,7 @@ public abstract class HypermediaDocumentation { * ] * } * - * - * @return The extractor for Atom-style links + * @return the extractor for Atom-style links */ public static LinkExtractor atomLinks() { return new AtomLinkExtractor(); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/Link.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/Link.java index 01d5165c..d590e1bc 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/Link.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/Link.java @@ -33,9 +33,8 @@ public class Link { /** * Creates a new {@code Link} with the given {@code rel} and {@code href}. - * - * @param rel The link's rel - * @param href The link's href + * @param rel the link's rel + * @param href the link's href */ public Link(String rel, String href) { this(rel, href, null); @@ -44,10 +43,9 @@ public class Link { /** * Creates a new {@code Link} with the given {@code rel}, {@code href}, and * {@code title}. - * - * @param rel The link's rel - * @param href The link's href - * @param title The link's title + * @param rel the link's rel + * @param href the link's href + * @param title the link's title */ public Link(String rel, String href, String title) { this.rel = rel; @@ -79,16 +77,6 @@ public class Link { return this.title; } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + this.href.hashCode(); - result = prime * result + this.rel.hashCode(); - result = prime * result + ((this.title == null) ? 0 : this.title.hashCode()); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -118,6 +106,16 @@ public class Link { return true; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + this.href.hashCode(); + result = prime * result + this.rel.hashCode(); + result = prime * result + ((this.title == null) ? 0 : this.title.hashCode()); + return result; + } + @Override public String toString() { return new ToStringCreator(this).append("rel", this.rel).append("href", this.href) diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkDescriptor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkDescriptor.java index 8876cf7d..7841b794 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkDescriptor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkDescriptor.java @@ -32,7 +32,6 @@ public class LinkDescriptor extends IgnorableDescriptor { /** * Creates a new {@code LinkDescriptor} describing a link with the given {@code rel}. - * * @param rel the rel of the link */ protected LinkDescriptor(String rel) { @@ -41,7 +40,6 @@ public class LinkDescriptor extends IgnorableDescriptor { /** * Marks the link as optional. - * * @return {@code this} */ public final LinkDescriptor optional() { @@ -51,7 +49,6 @@ public class LinkDescriptor extends IgnorableDescriptor { /** * Returns the rel of the link described by this descriptor. - * * @return the rel */ public final String getRel() { @@ -60,7 +57,6 @@ public class LinkDescriptor extends IgnorableDescriptor { /** * Returns {@code true} if the described link is optional, otherwise {@code false}. - * * @return {@code true} if the described link is optional, otherwise {@code false} */ public final boolean isOptional() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkExtractor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkExtractor.java index 747731d6..84e1d60a 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkExtractor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkExtractor.java @@ -34,9 +34,8 @@ public interface LinkExtractor { /** * Extract the links from the given {@code response}, returning a {@code Map} of links * where the keys are the link rels. - * - * @param response The response from which the links are to be extracted - * @return The extracted links, keyed by rel + * @param response the response from which the links are to be extracted + * @return the extracted links, keyed by rel * @throws IOException if link extraction fails */ Map> extractLinks(OperationResponse response) throws IOException; diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinksSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinksSnippet.java index 62543d5b..8832fe93 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinksSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinksSnippet.java @@ -57,7 +57,6 @@ public class LinksSnippet extends TemplatedSnippet { * Creates a new {@code LinksSnippet} that will extract links using the given * {@code linkExtractor} and document them using the given {@code descriptors}. * Undocumented links will trigger a failure. - * * @param linkExtractor the link extractor * @param descriptors the link descriptors */ @@ -71,7 +70,6 @@ public class LinksSnippet extends TemplatedSnippet { * {@code linkExtractor} and document them using the given {@code descriptors}. If * {@code ignoreUndocumentedLinks} is {@code true}, undocumented links will be ignored * and will not trigger a failure. - * * @param linkExtractor the link extractor * @param descriptors the link descriptors * @param ignoreUndocumentedLinks whether undocumented links should be ignored @@ -86,7 +84,6 @@ public class LinksSnippet extends TemplatedSnippet { * {@code linkExtractor} and document them using the given {@code descriptors}. The * given {@code attributes} will be included in the model during template rendering. * Undocumented links will trigger a failure. - * * @param linkExtractor the link extractor * @param descriptors the link descriptors * @param attributes the additional attributes @@ -102,7 +99,6 @@ public class LinksSnippet extends TemplatedSnippet { * given {@code attributes} will be included in the model during template rendering. * If {@code ignoreUndocumentedLinks} is {@code true}, undocumented links will be * ignored and will not trigger a failure. - * * @param linkExtractor the link extractor * @param descriptors the link descriptors * @param attributes the additional attributes @@ -220,7 +216,6 @@ public class LinksSnippet extends TemplatedSnippet { /** * Returns a {@code Map} of {@link LinkDescriptor LinkDescriptors} keyed by their * {@link LinkDescriptor#getRel() rels}. - * * @return the link descriptors */ protected final Map getDescriptorsByRel() { @@ -229,7 +224,6 @@ public class LinksSnippet extends TemplatedSnippet { /** * Returns a model for the given {@code descriptor}. - * * @param descriptor the descriptor * @return the model */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/AbstractOperationMessage.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/AbstractOperationMessage.java index 75c48e66..06aa85f2 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/AbstractOperationMessage.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/AbstractOperationMessage.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. @@ -34,7 +34,7 @@ abstract class AbstractOperationMessage { private final HttpHeaders headers; AbstractOperationMessage(byte[] content, HttpHeaders headers) { - this.content = content == null ? new byte[0] : content; + this.content = (content != null) ? content : new byte[0]; this.headers = headers; } @@ -49,7 +49,7 @@ abstract class AbstractOperationMessage { public String getContentAsString() { if (this.content.length > 0) { Charset charset = extractCharsetFromContentTypeHeader(); - return charset != null ? new String(this.content, charset) + return (charset != null) ? new String(this.content, charset) : new String(this.content); } return ""; diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/ConversionException.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/ConversionException.java index 96b6c5e5..b2482bf8 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/ConversionException.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/ConversionException.java @@ -30,7 +30,6 @@ public class ConversionException extends RuntimeException { /** * Creates a new {@code ConversionException} with the given {@code cause}. - * * @param cause the cause */ public ConversionException(Throwable cause) { @@ -40,7 +39,6 @@ public class ConversionException extends RuntimeException { /** * Creates a new {@code ConversionException} with the given {@code message} and * {@code cause}. - * * @param message the message * @param cause the cause */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/Operation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/Operation.java index a0053363..050bdb1c 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/Operation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/Operation.java @@ -27,28 +27,24 @@ public interface Operation { /** * Returns a {@code Map} of attributes associated with the operation. - * * @return the attributes */ Map getAttributes(); /** * Returns the name of the operation. - * * @return the name */ String getName(); /** * Returns the request that was sent. - * * @return the request */ OperationRequest getRequest(); /** * Returns the response that was received. - * * @return the response */ OperationResponse getResponse(); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequest.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequest.java index f768663d..cbb6bc43 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequest.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequest.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. @@ -33,7 +33,6 @@ public interface OperationRequest { /** * Returns the content of the request. If the request has no content an empty array is * returned. - * * @return the contents, never {@code null} */ byte[] getContent(); @@ -43,21 +42,18 @@ public interface OperationRequest { * content an empty string is returned. If the request has a {@code Content-Type} * header that specifies a charset then that charset will be used when converting the * contents to a {@code String}. - * * @return the contents as string, never {@code null} */ String getContentAsString(); /** * Returns the headers that were included in the request. - * * @return the headers */ HttpHeaders getHeaders(); /** * Returns the HTTP method of the request. - * * @return the HTTP method */ HttpMethod getMethod(); @@ -66,7 +62,6 @@ public interface OperationRequest { * Returns the request's parameters. For a {@code GET} request, the parameters are * derived from the query string. For a {@code POST} request, the parameters are * derived form the request's body. - * * @return the parameters */ Parameters getParameters(); @@ -74,14 +69,12 @@ public interface OperationRequest { /** * Returns the request's parts, provided that it is a multipart request. If not, then * an empty {@link Collection} is returned. - * * @return the parts */ Collection getParts(); /** * Returns the request's URI. - * * @return the URI */ URI getUri(); @@ -89,7 +82,6 @@ public interface OperationRequest { /** * Returns the {@link RequestCookie cookies} sent with the request. If no cookies were * sent an empty collection is returned. - * * @return the cookies, never {@code null} * @since 1.2.0 */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestFactory.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestFactory.java index da1c07cf..c4697097 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestFactory.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestFactory.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. @@ -34,7 +34,6 @@ public class OperationRequestFactory { * Creates a new {@link OperationRequest}. The given {@code headers} will be augmented * to ensure that they always include a {@code Content-Length} header if the request * has any content and a {@code Host} header. - * * @param uri the request's uri * @param method the request method * @param content the content of the request @@ -55,7 +54,6 @@ public class OperationRequestFactory { * Creates a new {@link OperationRequest}. The given {@code headers} will be augmented * to ensure that they always include a {@code Content-Length} header if the request * has any content and a {@code Host} header. - * * @param uri the request's uri * @param method the request method * @param content the content of the request @@ -75,11 +73,9 @@ public class OperationRequestFactory { * Creates a new {@code OperationRequest} based on the given {@code original} but with * the given {@code newContent}. If the original request had a {@code Content-Length} * header it will be modified to match the length of the new content. - * - * @param original The original request - * @param newContent The new content - * - * @return The new request with the new content + * @param original the original request + * @param newContent the new content + * @return the new request with the new content */ public OperationRequest createFrom(OperationRequest original, byte[] newContent) { return new StandardOperationRequest(original.getUri(), original.getMethod(), @@ -90,11 +86,9 @@ public class OperationRequestFactory { /** * Creates a new {@code OperationRequest} based on the given {@code original} but with * the given {@code newHeaders}. - * - * @param original The original request - * @param newHeaders The new headers - * - * @return The new request with the new headers + * @param original the original request + * @param newHeaders the new headers + * @return the new request with the new headers */ public OperationRequest createFrom(OperationRequest original, HttpHeaders newHeaders) { @@ -106,11 +100,9 @@ public class OperationRequestFactory { /** * Creates a new {@code OperationRequest} based on the given {@code original} but with * the given {@code newParameters}. - * - * @param original The original request - * @param newParameters The new parameters - * - * @return The new request with the new parameters + * @param original the original request + * @param newParameters the new parameters + * @return the new request with the new parameters */ public OperationRequest createFrom(OperationRequest original, Parameters newParameters) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestPart.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestPart.java index 13cb8ed0..7b77d872 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestPart.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestPart.java @@ -28,21 +28,18 @@ public interface OperationRequestPart { /** * Returns the name of the part. - * * @return the name */ String getName(); /** * Returns the name of the file that is being uploaded in this part. - * * @return the name of the file */ String getSubmittedFileName(); /** * Returns the contents of the part. - * * @return the contents */ byte[] getContent(); @@ -52,14 +49,12 @@ public interface OperationRequestPart { * empty string is returned. If the part has a {@code Content-Type} header that * specifies a charset then that charset will be used when converting the contents to * a {@code String}. - * * @return the contents as string, never {@code null} */ String getContentAsString(); /** * Returns the part's headers. - * * @return the headers */ HttpHeaders getHeaders(); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestPartFactory.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestPartFactory.java index 47aa7e43..448f7f27 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestPartFactory.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationRequestPartFactory.java @@ -29,7 +29,6 @@ public class OperationRequestPartFactory { * Creates a new {@link OperationRequestPart}. The given {@code headers} will be * augmented to ensure that they always include a {@code Content-Length} header if the * part has any content. - * * @param name the name of the part * @param submittedFileName the name of the file being submitted by the part * @param content the content of the part diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponse.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponse.java index 6a518679..268595d0 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponse.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponse.java @@ -30,14 +30,12 @@ public interface OperationResponse { /** * Returns the status of the response. - * * @return the status */ HttpStatus getStatus(); /** * Returns the headers in the response. - * * @return the headers */ HttpHeaders getHeaders(); @@ -45,7 +43,6 @@ public interface OperationResponse { /** * Returns the content of the response. If the response has no content an empty array * is returned. - * * @return the contents, never {@code null} */ byte[] getContent(); @@ -55,7 +52,6 @@ public interface OperationResponse { * content an empty string is returned. If the response has a {@code Content-Type} * header that specifies a charset then that charset will be used when converting the * contents to a {@code String}. - * * @return the contents as string, never {@code null} */ String getContentAsString(); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.java index 1cfd1434..6d075df1 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.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. @@ -30,7 +30,6 @@ public class OperationResponseFactory { * Creates a new {@link OperationResponse}. If the response has any content, the given * {@code headers} will be augmented to ensure that they include a * {@code Content-Length} header. - * * @param status the status of the response * @param headers the request's headers * @param content the content of the request @@ -47,11 +46,9 @@ public class OperationResponseFactory { * with the given {@code newContent}. If the original response had a * {@code Content-Length} header it will be modified to match the length of the new * content. - * - * @param original The original response - * @param newContent The new content - * - * @return The new response with the new content + * @param original the original response + * @param newContent the new content + * @return the new response with the new content */ public OperationResponse createFrom(OperationResponse original, byte[] newContent) { return new StandardOperationResponse(original.getStatus(), @@ -61,11 +58,9 @@ public class OperationResponseFactory { /** * Creates a new {@code OperationResponse} based on the given {@code original} but * with the given {@code newHeaders}. - * - * @param original The original response - * @param newHeaders The new headers - * - * @return The new response with the new headers + * @param original the original response + * @param newHeaders the new headers + * @return the new response with the new headers */ public OperationResponse createFrom(OperationResponse original, HttpHeaders newHeaders) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/Parameters.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/Parameters.java index f2ec42a5..35107208 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/Parameters.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/Parameters.java @@ -36,7 +36,6 @@ public class Parameters extends LinkedMultiValueMap { /** * Converts the parameters to a query string suitable for use in a URI or the body of * a form-encoded request. - * * @return the query string */ public String toQueryString() { @@ -57,7 +56,6 @@ public class Parameters extends LinkedMultiValueMap { /** * Returns a new {@code Parameters} containing only the parameters that do no appear * in the query string of the given {@code uri}. - * * @param uri the uri * @return the unique parameters */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/QueryStringParser.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/QueryStringParser.java index c5ab3b70..c5df6cb0 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/QueryStringParser.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/QueryStringParser.java @@ -33,7 +33,6 @@ public class QueryStringParser { /** * Parses the query string of the given {@code uri} and returns the resulting * {@link Parameters}. - * * @param uri the uri to parse * @return the parameters parsed from the query string */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/RequestConverter.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/RequestConverter.java index f7561ae5..50bbeb9f 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/RequestConverter.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/RequestConverter.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. @@ -20,7 +20,7 @@ package org.springframework.restdocs.operation; * A {@code RequestConverter} is used to convert an implementation-specific request into * an {@link OperationRequest}. * - * @param The implementation-specific request type + * @param the implementation-specific request type * @author Andy Wilkinson * @since 1.1.0 */ @@ -28,7 +28,6 @@ public interface RequestConverter { /** * Converts the given {@code request} into an {@code OperationRequest}. - * * @param request the request * @return the operation request * @throws ConversionException if the conversion fails diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/RequestCookie.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/RequestCookie.java index 595a19f2..f95cb801 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/RequestCookie.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/RequestCookie.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. @@ -30,7 +30,6 @@ public final class RequestCookie { /** * Creates a new {@code RequestCookie} with the given {@code name} and {@code value}. - * * @param name the name of the cookie * @param value the value of the cookie */ @@ -41,7 +40,6 @@ public final class RequestCookie { /** * Returns the name of the cookie. - * * @return the name */ public String getName() { @@ -50,7 +48,6 @@ public final class RequestCookie { /** * Returns the value of the cookie. - * * @return the value */ public String getValue() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/ResponseConverter.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/ResponseConverter.java index d294e68d..2cbfc189 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/ResponseConverter.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/ResponseConverter.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. @@ -20,7 +20,7 @@ package org.springframework.restdocs.operation; * A {@code ResponseConverter} is used to convert an implementation-specific response into * an {@link OperationResponse}. * - * @param The implementation-specific response type + * @param the implementation-specific response type * @author Andy Wilkinson * @since 1.1.0 */ @@ -28,7 +28,6 @@ public interface ResponseConverter { /** * Converts the given {@code response} into an {@code OperationResponse}. - * * @param response the response * @return the operation response * @throws ConversionException if the conversion fails diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperation.java index 736fc4b5..145cf326 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperation.java @@ -35,7 +35,6 @@ public class StandardOperation implements Operation { /** * Creates a new {@code StandardOperation}. - * * @param name the name of the operation * @param request the request that was sent * @param response the response that was received diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationRequest.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationRequest.java index 5fb57508..bcc04c5a 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationRequest.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationRequest.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. @@ -45,7 +45,6 @@ class StandardOperationRequest extends AbstractOperationMessage * Creates a new request with the given {@code uri} and {@code method}. The request * will have the given {@code headers}, {@code parameters}, {@code parts}, and * {@code cookies}. - * * @param uri the uri * @param method the method * @param content the content diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationRequestPart.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationRequestPart.java index e9fee9d7..d88001a2 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationRequestPart.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationRequestPart.java @@ -32,7 +32,6 @@ class StandardOperationRequestPart extends AbstractOperationMessage /** * Creates a new {@code StandardOperationRequestPart} with the given {@code name}. - * * @param name the name of the part * @param submittedFileName the name of the file being uploaded by this part * @param content the contents of the part diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationResponse.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationResponse.java index 0131a4b5..00b18d98 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationResponse.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/StandardOperationResponse.java @@ -32,7 +32,6 @@ class StandardOperationResponse extends AbstractOperationMessage /** * Creates a new response with the given {@code status}, {@code headers}, and * {@code content}. - * * @param status the status of the response * @param headers the headers of the response * @param content the content of the response diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ContentModifier.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ContentModifier.java index 8781a817..19af1b61 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ContentModifier.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ContentModifier.java @@ -32,7 +32,6 @@ public interface ContentModifier { /** * Returns modified content based on the given {@code originalContent}. - * * @param originalContent the original content * @param contentType the type of the original content, may be {@code null} * @return the modified content diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ContentModifyingOperationPreprocessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ContentModifyingOperationPreprocessor.java index d18948e3..5c138fae 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ContentModifyingOperationPreprocessor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ContentModifyingOperationPreprocessor.java @@ -38,7 +38,6 @@ public class ContentModifyingOperationPreprocessor implements OperationPreproces /** * Create a new {@code ContentModifyingOperationPreprocessor} that will apply the * given {@code contentModifier} to the operation's request or response. - * * @param contentModifier the contentModifier */ public ContentModifyingOperationPreprocessor(ContentModifier contentModifier) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationRequestPreprocessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationRequestPreprocessor.java index 76490760..c3c56151 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationRequestPreprocessor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationRequestPreprocessor.java @@ -37,7 +37,6 @@ class DelegatingOperationRequestPreprocessor implements OperationRequestPreproce * Creates a new {@code DelegatingOperationRequestPreprocessor} that will delegate to * the given {@code delegates} by calling * {@link OperationPreprocessor#preprocess(OperationRequest)}. - * * @param delegates the delegates */ DelegatingOperationRequestPreprocessor(List delegates) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationResponsePreprocessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationResponsePreprocessor.java index f55ce4eb..0c951be4 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationResponsePreprocessor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationResponsePreprocessor.java @@ -36,7 +36,6 @@ class DelegatingOperationResponsePreprocessor implements OperationResponsePrepro * Creates a new {@code DelegatingOperationResponsePreprocessor} that will delegate to * the given {@code delegates} by calling * {@link OperationPreprocessor#preprocess(OperationResponse)}. - * * @param delegates the delegates */ DelegatingOperationResponsePreprocessor(List delegates) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeaderFilter.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeaderFilter.java index 6b14f249..0d1ce55f 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeaderFilter.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeaderFilter.java @@ -26,7 +26,6 @@ interface HeaderFilter { /** * Called to determine whether a header should be excluded. Return {@code true} to * exclude a header, otherwise {@code false}. - * * @param name the name of the header * @return {@code true} to exclude the header, otherwise {@code false} */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationPreprocessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationPreprocessor.java index bfdfbc25..ed91a95f 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationPreprocessor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationPreprocessor.java @@ -30,7 +30,6 @@ public interface OperationPreprocessor { /** * Processes the given {@code request}. - * * @param request the request to process * @return the processed request */ @@ -38,7 +37,6 @@ public interface OperationPreprocessor { /** * Processes the given {@code response}. - * * @param response the response to process * @return the processed response */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationPreprocessorAdapter.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationPreprocessorAdapter.java index bf2aadfb..be227125 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationPreprocessorAdapter.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationPreprocessorAdapter.java @@ -31,7 +31,6 @@ public abstract class OperationPreprocessorAdapter implements OperationPreproces /** * Returns the given {@code request} as-is. - * * @param request the request * @return the unmodified request */ @@ -42,7 +41,6 @@ public abstract class OperationPreprocessorAdapter implements OperationPreproces /** * Returns the given {@code response} as-is. - * * @param response the response * @return the unmodified response */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationRequestPreprocessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationRequestPreprocessor.java index 24cf7535..3c902b71 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationRequestPreprocessor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationRequestPreprocessor.java @@ -29,7 +29,6 @@ public interface OperationRequestPreprocessor { /** * Processes and potentially modifies the given {@code request} before it is * documented. - * * @param request the request * @return the modified request */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationResponsePreprocessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationResponsePreprocessor.java index 931b7379..1f328a74 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationResponsePreprocessor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationResponsePreprocessor.java @@ -29,7 +29,6 @@ public interface OperationResponsePreprocessor { /** * Processes and potentially modifies the given {@code response} before it is * documented. - * * @param response the response * @return the modified response */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ParametersModifyingOperationPreprocessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ParametersModifyingOperationPreprocessor.java index 71759dad..4b222287 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ParametersModifyingOperationPreprocessor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ParametersModifyingOperationPreprocessor.java @@ -51,7 +51,6 @@ public final class ParametersModifyingOperationPreprocessor /** * Adds a parameter with the given {@code name} and {@code value}. - * * @param name the name * @param value the value * @return {@code this} @@ -63,7 +62,6 @@ public final class ParametersModifyingOperationPreprocessor /** * Sets the parameter with the given {@code name} to have the given {@code values}. - * * @param name the name * @param values the values * @return {@code this} @@ -76,7 +74,6 @@ public final class ParametersModifyingOperationPreprocessor /** * Removes the parameter with the given {@code name}. - * * @param name the name of the parameter * @return {@code this} */ @@ -87,7 +84,6 @@ public final class ParametersModifyingOperationPreprocessor /** * Removes the given {@code value} from the parameter with the given {@code name}. - * * @param name the name * @param value the value * @return {@code this} diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifier.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifier.java index f33f6be6..ec2a1094 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifier.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifier.java @@ -37,7 +37,6 @@ class PatternReplacingContentModifier implements ContentModifier { /** * Creates a new {@link PatternReplacingContentModifier} that will replace occurrences * of the given {@code pattern} with the given {@code replacement}. - * * @param pattern the pattern * @param replacement the replacement */ 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..b075fdcb 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 @@ -41,7 +41,6 @@ public final class Preprocessors { /** * Returns an {@link OperationRequestPreprocessor} that will preprocess the request by * applying the given {@code preprocessors} to it. - * * @param preprocessors the preprocessors * @return the request preprocessor */ @@ -53,7 +52,6 @@ public final class Preprocessors { /** * Returns an {@link OperationResponsePreprocessor} that will preprocess the response * by applying the given {@code preprocessors} to it. - * * @param preprocessors the preprocessors * @return the response preprocessor */ @@ -65,7 +63,6 @@ public final class Preprocessors { /** * Returns an {@code OperationPreprocessor} that will pretty print the content of the * request or response. - * * @return the preprocessor */ public static OperationPreprocessor prettyPrint() { @@ -77,7 +74,6 @@ public final class Preprocessors { * Returns an {@code OperationPreprocessor} that will remove any header from the * request or response with a name that is equal to one of the given * {@code headersToRemove}. - * * @param headerNames the header names * @return the preprocessor * @see String#equals(Object) @@ -91,7 +87,6 @@ public final class Preprocessors { * Returns an {@code OperationPreprocessor} that will remove any headers from the * request or response with a name that matches one of the given * {@code headerNamePatterns} regular expressions. - * * @param headerNamePatterns the header name patterns * @return the preprocessor * @see java.util.regex.Matcher#matches() @@ -105,7 +100,6 @@ public final class Preprocessors { /** * Returns an {@code OperationPreprocessor} that will mask the href of hypermedia * links in the request or response. - * * @return the preprocessor */ public static OperationPreprocessor maskLinks() { @@ -116,7 +110,6 @@ public final class Preprocessors { /** * Returns an {@code OperationPreprocessor} that will mask the href of hypermedia * links in the request or response. - * * @param mask the link mask * @return the preprocessor */ @@ -129,7 +122,6 @@ public final class Preprocessors { * Returns an {@code OperationPreprocessor} that will modify the content of the * request or response by replacing occurrences of the given {@code pattern} with the * given {@code replacement}. - * * @param pattern the pattern * @param replacement the replacement * @return the preprocessor @@ -143,7 +135,6 @@ public final class Preprocessors { /** * Returns a {@code ParametersModifyingOperationPreprocessor} that can then be * configured to modify the parameters of the request. - * * @return the preprocessor * @since 1.1.0 */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/AbstractBodySnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/AbstractBodySnippet.java index 0010ea28..8d6759ee 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/AbstractBodySnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/AbstractBodySnippet.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. @@ -42,7 +42,6 @@ public abstract class AbstractBodySnippet extends TemplatedSnippet { * contain the subsection of the body extracted by the given * {@code subsectionExtractor}. The given {@code attributes} will be included in the * model during template rendering - * * @param type the type of the body * @param subsectionExtractor the subsection extractor * @param attributes the attributes @@ -59,7 +58,6 @@ public abstract class AbstractBodySnippet extends TemplatedSnippet { * contain the subsection of the body extracted by the given * {@code subsectionExtractor}. The given {@code attributes} will be included in the * model during template rendering - * * @param name the name of the snippet * @param type the type of the body * @param subsectionExtractor the subsection extractor @@ -69,7 +67,7 @@ public abstract class AbstractBodySnippet extends TemplatedSnippet { PayloadSubsectionExtractor subsectionExtractor, Map attributes) { super(name + "-body" - + (subsectionExtractor != null + + ((subsectionExtractor != null) ? "-" + subsectionExtractor.getSubsectionId() : ""), type + "-body", attributes); this.subsectionExtractor = subsectionExtractor; @@ -85,7 +83,7 @@ public abstract class AbstractBodySnippet extends TemplatedSnippet { contentType); } Charset charset = extractCharset(contentType); - String body = charset != null ? new String(content, charset) + String body = (charset != null) ? new String(content, charset) : new String(content); Map model = new HashMap<>(); model.put("body", body); @@ -106,9 +104,8 @@ public abstract class AbstractBodySnippet extends TemplatedSnippet { /** * Returns the content of the request or response extracted from the given * {@code operation}. - * - * @param operation The operation - * @return The content + * @param operation the operation + * @return the content * @throws IOException if the content cannot be extracted */ protected abstract byte[] getContent(Operation operation) throws IOException; @@ -116,9 +113,8 @@ public abstract class AbstractBodySnippet extends TemplatedSnippet { /** * Returns the content type of the request or response extracted from the given * {@code operation}. - * - * @param operation The operation - * @return The content type + * @param operation the operation + * @return the content type */ protected abstract MediaType getContentType(Operation operation); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/AbstractFieldsSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/AbstractFieldsSnippet.java index f40a42a8..16dcfd48 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/AbstractFieldsSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/AbstractFieldsSnippet.java @@ -54,7 +54,6 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { * {@code -fields}. The fields will be documented using the given * {@code descriptors} and the given {@code attributes} will be included in the model * during template rendering. Undocumented fields will trigger a failure. - * * @param type the type of the fields * @param descriptors the field descriptors * @param attributes the additional attributes @@ -74,7 +73,6 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { * will be included in the model during template rendering. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param type the type of the fields * @param descriptors the field descriptors * @param attributes the additional attributes @@ -93,7 +91,6 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { * {@code attributes} will be included in the model during template rendering. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param type the type of the fields * @param descriptors the field descriptors * @param attributes the additional attributes @@ -115,7 +112,6 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { * will be included in the model during template rendering. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param name the name of the snippet * @param type the type of the fields * @param descriptors the field descriptors @@ -136,7 +132,6 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { * will be included in the model during template rendering. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param name the name of the snippet * @param type the type of the fields * @param descriptors the field descriptors @@ -151,7 +146,7 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { boolean ignoreUndocumentedFields, PayloadSubsectionExtractor subsectionExtractor) { super(name + "-fields" - + (subsectionExtractor != null + + ((subsectionExtractor != null) ? "-" + subsectionExtractor.getSubsectionId() : ""), type + "-fields", attributes); for (FieldDescriptor descriptor : descriptors) { @@ -283,18 +278,16 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { /** * Returns the content type of the request or response extracted from the given * {@code operation}. - * - * @param operation The operation - * @return The content type + * @param operation the operation + * @return the content type */ protected abstract MediaType getContentType(Operation operation); /** * Returns the content of the request or response extracted form the given * {@code operation}. - * - * @param operation The operation - * @return The content + * @param operation the operation + * @return the content * @throws IOException if the content cannot be extracted */ protected abstract byte[] getContent(Operation operation) throws IOException; @@ -302,7 +295,6 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { /** * Returns the list of {@link FieldDescriptor FieldDescriptors} that will be used to * generate the documentation. - * * @return the field descriptors */ protected final List getFieldDescriptors() { @@ -311,7 +303,6 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { /** * Returns whether or not this snippet ignores undocumented fields. - * * @return {@code true} if undocumented fields are ignored, otherwise {@code false} */ protected final boolean isIgnoredUndocumentedFields() { @@ -320,7 +311,6 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { /** * Returns the {@link PayloadSubsectionExtractor}, if any, used by this snippet. - * * @return the subsection extractor or {@code null} * @since 1.2.4 */ @@ -330,7 +320,6 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { /** * Returns a model for the given {@code descriptor}. - * * @param descriptor the descriptor * @return the model */ @@ -345,7 +334,7 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { } private FieldDescriptor copyWithType(FieldDescriptor source, Object type) { - FieldDescriptor result = source instanceof SubsectionDescriptor + FieldDescriptor result = (source instanceof SubsectionDescriptor) ? new SubsectionDescriptor(source.getPath()) : new FieldDescriptor(source.getPath()); result.description(source.getDescription()).type(type) diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ContentHandler.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ContentHandler.java index 45865f4b..32bed30b 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ContentHandler.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ContentHandler.java @@ -29,7 +29,6 @@ interface ContentHandler { * Finds the fields that are missing from the handler's payload. A field is missing if * it is described by one of the {@code fieldDescriptors} but is not present in the * payload. - * * @param fieldDescriptors the descriptors * @return descriptors for the fields that are missing from the payload * @throws PayloadHandlingException if a failure occurs @@ -41,7 +40,6 @@ interface ContentHandler { * are undocumented. A field is undocumented if it is present in the handler's content * but is not described by the given {@code fieldDescriptors}. If the content is * completely documented, {@code null} is returned - * * @param fieldDescriptors the descriptors * @return the undocumented content, or {@code null} if all of the content is * documented @@ -52,7 +50,6 @@ interface ContentHandler { /** * Returns the type of the field that is described by the given * {@code fieldDescriptor} based on the content of the payload. - * * @param fieldDescriptor the field descriptor * @return the type of the field */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldDescriptor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldDescriptor.java index edc48443..ce209849 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldDescriptor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldDescriptor.java @@ -45,8 +45,7 @@ public class FieldDescriptor extends IgnorableDescriptor { /** * Specifies the type of the field. When documenting a JSON payload, the * {@link JsonFieldType} enumeration will typically be used. - * - * @param type The type of the field + * @param type the type of the field * @return {@code this} * @see JsonFieldType */ @@ -57,7 +56,6 @@ public class FieldDescriptor extends IgnorableDescriptor { /** * Marks the field as optional. - * * @return {@code this} */ public final FieldDescriptor optional() { @@ -67,7 +65,6 @@ public class FieldDescriptor extends IgnorableDescriptor { /** * Returns the path of the field described by this descriptor. - * * @return the path */ public final String getPath() { @@ -76,7 +73,6 @@ public class FieldDescriptor extends IgnorableDescriptor { /** * Returns the type of the field described by this descriptor. - * * @return the type */ public final Object getType() { @@ -85,7 +81,6 @@ public class FieldDescriptor extends IgnorableDescriptor { /** * Returns {@code true} if the described field is optional, otherwise {@code false}. - * * @return {@code true} if the described field is optional, otherwise {@code false} */ public final boolean isOptional() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldDoesNotExistException.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldDoesNotExistException.java index 3ba56eb0..e13aba17 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldDoesNotExistException.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldDoesNotExistException.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. @@ -28,7 +28,6 @@ public class FieldDoesNotExistException extends RuntimeException { /** * Creates a new {@code FieldDoesNotExistException} that indicates that the field with * the given {@code fieldPath} does not exist. - * * @param fieldPath the path of the field that does not exist */ public FieldDoesNotExistException(String fieldPath) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldPathPayloadSubsectionExtractor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldPathPayloadSubsectionExtractor.java index 1418326e..69b07cbb 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldPathPayloadSubsectionExtractor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldPathPayloadSubsectionExtractor.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. @@ -46,7 +46,6 @@ public class FieldPathPayloadSubsectionExtractor * Creates a new {@code FieldPathPayloadSubsectionExtractor} that will extract the * subsection of the JSON payload found at the given {@code fieldPath}. The * {@code fieldPath} prefixed with {@code beneath-} with be used as the subsection ID. - * * @param fieldPath the path of the field */ protected FieldPathPayloadSubsectionExtractor(String fieldPath) { @@ -57,7 +56,6 @@ public class FieldPathPayloadSubsectionExtractor * Creates a new {@code FieldPathPayloadSubsectionExtractor} that will extract the * subsection of the JSON payload found at the given {@code fieldPath} and that will * us the given {@code subsectionId} to identify the subsection. - * * @param fieldPath the path of the field * @param subsectionId the ID of the subsection */ @@ -96,7 +94,6 @@ public class FieldPathPayloadSubsectionExtractor /** * Returns the path of the field that will be extracted. - * * @return the path of the field */ protected String getFieldPath() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypeRequiredException.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypeRequiredException.java index dfa98953..2846883e 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypeRequiredException.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypeRequiredException.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. @@ -28,7 +28,6 @@ public class FieldTypeRequiredException extends RuntimeException { /** * Creates a new {@code FieldTypeRequiredException} indicating that a type is required * for the reason described in the given {@code message}. - * * @param message the message */ public FieldTypeRequiredException(String message) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypesDoNotMatchException.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypesDoNotMatchException.java index cfb8667a..3090ba95 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypesDoNotMatchException.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypesDoNotMatchException.java @@ -27,7 +27,6 @@ class FieldTypesDoNotMatchException extends RuntimeException { /** * Creates a new {@code FieldTypesDoNotMatchException} for the field described by the * given {@code fieldDescriptor} that has the given {@code actualType}. - * * @param fieldDescriptor the field * @param actualType the actual type of the field */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldProcessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldProcessor.java index 78b050ae..2742bc65 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldProcessor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldProcessor.java @@ -59,7 +59,7 @@ final class JsonFieldProcessor { throw new FieldDoesNotExistException(path); } return new ExtractedField( - compiledPath.getType() == PathType.SINGLE ? matches.get(0) : matches, + (compiledPath.getType() != PathType.SINGLE) ? matches : matches.get(0), compiledPath.getType()); } @@ -182,7 +182,7 @@ final class JsonFieldProcessor { @Override public void foundMatch(Match match) { this.matchType = this.matchType.combinedWith( - match.getValue() == null ? MatchType.NULL : MatchType.NON_NULL); + (match.getValue() != null) ? MatchType.NON_NULL : MatchType.NULL); } @Override @@ -408,7 +408,7 @@ final class JsonFieldProcessor { List segments, Match parent) { this.payload = payload; this.path = path; - this.segments = segments == null ? path.getSegments() : segments; + this.segments = (segments != null) ? segments : path.getSegments(); this.parent = parent; } diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadDocumentation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadDocumentation.java index 7ecbf9eb..1d330c3f 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadDocumentation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadDocumentation.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. @@ -94,8 +94,7 @@ public abstract class PayloadDocumentation { * The string "three" * * - * - * @param path The path of the field + * @param path the path of the field * @return a {@code FieldDescriptor} ready for further configuration */ public static FieldDescriptor fieldWithPath(String path) { @@ -162,8 +161,7 @@ public abstract class PayloadDocumentation { *

* A subsection descriptor for the array with the path {@code a.b[]} will also * describe its descendants {@code a.b[].c} and {@code a.b[].d}. - * - * @param path The path of the subsection + * @param path the path of the subsection * @return a {@code SubsectionDescriptor} ready for further configuration */ public static SubsectionDescriptor subsectionWithPath(String path) { @@ -185,7 +183,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields * @see #fieldWithPath(String) @@ -211,7 +208,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields * @see #fieldWithPath(String) @@ -227,7 +223,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields * @see #fieldWithPath(String) @@ -244,7 +239,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields * @see #fieldWithPath(String) @@ -271,7 +265,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param attributes the attributes * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields @@ -299,7 +292,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param attributes the attributes * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields @@ -318,7 +310,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param attributes the attributes * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields @@ -337,7 +328,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param attributes the attributes * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields @@ -366,7 +356,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields @@ -398,7 +387,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields @@ -420,7 +408,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields @@ -442,7 +429,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the request payload's fields * @return the snippet that will document the fields @@ -475,7 +461,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param subsectionExtractor the subsection extractor * @param attributes the attributes * @param descriptors the descriptions of the request payload's fields @@ -509,7 +494,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param subsectionExtractor the subsection extractor * @param attributes the attributes * @param descriptors the descriptions of the request payload's fields @@ -533,7 +517,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param subsectionExtractor the subsection extractor * @param attributes the attributes * @param descriptors the descriptions of the request payload's fields @@ -558,7 +541,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param subsectionExtractor the subsection extractor * @param attributes the attributes * @param descriptors the descriptions of the request payload's fields @@ -592,7 +574,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param part the part name * @param descriptors the descriptions of the request part's fields * @return the snippet that will document the fields @@ -622,7 +603,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param part the part name * @param descriptors the descriptions of the request part's fields * @return the snippet that will document the fields @@ -641,7 +621,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param part the part name * @param descriptors the descriptions of the request part's fields * @return the snippet that will document the fields @@ -660,7 +639,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param part the part name * @param descriptors the descriptions of the request part's fields * @return the snippet that will document the fields @@ -690,7 +668,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param part the part name * @param attributes the attributes * @param descriptors the descriptions of the request part's fields @@ -721,7 +698,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param part the part name * @param attributes the attributes * @param descriptors the descriptions of the request part's fields @@ -742,7 +718,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param part the part name * @param attributes the attributes * @param descriptors the descriptions of the request part's fields @@ -763,7 +738,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param part the part name * @param attributes the attributes * @param descriptors the descriptions of the request part's fields @@ -794,7 +768,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param part the part name * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the subsection's fields @@ -828,7 +801,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param part the part name * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the subsection's fields @@ -852,7 +824,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param part the part name * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the request part's fields @@ -877,7 +848,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param part the part name * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the request part's fields @@ -912,7 +882,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param part the part name * @param subsectionExtractor the subsection extractor * @param attributes the attributes @@ -949,7 +918,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param part the part name * @param subsectionExtractor the subsection extractor * @param attributes the attributes @@ -976,7 +944,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param part the part name * @param subsectionExtractor the subsection extractor * @param attributes the attributes @@ -1003,7 +970,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param part the part name * @param subsectionExtractor the subsection extractor * @param attributes the attributes @@ -1037,7 +1003,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields * @see #fieldWithPath(String) @@ -1063,7 +1028,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields * @since 1.2.0 @@ -1083,7 +1047,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields * @since 1.2.0 @@ -1103,7 +1066,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields * @see #fieldWithPath(String) @@ -1130,7 +1092,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param attributes the attributes * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields @@ -1158,7 +1119,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param attributes the attributes * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields @@ -1177,7 +1137,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param attributes the attributes * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields @@ -1196,7 +1155,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param attributes the attributes * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields @@ -1226,7 +1184,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields @@ -1259,7 +1216,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields @@ -1282,7 +1238,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields @@ -1305,7 +1260,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptions of the response payload's fields * @return the snippet that will document the fields @@ -1339,7 +1293,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param subsectionExtractor the subsection extractor * @param attributes the attributes * @param descriptors the descriptions of the response payload's fields @@ -1375,7 +1328,6 @@ public abstract class PayloadDocumentation { * {@link FieldDescriptor#ignored configured to ignore it}. The ignored field or * subsection will not appear in the generated snippet and the failure described above * will not occur. - * * @param subsectionExtractor the subsection extractor * @param attributes the attributes * @param descriptors the descriptions of the response payload's fields @@ -1400,7 +1352,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param subsectionExtractor the subsection extractor * @param attributes the attributes * @param descriptors the descriptions of the response payload's fields @@ -1426,7 +1377,6 @@ public abstract class PayloadDocumentation { *

* If a field is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented fields will be ignored. - * * @param subsectionExtractor the subsection extractor * @param attributes the attributes * @param descriptors the descriptions of the response payload's fields @@ -1446,7 +1396,6 @@ public abstract class PayloadDocumentation { /** * Returns a {@code Snippet} that will document the body of the API operation's * request payload. - * * @return the snippet that will document the request body */ public static RequestBodySnippet requestBody() { @@ -1457,7 +1406,6 @@ public abstract class PayloadDocumentation { * Returns a {@code Snippet} that will document the body of the API operation's * request payload. The given attributes will be made available during snippet * generation. - * * @param attributes the attributes * @return the snippet that will document the request body */ @@ -1469,7 +1417,6 @@ public abstract class PayloadDocumentation { * Returns a {@code Snippet} that will document a subsection of the body of the API * operation's request payload. The subsection will be extracted using the given * {@code subsectionExtractor}. - * * @param subsectionExtractor the subsection extractor * @return the snippet that will document the request body subsection */ @@ -1483,7 +1430,6 @@ public abstract class PayloadDocumentation { * operation's request payload. The subsection will be extracted using the given * {@code subsectionExtractor}. The given attributes will be made available during * snippet generation. - * * @param subsectionExtractor the subsection extractor * @param attributes the attributes * @return the snippet that will document the request body subsection @@ -1497,7 +1443,6 @@ public abstract class PayloadDocumentation { /** * Returns a {@code Snippet} that will document the body of the API operation's * response payload. - * * @return the snippet that will document the response body */ public static ResponseBodySnippet responseBody() { @@ -1508,7 +1453,6 @@ public abstract class PayloadDocumentation { * Returns a {@code Snippet} that will document the body of the API operation's * response payload. The given attributes will be made available during snippet * generation. - * * @param attributes the attributes * @return the snippet that will document the response body */ @@ -1520,7 +1464,6 @@ public abstract class PayloadDocumentation { * Returns a {@code Snippet} that will document a subsection of the body of the API * operation's response payload. The subsection will be extracted using the given * {@code subsectionExtractor}. - * * @param subsectionExtractor the subsection extractor * @return the snippet that will document the response body subsection */ @@ -1534,7 +1477,6 @@ public abstract class PayloadDocumentation { * operation's response payload. The subsection will be extracted using the given * {@code subsectionExtractor}. The given attributes will be made available during * snippet generation. - * * @param subsectionExtractor the subsection extractor * @param attributes the attributes * @return the snippet that will document the response body subsection @@ -1548,7 +1490,6 @@ public abstract class PayloadDocumentation { /** * Returns a {@code Snippet} that will document the body of specified part of the API * operation's request payload. - * * @param partName the name of the request part * @return the snippet that will document the response body */ @@ -1560,7 +1501,6 @@ public abstract class PayloadDocumentation { * Returns a {@code Snippet} that will document the body of specified part of the API * operation's request payload. The given attributes will be made available during * snippet generation. - * * @param partName the name of the request part * @param attributes the attributes * @return the snippet that will document the response body @@ -1574,7 +1514,6 @@ public abstract class PayloadDocumentation { * Returns a {@code Snippet} that will document a subsection of the body of specified * part of the API operation's request payload. The subsection will be extracted using * the given {@code subsectionExtractor}. - * * @param partName the name of the request part * @param subsectionExtractor the subsection extractor * @return the snippet that will document the response body @@ -1589,7 +1528,6 @@ public abstract class PayloadDocumentation { * part of the API operation's request payload. The subsection will be extracted using * the given {@code subsectionExtractor}. The given attributes will be made available * during snippet generation. - * * @param partName the name of the request part * @param subsectionExtractor the subsection extractor * @param attributes the attributes @@ -1604,7 +1542,6 @@ public abstract class PayloadDocumentation { /** * Creates a copy of the given {@code descriptors} with the given {@code pathPrefix} * applied to their paths. - * * @param pathPrefix the path prefix * @param descriptors the descriptors to copy * @return the copied descriptors with the prefix applied @@ -1614,7 +1551,7 @@ public abstract class PayloadDocumentation { List prefixedDescriptors = new ArrayList<>(); for (FieldDescriptor descriptor : descriptors) { String prefixedPath = pathPrefix + descriptor.getPath(); - FieldDescriptor prefixedDescriptor = descriptor instanceof SubsectionDescriptor + FieldDescriptor prefixedDescriptor = (descriptor instanceof SubsectionDescriptor) ? new SubsectionDescriptor(prefixedPath) : new FieldDescriptor(prefixedPath); prefixedDescriptor.description(descriptor.getDescription()) @@ -1634,7 +1571,6 @@ public abstract class PayloadDocumentation { /** * Returns a {@link PayloadSubsectionExtractor} that will extract the subsection of * the JSON payload found beneath the given {@code path}. - * * @param path the path * @return the subsection extractor * @since 1.2.0 diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadHandlingException.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadHandlingException.java index 6619f5ae..38bc2bf0 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadHandlingException.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadHandlingException.java @@ -27,7 +27,6 @@ class PayloadHandlingException extends RuntimeException { /** * Creates a new {@code PayloadHandlingException} with the given {@code message}. - * * @param message the message * @since 1.2.0 */ @@ -37,7 +36,6 @@ class PayloadHandlingException extends RuntimeException { /** * Creates a new {@code PayloadHandlingException} with the given {@code cause}. - * * @param cause the cause of the failure */ PayloadHandlingException(Throwable cause) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadSubsectionExtractor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadSubsectionExtractor.java index c69989ba..19fbf1b9 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadSubsectionExtractor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadSubsectionExtractor.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. @@ -21,7 +21,7 @@ import org.springframework.http.MediaType; /** * Strategy interface for extracting a subsection of a payload. * - * @param The subsection extractor subclass + * @param the subsection extractor subclass * @author Andy Wilkinson * @since 1.2.0 */ @@ -30,7 +30,6 @@ public interface PayloadSubsectionExtractor subsectionExtractor) { @@ -50,8 +49,7 @@ public class RequestBodySnippet extends AbstractBodySnippet { /** * Creates a new {@code RequestBodySnippet} with the given additional * {@code attributes} that will be included in the model during template rendering. - * - * @param attributes The additional attributes + * @param attributes the additional attributes */ public RequestBodySnippet(Map attributes) { this(null, attributes); @@ -62,9 +60,8 @@ public class RequestBodySnippet extends AbstractBodySnippet { * request body extracted by the given {@code subsectionExtractor}. The given * additional {@code attributes} that will be included in the model during template * rendering. - * * @param subsectionExtractor the subsection extractor - * @param attributes The additional attributes + * @param attributes the additional attributes */ public RequestBodySnippet(PayloadSubsectionExtractor subsectionExtractor, Map attributes) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestFieldsSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestFieldsSnippet.java index bc8b8f7c..0a3f75f0 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestFieldsSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestFieldsSnippet.java @@ -39,7 +39,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * Creates a new {@code RequestFieldsSnippet} that will document the fields in the * request using the given {@code descriptors}. Undocumented fields will trigger a * failure. - * * @param descriptors the descriptors */ protected RequestFieldsSnippet(List descriptors) { @@ -50,7 +49,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * Creates a new {@code RequestFieldsSnippet} that will document the fields in the * request using the given {@code descriptors}. If {@code ignoreUndocumentedFields} is * {@code true}, undocumented fields will be ignored and will not trigger a failure. - * * @param descriptors the descriptors * @param ignoreUndocumentedFields whether undocumented fields should be ignored */ @@ -64,7 +62,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * request using the given {@code descriptors}. The given {@code attributes} will be * included in the model during template rendering. Undocumented fields will trigger a * failure. - * * @param descriptors the descriptors * @param attributes the additional attributes */ @@ -79,7 +76,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * included in the model during template rendering. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param descriptors the descriptors * @param attributes the additional attributes * @param ignoreUndocumentedFields whether undocumented fields should be ignored @@ -93,7 +89,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * Creates a new {@code RequestFieldsSnippet} that will document the fields in the * subsection of the request extracted by the given {@code subsectionExtractor} using * the given {@code descriptors}. Undocumented fields will trigger a failure. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptors * @since 1.2.0 @@ -108,7 +103,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * subsection of the request extracted by the given {@code subsectionExtractor} using * the given {@code descriptors}. If {@code ignoreUndocumentedFields} is {@code true}, * undocumented fields will be ignored and will not trigger a failure. - * * @param subsectionExtractor the subsection extractor document * @param descriptors the descriptors * @param ignoreUndocumentedFields whether undocumented fields should be ignored @@ -124,7 +118,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * subsection of the request extracted by the given {@code subsectionExtractor} using * the given {@code descriptors}. The given {@code attributes} will be included in the * model during template rendering. Undocumented fields will trigger a failure. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptors * @param attributes the additional attributes @@ -141,7 +134,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * the given {@code descriptors}. The given {@code attributes} will be included in the * model during template rendering. If {@code ignoreUndocumentedFields} is * {@code true}, undocumented fields will be ignored and will not trigger a failure. - * * @param subsectionExtractor the path identifying the subsection of the payload to * document * @param descriptors the descriptors @@ -170,7 +162,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * Returns a new {@code RequestFieldsSnippet} configured with this snippet's * attributes and its descriptors combined with the given * {@code additionalDescriptors}. - * * @param additionalDescriptors the additional descriptors * @return the new snippet */ @@ -182,7 +173,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * Returns a new {@code RequestFieldsSnippet} configured with this snippet's * attributes and its descriptors combined with the given * {@code additionalDescriptors}. - * * @param additionalDescriptors the additional descriptors * @return the new snippet */ @@ -195,7 +185,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * attributes and its descriptors combined with the given * {@code additionalDescriptors}. The given {@code pathPrefix} is applied to the path * of each additional descriptor. - * * @param pathPrefix the prefix to apply to the additional descriptors * @param additionalDescriptors the additional descriptors * @return the new snippet @@ -215,7 +204,6 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * attributes and its descriptors combined with the given * {@code additionalDescriptors}. The given {@code pathPrefix} is applied to the path * of each additional descriptor. - * * @param pathPrefix the prefix to apply to the additional descriptors * @param additionalDescriptors the additional descriptors * @return the new snippet diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestPartBodySnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestPartBodySnippet.java index 0e5ec324..798ebca7 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestPartBodySnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestPartBodySnippet.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. @@ -37,7 +37,6 @@ public class RequestPartBodySnippet extends AbstractBodySnippet { /** * Creates a new {@code RequestPartBodySnippet} that will document the body of the * request part with the given {@code partName}. - * * @param partName the name of the request part */ public RequestPartBodySnippet(String partName) { @@ -48,7 +47,6 @@ public class RequestPartBodySnippet extends AbstractBodySnippet { * Creates a new {@code RequestPartBodySnippet} that will document the subsection of * the body of the request part with the given {@code partName} extracted by the given * {@code subsectionExtractor}. - * * @param partName the name of the request part * @param subsectionExtractor the subsection extractor */ @@ -61,7 +59,6 @@ public class RequestPartBodySnippet extends AbstractBodySnippet { * Creates a new {@code RequestPartBodySnippet} that will document the body of the * request part with the given {@code partName}. The given additional * {@code attributes} will be included in the model during template rendering. - * * @param partName the name of the request part * @param attributes the additional attributes */ @@ -75,10 +72,9 @@ public class RequestPartBodySnippet extends AbstractBodySnippet { * by the given {@code subsectionExtractor} will be documented and the given * additional {@code attributes} that will be included in the model during template * rendering. - * * @param partName the name of the request part * @param subsectionExtractor the subsection extractor - * @param attributes The additional attributes + * @param attributes the additional attributes */ public RequestPartBodySnippet(String partName, PayloadSubsectionExtractor subsectionExtractor, diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestPartFieldsSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestPartFieldsSnippet.java index 1eb5205d..6d831938 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestPartFieldsSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/RequestPartFieldsSnippet.java @@ -45,7 +45,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * Creates a new {@code RequestPartFieldsSnippet} that will document the fields in the * request part using the given {@code descriptors}. Undocumented fields will trigger * a failure. - * * @param partName the part name * @param descriptors the descriptors */ @@ -59,7 +58,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * request part using the given {@code descriptors}. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param partName the part name * @param descriptors the descriptors * @param ignoreUndocumentedFields whether undocumented fields should be ignored @@ -74,7 +72,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * request using the given {@code descriptors}. The given {@code attributes} will be * included in the model during template rendering. Undocumented fields will trigger a * failure. - * * @param partName the part name * @param descriptors the descriptors * @param attributes the additional attributes @@ -90,7 +87,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * included in the model during template rendering. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param partName the part name * @param descriptors the descriptors * @param attributes the additional attributes @@ -106,7 +102,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * subsection of the request part using the given {@code descriptors}. The subsection * will be extracted using the given {@code subsectionExtractor}. Undocumented fields * will trigger a failure. - * * @param partName the part name * @param subsectionExtractor the subsection extractor * @param descriptors the descriptors @@ -123,7 +118,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * will be extracted using the given {@code subsectionExtractor}. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param partName the part name * @param subsectionExtractor the subsection extractor * @param descriptors the descriptors @@ -141,7 +135,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * will be extracted using the given {@code subsectionExtractor}. The given * {@code attributes} will be included in the model during template rendering. * Undocumented fields will trigger a failure. - * * @param partName the part name * @param subsectionExtractor the subsection extractor * @param descriptors the descriptors @@ -160,7 +153,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * {@code attributes} will be included in the model during template rendering. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param partName the part name * @param subsectionExtractor the subsection extractor * @param descriptors the descriptors @@ -200,7 +192,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * Returns a new {@code RequestPartFieldsSnippet} configured with this snippet's * attributes and its descriptors combined with the given * {@code additionalDescriptors}. - * * @param additionalDescriptors the additional descriptors * @return the new snippet */ @@ -212,7 +203,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * Returns a new {@code RequestPartFieldsSnippet} configured with this snippet's * attributes and its descriptors combined with the given * {@code additionalDescriptors}. - * * @param additionalDescriptors the additional descriptors * @return the new snippet */ @@ -226,7 +216,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * attributes and its descriptors combined with the given * {@code additionalDescriptors}. The given {@code pathPrefix} is applied to the path * of each additional descriptor. - * * @param pathPrefix the prefix to apply to the additional descriptors * @param additionalDescriptors the additional descriptors * @return the new snippet @@ -246,7 +235,6 @@ public class RequestPartFieldsSnippet extends AbstractFieldsSnippet { * attributes and its descriptors combined with the given * {@code additionalDescriptors}. The given {@code pathPrefix} is applied to the path * of each additional descriptor. - * * @param pathPrefix the prefix to apply to the additional descriptors * @param additionalDescriptors the additional descriptors * @return the new snippet diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ResponseBodySnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ResponseBodySnippet.java index d0dbe140..a4a0b362 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ResponseBodySnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ResponseBodySnippet.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. @@ -40,7 +40,6 @@ public class ResponseBodySnippet extends AbstractBodySnippet { /** * Creates a new {@code ResponseBodySnippet} that will document the subsection of the * response body extracted by the given {@code subsectionExtractor}. - * * @param subsectionExtractor the subsection extractor */ public ResponseBodySnippet(PayloadSubsectionExtractor subsectionExtractor) { @@ -50,8 +49,7 @@ public class ResponseBodySnippet extends AbstractBodySnippet { /** * Creates a new {@code ResponseBodySnippet} with the given additional * {@code attributes} that will be included in the model during template rendering. - * - * @param attributes The additional attributes + * @param attributes the additional attributes */ public ResponseBodySnippet(Map attributes) { this(null, attributes); @@ -62,9 +60,8 @@ public class ResponseBodySnippet extends AbstractBodySnippet { * response body extracted by the given {@code subsectionExtractor}. The given * additional {@code attributes} that will be included in the model during template * rendering. - * * @param subsectionExtractor the subsection extractor - * @param attributes The additional attributes + * @param attributes the additional attributes */ public ResponseBodySnippet(PayloadSubsectionExtractor subsectionExtractor, Map attributes) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ResponseFieldsSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ResponseFieldsSnippet.java index 144e468d..45b5be15 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ResponseFieldsSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ResponseFieldsSnippet.java @@ -39,7 +39,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * Creates a new {@code ResponseFieldsSnippet} that will document the fields in the * response using the given {@code descriptors}. Undocumented fields will trigger a * failure. - * * @param descriptors the descriptors */ protected ResponseFieldsSnippet(List descriptors) { @@ -51,7 +50,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * response using the given {@code descriptors}. If {@code ignoreUndocumentedFields} * is {@code true}, undocumented fields will be ignored and will not trigger a * failure. - * * @param descriptors the descriptors * @param ignoreUndocumentedFields whether undocumented fields should be ignored */ @@ -65,7 +63,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * response using the given {@code descriptors}. The given {@code attributes} will be * included in the model during template rendering. Undocumented fields will trigger a * failure. - * * @param descriptors the descriptors * @param attributes the additional attributes */ @@ -80,7 +77,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * included in the model during template rendering. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param descriptors the descriptors * @param attributes the additional attributes * @param ignoreUndocumentedFields whether undocumented fields should be ignored @@ -95,7 +91,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * subsection of the response using the given {@code descriptors}. The subsection will * be extracted using the given {@code subsectionExtractor}. Undocumented fields will * trigger a failure. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptors * @since 1.2.0 @@ -111,7 +106,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * be extracted using the given {@code subsectionExtractor}. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptors * @param ignoreUndocumentedFields whether undocumented fields should be ignored @@ -128,7 +122,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * be extracted using the given {@code subsectionExtractor}. The given * {@code attributes} will be included in the model during template rendering. * Undocumented fields will trigger a failure. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptors * @param attributes the additional attributes @@ -146,7 +139,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * {@code attributes} will be included in the model during template rendering. If * {@code ignoreUndocumentedFields} is {@code true}, undocumented fields will be * ignored and will not trigger a failure. - * * @param subsectionExtractor the subsection extractor * @param descriptors the descriptors * @param attributes the additional attributes @@ -174,7 +166,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * Returns a new {@code ResponseFieldsSnippet} configured with this snippet's * attributes and its descriptors combined with the given * {@code additionalDescriptors}. - * * @param additionalDescriptors the additional descriptors * @return the new snippet */ @@ -186,7 +177,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * Returns a new {@code ResponseFieldsSnippet} configured with this snippet's * attributes and its descriptors combined with the given * {@code additionalDescriptors}. - * * @param additionalDescriptors the additional descriptors * @return the new snippet */ @@ -199,7 +189,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * attributes and its descriptors combined with the given * {@code additionalDescriptors}. The given {@code pathPrefix} is applied to the path * of each additional descriptor. - * * @param pathPrefix the prefix to apply to the additional descriptors * @param additionalDescriptors the additional descriptors * @return the new snippet @@ -219,7 +208,6 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * attributes and its descriptors combined with the given * {@code additionalDescriptors}. The given {@code pathPrefix} is applied to the path * of each additional descriptor. - * * @param pathPrefix the prefix to apply to the additional descriptors * @param additionalDescriptors the additional descriptors * @return the new snippet diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/AbstractParametersSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/AbstractParametersSnippet.java index 31d2913e..1e30e8a8 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/AbstractParametersSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/AbstractParametersSnippet.java @@ -48,10 +48,9 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet { * the given {@code snippetName} that will document parameters using the given * {@code descriptors}. The given {@code attributes} will be included in the model * during template rendering. Undocumented parameters will trigger a failure. - * - * @param snippetName The snippet name - * @param descriptors The descriptors - * @param attributes The additional attributes + * @param snippetName the snippet name + * @param descriptors the descriptors + * @param attributes the additional attributes * @deprecated since 1.1 in favour of * {@link #AbstractParametersSnippet(String, List, Map, boolean)} */ @@ -67,10 +66,9 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet { * {@code descriptors}. The given {@code attributes} will be included in the model * during template rendering. If {@code ignoreUndocumentedParameters} is {@code true}, * undocumented parameters will be ignored and will not trigger a failure. - * - * @param snippetName The snippet name - * @param descriptors The descriptors - * @param attributes The additional attributes + * @param snippetName the snippet name + * @param descriptors the descriptors + * @param attributes the additional attributes * @param ignoreUndocumentedParameters whether undocumented parameters should be * ignored */ @@ -137,7 +135,6 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet { /** * Extracts the names of the parameters that were present in the given * {@code operation}. - * * @param operation the operation * @return the parameters */ @@ -145,7 +142,6 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet { /** * Called when the documented parameters do not match the actual parameters. - * * @param undocumentedParameters the parameters that were found in the operation but * were not documented * @param missingParameters the parameters that were documented but were not found in @@ -158,7 +154,6 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet { * Returns a {@code Map} of {@link ParameterDescriptor ParameterDescriptors} that will * be used to generate the documentation key by their * {@link ParameterDescriptor#getName()}. - * * @return the map of path descriptors * @deprecated since 1.1.0 in favor of {@link #getParameterDescriptors()} */ @@ -171,7 +166,6 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet { * Returns a {@code Map} of {@link ParameterDescriptor ParameterDescriptors} that will * be used to generate the documentation key by their * {@link ParameterDescriptor#getName()}. - * * @return the map of path descriptors */ protected final Map getParameterDescriptors() { @@ -180,7 +174,6 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet { /** * Returns a model for the given {@code descriptor}. - * * @param descriptor the descriptor * @return the model */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/ParameterDescriptor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/ParameterDescriptor.java index d19eab4f..24b48b96 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/ParameterDescriptor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/ParameterDescriptor.java @@ -34,7 +34,6 @@ public class ParameterDescriptor extends IgnorableDescriptor descriptors) { @@ -58,7 +57,6 @@ public class PathParametersSnippet extends AbstractParametersSnippet { * parameters using the given {@code descriptors}. If * {@code ignoreUndocumentedParameters} is {@code true}, undocumented parameters will * be ignored and will not trigger a failure. - * * @param descriptors the parameter descriptors * @param ignoreUndocumentedParameters whether undocumented parameters should be * ignored @@ -73,7 +71,6 @@ public class PathParametersSnippet extends AbstractParametersSnippet { * parameters using the given {@code descriptors}. The given {@code attributes} will * be included in the model during template rendering. Undocumented parameters will * trigger a failure. - * * @param descriptors the parameter descriptors * @param attributes the additional attributes */ @@ -88,7 +85,6 @@ public class PathParametersSnippet extends AbstractParametersSnippet { * be included in the model during template rendering. If * {@code ignoreUndocumentedParameters} is {@code true}, undocumented parameters will * be ignored and will not trigger a failure. - * * @param descriptors the parameter descriptors * @param attributes the additional attributes * @param ignoreUndocumentedParameters whether undocumented parameters should be @@ -136,7 +132,7 @@ public class PathParametersSnippet extends AbstractParametersSnippet { private static String getParameterName(String match) { int colonIndex = match.indexOf(':'); - return colonIndex != -1 ? match.substring(0, colonIndex) : match; + return (colonIndex != -1) ? match.substring(0, colonIndex) : match; } @Override diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestDocumentation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestDocumentation.java index 043fdfe6..e7a66969 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestDocumentation.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestDocumentation.java @@ -37,8 +37,7 @@ public abstract class RequestDocumentation { /** * Creates a {@link ParameterDescriptor} that describes a request or path parameter * with the given {@code name}. - * - * @param name The name of the parameter + * @param name the name of the parameter * @return a {@link ParameterDescriptor} ready for further configuration */ public static ParameterDescriptor parameterWithName(String name) { @@ -48,8 +47,7 @@ public abstract class RequestDocumentation { /** * Creates a {@link RequestPartDescriptor} that describes a request part with the * given {@code name}. - * - * @param name The name of the request part + * @param name the name of the request part * @return a {@link RequestPartDescriptor} ready for further configuration */ public static RequestPartDescriptor partWithName(String name) { @@ -69,7 +67,6 @@ public abstract class RequestDocumentation { * If you do not want to document a path parameter, a parameter descriptor can be * marked as {@link ParameterDescriptor#ignored}. This will prevent it from appearing * in the generated snippet while avoiding the failure described above. - * * @param descriptors the descriptions of the parameters in the request's path * @return the snippet that will document the parameters */ @@ -91,7 +88,6 @@ public abstract class RequestDocumentation { * If you do not want to document a path parameter, a parameter descriptor can be * marked as {@link ParameterDescriptor#ignored}. This will prevent it from appearing * in the generated snippet while avoiding the failure described above. - * * @param descriptors the descriptions of the parameters in the request's path * @return the snippet that will document the parameters */ @@ -107,7 +103,6 @@ public abstract class RequestDocumentation { *

* If a parameter is documented, is not marked as optional, and is not present in the * response, a failure will occur. Any undocumented parameters will be ignored. - * * @param descriptors the descriptions of the parameters in the request's path * @return the snippet that will document the parameters */ @@ -123,7 +118,6 @@ public abstract class RequestDocumentation { *

* If a parameter is documented, is not marked as optional, and is not present in the * response, a failure will occur. Any undocumented parameters will be ignored. - * * @param descriptors the descriptions of the parameters in the request's path * @return the snippet that will document the parameters */ @@ -146,7 +140,6 @@ public abstract class RequestDocumentation { * If you do not want to document a path parameter, a parameter descriptor can be * marked as {@link ParameterDescriptor#ignored}. This will prevent it from appearing * in the generated snippet while avoiding the failure described above. - * * @param attributes the attributes * @param descriptors the descriptions of the parameters in the request's path * @return the snippet that will document the parameters @@ -170,7 +163,6 @@ public abstract class RequestDocumentation { * If you do not want to document a path parameter, a parameter descriptor can be * marked as {@link ParameterDescriptor#ignored}. This will prevent it from appearing * in the generated snippet while avoiding the failure described above. - * * @param attributes the attributes * @param descriptors the descriptions of the parameters in the request's path * @return the snippet that will document the parameters @@ -188,7 +180,6 @@ public abstract class RequestDocumentation { *

* If a parameter is documented, is not marked as optional, and is not present in the * response, a failure will occur. Any undocumented parameters will be ignored. - * * @param attributes the attributes * @param descriptors the descriptions of the parameters in the request's path * @return the snippet that will document the parameters @@ -206,7 +197,6 @@ public abstract class RequestDocumentation { *

* If a parameter is documented, is not marked as optional, and is not present in the * response, a failure will occur. Any undocumented parameters will be ignored. - * * @param attributes the attributes * @param descriptors the descriptions of the parameters in the request's path * @return the snippet that will document the parameters @@ -229,8 +219,7 @@ public abstract class RequestDocumentation { * If you do not want to document a request parameter, a parameter descriptor can be * marked as {@link ParameterDescriptor#ignored}. This will prevent it from appearing * in the generated snippet while avoiding the failure described above. - * - * @param descriptors The descriptions of the request's parameters + * @param descriptors the descriptions of the request's parameters * @return the snippet * @see OperationRequest#getParameters() */ @@ -252,8 +241,7 @@ public abstract class RequestDocumentation { * If you do not want to document a request parameter, a parameter descriptor can be * marked as {@link ParameterDescriptor#ignored}. This will prevent it from appearing * in the generated snippet while avoiding the failure described above. - * - * @param descriptors The descriptions of the request's parameters + * @param descriptors the descriptions of the request's parameters * @return the snippet * @see OperationRequest#getParameters() */ @@ -269,8 +257,7 @@ public abstract class RequestDocumentation { *

* If a parameter is documented, is not marked as optional, and is not present in the * response, a failure will occur. Any undocumented parameters will be ignored. - * - * @param descriptors The descriptions of the request's parameters + * @param descriptors the descriptions of the request's parameters * @return the snippet * @see OperationRequest#getParameters() */ @@ -286,8 +273,7 @@ public abstract class RequestDocumentation { *

* If a parameter is documented, is not marked as optional, and is not present in the * response, a failure will occur. Any undocumented parameters will be ignored. - * - * @param descriptors The descriptions of the request's parameters + * @param descriptors the descriptions of the request's parameters * @return the snippet * @see OperationRequest#getParameters() */ @@ -310,7 +296,6 @@ public abstract class RequestDocumentation { * If you do not want to document a request parameter, a parameter descriptor can be * marked as {@link ParameterDescriptor#ignored}. This will prevent it from appearing * in the generated snippet while avoiding the failure described above. - * * @param attributes the attributes * @param descriptors the descriptions of the request's parameters * @return the snippet that will document the parameters @@ -335,7 +320,6 @@ public abstract class RequestDocumentation { * If you do not want to document a request parameter, a parameter descriptor can be * marked as {@link ParameterDescriptor#ignored}. This will prevent it from appearing * in the generated snippet while avoiding the failure described above. - * * @param attributes the attributes * @param descriptors the descriptions of the request's parameters * @return the snippet that will document the parameters @@ -354,7 +338,6 @@ public abstract class RequestDocumentation { *

* If a parameter is documented, is not marked as optional, and is not present in the * response, a failure will occur. Any undocumented parameters will be ignored. - * * @param attributes the attributes * @param descriptors the descriptions of the request's parameters * @return the snippet that will document the parameters @@ -373,7 +356,6 @@ public abstract class RequestDocumentation { *

* If a parameter is documented, is not marked as optional, and is not present in the * response, a failure will occur. Any undocumented parameters will be ignored. - * * @param attributes the attributes * @param descriptors the descriptions of the request's parameters * @return the snippet that will document the parameters @@ -396,8 +378,7 @@ public abstract class RequestDocumentation { * If you do not want to document a part, a part descriptor can be marked as * {@link RequestPartDescriptor#ignored}. This will prevent it from appearing in the * generated snippet while avoiding the failure described above. - * - * @param descriptors The descriptions of the request's parts + * @param descriptors the descriptions of the request's parts * @return the snippet * @see OperationRequest#getParts() */ @@ -417,8 +398,7 @@ public abstract class RequestDocumentation { * If you do not want to document a part, a part descriptor can be marked as * {@link RequestPartDescriptor#ignored}. This will prevent it from appearing in the * generated snippet while avoiding the failure described above. - * - * @param descriptors The descriptions of the request's parts + * @param descriptors the descriptions of the request's parts * @return the snippet * @see OperationRequest#getParts() */ @@ -433,8 +413,7 @@ public abstract class RequestDocumentation { *

* If a part is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented parts will be ignored. - * - * @param descriptors The descriptions of the request's parts + * @param descriptors the descriptions of the request's parts * @return the snippet * @see OperationRequest#getParts() */ @@ -449,8 +428,7 @@ public abstract class RequestDocumentation { *

* If a part is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented parts will be ignored. - * - * @param descriptors The descriptions of the request's parts + * @param descriptors the descriptions of the request's parts * @return the snippet * @see OperationRequest#getParts() */ @@ -472,7 +450,6 @@ public abstract class RequestDocumentation { * If you do not want to document a part, a part descriptor can be marked as * {@link RequestPartDescriptor#ignored}. This will prevent it from appearing in the * generated snippet while avoiding the failure described above. - * * @param attributes the attributes * @param descriptors the descriptions of the request's parts * @return the snippet @@ -496,7 +473,6 @@ public abstract class RequestDocumentation { * If you do not want to document a part, a part descriptor can be marked as * {@link RequestPartDescriptor#ignored}. This will prevent it from appearing in the * generated snippet while avoiding the failure described above. - * * @param attributes the attributes * @param descriptors the descriptions of the request's parts * @return the snippet @@ -514,7 +490,6 @@ public abstract class RequestDocumentation { *

* If a part is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented parts will be ignored. - * * @param attributes the attributes * @param descriptors the descriptions of the request's parts * @return the snippet @@ -532,7 +507,6 @@ public abstract class RequestDocumentation { *

* If a part is documented, is not marked as optional, and is not present in the * request, a failure will occur. Any undocumented parts will be ignored. - * * @param attributes the attributes * @param descriptors the descriptions of the request's parts * @return the snippet diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestParametersSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestParametersSnippet.java index 1fa21bf7..acfaec9b 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestParametersSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestParametersSnippet.java @@ -44,7 +44,6 @@ public class RequestParametersSnippet extends AbstractParametersSnippet { * Creates a new {@code RequestParametersSnippet} that will document the request's * parameters using the given {@code descriptors}. Undocumented parameters will * trigger a failure. - * * @param descriptors the parameter descriptors */ protected RequestParametersSnippet(List descriptors) { @@ -56,7 +55,6 @@ public class RequestParametersSnippet extends AbstractParametersSnippet { * parameters using the given {@code descriptors}. If * {@code ignoreUndocumentedParameters} is {@code true}, undocumented parameters will * be ignored and will not trigger a failure. - * * @param descriptors the parameter descriptors * @param ignoreUndocumentedParameters whether undocumented parameters should be * ignored @@ -71,7 +69,6 @@ public class RequestParametersSnippet extends AbstractParametersSnippet { * parameters using the given {@code descriptors}. The given {@code attributes} will * be included in the model during template rendering. Undocumented parameters will * trigger a failure. - * * @param descriptors the parameter descriptors * @param attributes the additional attributes */ @@ -86,7 +83,6 @@ public class RequestParametersSnippet extends AbstractParametersSnippet { * be included in the model during template rendering. If * {@code ignoreUndocumentedParameters} is {@code true}, undocumented parameters will * be ignored and will not trigger a failure. - * * @param descriptors the parameter descriptors * @param attributes the additional attributes * @param ignoreUndocumentedParameters whether undocumented parameters should be diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestPartDescriptor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestPartDescriptor.java index 5ca4e68b..f3e2754f 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestPartDescriptor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/RequestPartDescriptor.java @@ -34,7 +34,6 @@ public class RequestPartDescriptor extends IgnorableDescriptor descriptors) { @@ -64,7 +63,6 @@ public class RequestPartsSnippet extends TemplatedSnippet { * Creates a new {@code RequestPartsSnippet} that will document the request's parts * using the given {@code descriptors}. If {@code ignoreUndocumentedParts} is * {@code true}, undocumented parts will be ignored and will not trigger a failure. - * * @param descriptors the parameter descriptors * @param ignoreUndocumentedParts whether undocumented parts should be ignored */ @@ -77,7 +75,6 @@ public class RequestPartsSnippet extends TemplatedSnippet { * Creates a new {@code RequestPartsSnippet} that will document the request's parts * using the given {@code descriptors}. The given {@code attributes} will be included * in the model during template rendering. Undocumented parts will trigger a failure. - * * @param descriptors the parameter descriptors * @param attributes the additional attributes */ @@ -91,7 +88,6 @@ public class RequestPartsSnippet extends TemplatedSnippet { * using the given {@code descriptors}. The given {@code attributes} will be included * in the model during template rendering. If {@code ignoreUndocumentedParts} is * {@code true}, undocumented parts will be ignored and will not trigger a failure. - * * @param descriptors the parameter descriptors * @param attributes the additional attributes * @param ignoreUndocumentedParts whether undocumented parts should be ignored diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/AbstractDescriptor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/AbstractDescriptor.java index a0b67a3a..700aa756 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/AbstractDescriptor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/AbstractDescriptor.java @@ -36,7 +36,6 @@ public abstract class AbstractDescriptor> { /** * Adds the given {@code attributes} to the descriptor. - * * @param attributes the attributes * @return the descriptor */ @@ -50,7 +49,6 @@ public abstract class AbstractDescriptor> { /** * Specifies the description. - * * @param description the description * @return the descriptor */ @@ -62,7 +60,6 @@ public abstract class AbstractDescriptor> { /** * Returns the description. - * * @return the description */ public final Object getDescription() { @@ -71,7 +68,6 @@ public abstract class AbstractDescriptor> { /** * Returns the descriptor's attributes. - * * @return the attributes */ public final Map getAttributes() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/Attributes.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/Attributes.java index b5f1a9c3..6c5606bb 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/Attributes.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/Attributes.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. @@ -33,9 +33,8 @@ public abstract class Attributes { /** * Creates an attribute with the given {@code key}. A value for the attribute must * still be specified. - * - * @param key The key of the attribute - * @return An {@code AttributeBuilder} to use to specify the value of the attribute + * @param key the key of the attribute + * @return an {@code AttributeBuilder} to use to specify the value of the attribute * @see AttributeBuilder#value(Object) */ public static AttributeBuilder key(String key) { @@ -44,9 +43,8 @@ public abstract class Attributes { /** * Creates a {@code Map} of the given {@code attributes}. - * - * @param attributes The attributes - * @return A Map of the attributes + * @param attributes the attributes + * @return a Map of the attributes */ public static Map attributes(Attribute... attributes) { Map attributeMap = new HashMap<>(); @@ -69,9 +67,8 @@ public abstract class Attributes { /** * Configures the value of the attribute. - * - * @param value The attribute's value - * @return A newly created {@code Attribute} + * @param value the attribute's value + * @return a newly created {@code Attribute} */ public Attribute value(Object value) { return new Attribute(this.key, value); @@ -90,7 +87,6 @@ public abstract class Attributes { /** * Creates a new attribute with the given {@code key} and {@code value}. - * * @param key the key * @param value the value */ @@ -101,7 +97,6 @@ public abstract class Attributes { /** * Returns the attribute's key. - * * @return the key */ public String getKey() { @@ -110,7 +105,6 @@ public abstract class Attributes { /** * Returns the attribute's value. - * * @return the value */ public Object getValue() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/IgnorableDescriptor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/IgnorableDescriptor.java index 477431ee..d1fef2c8 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/IgnorableDescriptor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/IgnorableDescriptor.java @@ -30,7 +30,6 @@ public abstract class IgnorableDescriptor> /** * Marks the described item as being ignored. Ignored items are not included in the * generated documentation. - * * @return the descriptor */ @SuppressWarnings("unchecked") @@ -42,7 +41,6 @@ public abstract class IgnorableDescriptor> /** * Returns whether or not the item being described should be ignored and, therefore, * should not be included in the documentation. - * * @return {@code true} if the item should be ignored, otherwise {@code false}. */ public final boolean isIgnored() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/ModelCreationException.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/ModelCreationException.java index 93c60192..92ac2f38 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/ModelCreationException.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/ModelCreationException.java @@ -28,7 +28,6 @@ public class ModelCreationException extends RuntimeException { /** * Creates a new {@code ModelCreationException} with the given {@code cause}. - * * @param cause the cause */ public ModelCreationException(Throwable cause) { @@ -38,7 +37,6 @@ public class ModelCreationException extends RuntimeException { /** * Creates a new {@code ModelCreationException} with the given {@code message} and * {@code cause}. - * * @param message the message * @param cause the cause */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/PlaceholderResolverFactory.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/PlaceholderResolverFactory.java index 5683346b..f32da531 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/PlaceholderResolverFactory.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/PlaceholderResolverFactory.java @@ -29,7 +29,6 @@ public interface PlaceholderResolverFactory { /** * Creates a new {@link PlaceholderResolver} using the given {@code context}. - * * @param context the context * @return the placeholder resolver */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolver.java index 81898c25..18ea5cd0 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolver.java @@ -58,7 +58,6 @@ public class RestDocumentationContextPlaceholderResolver implements PlaceholderR /** * Creates a new placeholder resolver that will resolve placeholders using the given * {@code context}. - * * @param context the context to use */ public RestDocumentationContextPlaceholderResolver(RestDocumentationContext context) { @@ -105,7 +104,6 @@ public class RestDocumentationContextPlaceholderResolver implements PlaceholderR /** * Converts the given {@code string} from camelCase to kebab-case. - * * @param string the string * @return the converted string */ @@ -115,7 +113,6 @@ public class RestDocumentationContextPlaceholderResolver implements PlaceholderR /** * Converts the given {@code string} from camelCase to snake_case. - * * @param string the string * @return the converted string */ @@ -126,7 +123,6 @@ public class RestDocumentationContextPlaceholderResolver implements PlaceholderR /** * Returns the {@link RestDocumentationContext} that should be used during placeholder * resolution. - * * @return the context */ protected final RestDocumentationContext getContext() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/Snippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/Snippet.java index a4309156..849f5987 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/Snippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/Snippet.java @@ -29,7 +29,6 @@ public interface Snippet { /** * Documents the call to the RESTful API described by the given {@code operation}. - * * @param operation the API operation * @throws IOException if a failure occurs will documenting the operation */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/SnippetException.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/SnippetException.java index 9928c352..0d1c3f64 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/SnippetException.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/SnippetException.java @@ -27,7 +27,6 @@ public class SnippetException extends RuntimeException { /** * Creates a new {@code SnippetException} described by the given {@code message}. - * * @param message the message that describes the problem */ public SnippetException(String message) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/StandardWriterResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/StandardWriterResolver.java index 51235a5e..437cdd2d 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/StandardWriterResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/StandardWriterResolver.java @@ -49,7 +49,6 @@ public final class StandardWriterResolver implements WriterResolver { * {@code placeholderResolver} to resolve any placeholders in the * {@code operationName}. Writers will use {@code UTF-8} encoding and, when writing to * a file, will use a filename appropriate for Asciidoctor content. - * * @param placeholderResolver the placeholder resolver * @deprecated since 1.1.0 in favor of * {@link #StandardWriterResolver(PlaceholderResolverFactory, String, TemplateFormat)} @@ -67,7 +66,6 @@ public final class StandardWriterResolver implements WriterResolver { * {@code operationName}. Writers will use the given {@code encoding} and, when * writing to a file, will use a filename appropriate for content generated from * templates in the given {@code templateFormat}. - * * @param placeholderResolverFactory the placeholder resolver factory * @param encoding the encoding * @param templateFormat the snippet format diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/TemplatedSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/TemplatedSnippet.java index cfb584fb..3951b1ee 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/TemplatedSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/TemplatedSnippet.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. @@ -45,9 +45,8 @@ public abstract class TemplatedSnippet implements Snippet { * {@code snippetName}. The {@code snippetName} will also be used as the name of the * template. The given {@code attributes} will be included in the model during * rendering of the template. - * - * @param snippetName The name of the snippet - * @param attributes The additional attributes + * @param snippetName the name of the snippet + * @param attributes the additional attributes * @see #TemplatedSnippet(String, String, Map) */ protected TemplatedSnippet(String snippetName, Map attributes) { @@ -58,10 +57,9 @@ public abstract class TemplatedSnippet implements Snippet { * Creates a new {@code TemplatedSnippet} that will produce a snippet with the given * {@code snippetName} using a template with the given {@code templateName}. The given * {@code attributes} will be included in the model during rendering of the template. - * - * @param snippetName The name of the snippet - * @param templateName The name of the template - * @param attributes The additional attributes + * @param snippetName the name of the snippet + * @param templateName the name of the template + * @param attributes the additional attributes */ protected TemplatedSnippet(String snippetName, String templateName, Map attributes) { @@ -94,8 +92,7 @@ public abstract class TemplatedSnippet implements Snippet { * given {@code operation}. Any additional attributes that were supplied when this * {@code TemplatedSnippet} were created will be automatically added to the model * prior to rendering. - * - * @param operation The operation + * @param operation the operation * @return the model * @throws ModelCreationException if model creation fails */ @@ -104,7 +101,6 @@ public abstract class TemplatedSnippet implements Snippet { /** * Returns the additional attributes that will be included in the model during * template rendering. - * * @return the additional attributes */ protected final Map getAttributes() { @@ -113,7 +109,6 @@ public abstract class TemplatedSnippet implements Snippet { /** * Returns the name of the snippet that will be created. - * * @return the snippet name */ protected final String getSnippetName() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/WriterResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/WriterResolver.java index 3caac5ac..cd396601 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/WriterResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/WriterResolver.java @@ -32,7 +32,6 @@ public interface WriterResolver { /** * Returns a writer that can be used to write the snippet with the given name for the * operation with the given name. - * * @param operationName the name of the operation that is being documented * @param snippetName the name of the snippet * @param restDocumentationContext the current documentation context @@ -45,7 +44,6 @@ public interface WriterResolver { /** * Configures the encoding that should be used by any writers produced by this * resolver. - * * @param encoding the encoding * @deprecated since 1.1.0 in favour of configuring the encoding when to resolver is * created diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/StandardTemplateResourceResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/StandardTemplateResourceResolver.java index 7f963e99..b0a578bd 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/StandardTemplateResourceResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/StandardTemplateResourceResolver.java @@ -44,7 +44,6 @@ public class StandardTemplateResourceResolver implements TemplateResourceResolve /** * Creates a new {@code StandardTemplateResourceResolver} that will produce default * template resources formatted with Asciidoctor. - * * @deprecated since 1.1.0 in favour of * {@link #StandardTemplateResourceResolver(TemplateFormat)} */ @@ -56,7 +55,6 @@ public class StandardTemplateResourceResolver implements TemplateResourceResolve /** * Creates a new {@code StandardTemplateResourceResolver} that will produce default * template resources formatted with the given {@code templateFormat}. - * * @param templateFormat the format for the default snippet templates */ public StandardTemplateResourceResolver(TemplateFormat templateFormat) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/Template.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/Template.java index 7275c529..37d5c4c5 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/Template.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/Template.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. @@ -29,9 +29,8 @@ public interface Template { /** * Renders the template to a {@link String} using the given {@code context} for * variable/property resolution. - * - * @param context The context to use - * @return The rendered template + * @param context the context to use + * @return the rendered template */ String render(Map context); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateEngine.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateEngine.java index 17c2dfc7..57bdc312 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateEngine.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateEngine.java @@ -32,7 +32,6 @@ public interface TemplateEngine { * Compiles the template at the given {@code path}. Typically, a * {@link TemplateResourceResolver} will be used to resolve the path into a resource * that can be read and compiled. - * * @param path the path of the template * @return the compiled {@code Template} * @throws IOException if compilation fails diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormat.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormat.java index fa75b5f5..899ff5ec 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormat.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormat.java @@ -27,7 +27,6 @@ public interface TemplateFormat { /** * Returns the id of this template format. - * * @return the id */ String getId(); @@ -35,7 +34,6 @@ public interface TemplateFormat { /** * Returns the file extension to use for files generated from templates in this * format. - * * @return the file extension */ String getFileExtension(); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormats.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormats.java index 32f5b4aa..1be56e31 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormats.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormats.java @@ -35,7 +35,6 @@ public abstract class TemplateFormats { /** * Returns the Asciidoctor template format with the ID {@code asciidoctor} and the * file extension {@code adoc}. - * * @return the template format */ public static TemplateFormat asciidoctor() { @@ -45,7 +44,6 @@ public abstract class TemplateFormats { /** * Returns the Markdown template format with the ID {@code markdown} and the file * extension {@code md}. - * * @return the template format */ public static TemplateFormat markdown() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateResourceResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateResourceResolver.java index 7def9462..0177aed7 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateResourceResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateResourceResolver.java @@ -28,7 +28,6 @@ public interface TemplateResourceResolver { /** * Resolves a {@link Resource} for the template with the given {@code name}. - * * @param name the name of the template * @return the {@code Resource} from which the template can be read */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/MustacheTemplate.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/MustacheTemplate.java index 1d315360..2ab8bea2 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/MustacheTemplate.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/MustacheTemplate.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. @@ -36,8 +36,7 @@ public class MustacheTemplate implements Template { /** * Creates a new {@code MustacheTemplate} that adapts the given {@code delegate}. - * - * @param delegate The delegate to adapt + * @param delegate the delegate to adapt */ public MustacheTemplate(org.springframework.restdocs.mustache.Template delegate) { this(delegate, Collections.emptyMap()); @@ -48,9 +47,8 @@ public class MustacheTemplate implements Template { * During rendering, the given {@code context} and the context passed into * {@link #render(Map)} will be combined and then passed to the delegate when it is * {@link org.springframework.restdocs.mustache.Template#execute executed}. - * - * @param delegate The delegate to adapt - * @param context The context + * @param delegate the delegate to adapt + * @param context the context */ public MustacheTemplate(org.springframework.restdocs.mustache.Template delegate, Map context) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/MustacheTemplateEngine.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/MustacheTemplateEngine.java index fadce5ae..8d0c6bfa 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/MustacheTemplateEngine.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/MustacheTemplateEngine.java @@ -47,7 +47,6 @@ public class MustacheTemplateEngine implements TemplateEngine { /** * Creates a new {@code MustacheTemplateEngine} that will use the given * {@code templateResourceResolver} to resolve template paths. - * * @param templateResourceResolver the resolver to use */ public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver) { @@ -58,7 +57,6 @@ public class MustacheTemplateEngine implements TemplateEngine { * Creates a new {@code MustacheTemplateEngine} that will use the given * {@code templateResourceResolver} to resolve templates and the given * {@code compiler} to compile them. - * * @param templateResourceResolver the resolver to use * @param compiler the compiler to use */ @@ -72,7 +70,6 @@ public class MustacheTemplateEngine implements TemplateEngine { * {@code templateResourceResolver} to resolve templates and the given * {@code compiler} to compile them. Compiled templates will be created with the given * {@code context}. - * * @param templateResourceResolver the resolver to use * @param compiler the compiler to use * @param context the context to pass to compiled templates @@ -98,7 +95,6 @@ public class MustacheTemplateEngine implements TemplateEngine { /** * Returns the {@link Compiler} used to compile Mustache templates. - * * @return the compiler */ protected final Compiler getCompiler() { @@ -108,7 +104,6 @@ public class MustacheTemplateEngine implements TemplateEngine { /** * Returns the {@link TemplateResourceResolver} used to resolve the template resources * prior to compilation. - * * @return the resolver */ protected final TemplateResourceResolver getTemplateResourceResolver() { diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/AbstractSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/AbstractSnippetTests.java index 11b51651..7b5034e1 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/AbstractSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/AbstractSnippetTests.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. @@ -27,6 +27,7 @@ import org.junit.runners.Parameterized.Parameters; import org.springframework.core.io.FileSystemResource; import org.springframework.http.HttpStatus; import org.springframework.restdocs.templates.TemplateFormat; +import org.springframework.restdocs.templates.TemplateFormats; import org.springframework.restdocs.test.GeneratedSnippets; import org.springframework.restdocs.test.OperationBuilder; import org.springframework.restdocs.test.SnippetConditions; @@ -36,9 +37,6 @@ import org.springframework.restdocs.test.SnippetConditions.HttpResponseCondition import org.springframework.restdocs.test.SnippetConditions.TableCondition; import org.springframework.web.bind.annotation.RequestMethod; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; -import static org.springframework.restdocs.templates.TemplateFormats.markdown; - /** * Abstract base class for testing snippet generation. * @@ -57,8 +55,9 @@ public abstract class AbstractSnippetTests { @Parameters(name = "{0}") public static List parameters() { - return Arrays.asList(new Object[] { "Asciidoctor", asciidoctor() }, - new Object[] { "Markdown", markdown() }); + return Arrays.asList( + new Object[] { "Asciidoctor", TemplateFormats.asciidoctor() }, + new Object[] { "Markdown", TemplateFormats.markdown() }); } public AbstractSnippetTests(String name, TemplateFormat templateFormat) { diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ResourceBundleConstraintDescriptionResolverTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ResourceBundleConstraintDescriptionResolverTests.java index c92a6302..e75f25a7 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ResourceBundleConstraintDescriptionResolverTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ResourceBundleConstraintDescriptionResolverTests.java @@ -347,6 +347,7 @@ public class ResourceBundleConstraintDescriptionResolverTests { @org.hibernate.validator.constraints.URL private String url; + } } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetFailureTests.java index 95f27678..72ca1c66 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetFailureTests.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. @@ -24,12 +24,12 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.restdocs.snippet.SnippetException; +import org.springframework.restdocs.templates.TemplateFormats; import org.springframework.restdocs.test.OperationBuilder; import static org.hamcrest.CoreMatchers.endsWith; import static org.hamcrest.CoreMatchers.equalTo; import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; /** * Tests for failures when rendering {@link RequestHeadersSnippet} due to missing or @@ -40,7 +40,8 @@ import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor public class RequestHeadersSnippetFailureTests { @Rule - public OperationBuilder operationBuilder = new OperationBuilder(asciidoctor()); + public OperationBuilder operationBuilder = new OperationBuilder( + TemplateFormats.asciidoctor()); @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetFailureTests.java index 6df4929b..f45a0abd 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetFailureTests.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. @@ -24,12 +24,12 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.restdocs.snippet.SnippetException; +import org.springframework.restdocs.templates.TemplateFormats; import org.springframework.restdocs.test.OperationBuilder; import static org.hamcrest.CoreMatchers.endsWith; import static org.hamcrest.CoreMatchers.equalTo; import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; /** * Tests for failures when rendering {@link ResponseHeadersSnippet} due to missing or @@ -40,7 +40,8 @@ import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor public class ResponseHeadersSnippetFailureTests { @Rule - public OperationBuilder operationBuilder = new OperationBuilder(asciidoctor()); + public OperationBuilder operationBuilder = new OperationBuilder( + TemplateFormats.asciidoctor()); @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetFailureTests.java index c6b62020..097022e6 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetFailureTests.java @@ -25,10 +25,10 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.restdocs.snippet.SnippetException; +import org.springframework.restdocs.templates.TemplateFormats; import org.springframework.restdocs.test.OperationBuilder; import static org.hamcrest.CoreMatchers.equalTo; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; /** * Tests for failures when rendering {@link LinksSnippet} due to missing or undocumented @@ -39,7 +39,8 @@ import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor public class LinksSnippetFailureTests { @Rule - public OperationBuilder operationBuilder = new OperationBuilder(asciidoctor()); + public OperationBuilder operationBuilder = new OperationBuilder( + TemplateFormats.asciidoctor()); @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/AsciidoctorRequestFieldsSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/AsciidoctorRequestFieldsSnippetTests.java index 1ce44f4b..3df46c50 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/AsciidoctorRequestFieldsSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/AsciidoctorRequestFieldsSnippetTests.java @@ -24,17 +24,17 @@ import org.junit.Test; import org.springframework.core.io.FileSystemResource; import org.springframework.restdocs.templates.TemplateEngine; +import org.springframework.restdocs.templates.TemplateFormats; import org.springframework.restdocs.templates.TemplateResourceResolver; import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; import org.springframework.restdocs.test.GeneratedSnippets; import org.springframework.restdocs.test.OperationBuilder; +import org.springframework.restdocs.test.SnippetConditions; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; -import static org.springframework.restdocs.test.SnippetConditions.tableWithHeader; /** * Tests for {@link RequestFieldsSnippet} that are specific to Asciidoctor. @@ -44,10 +44,12 @@ import static org.springframework.restdocs.test.SnippetConditions.tableWithHeade public class AsciidoctorRequestFieldsSnippetTests { @Rule - public OperationBuilder operationBuilder = new OperationBuilder(asciidoctor()); + public OperationBuilder operationBuilder = new OperationBuilder( + TemplateFormats.asciidoctor()); @Rule - public GeneratedSnippets generatedSnippets = new GeneratedSnippets(asciidoctor()); + public GeneratedSnippets generatedSnippets = new GeneratedSnippets( + TemplateFormats.asciidoctor()); @Test public void requestFieldsWithListDescription() throws IOException { @@ -64,11 +66,12 @@ public class AsciidoctorRequestFieldsSnippetTests { resolver)) .request("http://localhost") .content("{\"a\": \"foo\"}").build()); - assertThat(this.generatedSnippets.requestFields()) - .is(tableWithHeader(asciidoctor(), "Path", "Type", "Description") - // - .row("a", "String", String.format(" - one%n - two")) - .configuration("[cols=\"1,1,1a\"]")); + assertThat(this.generatedSnippets.requestFields()).is(SnippetConditions + .tableWithHeader(TemplateFormats.asciidoctor(), "Path", "Type", + "Description") + // + .row("a", "String", String.format(" - one%n - two")) + .configuration("[cols=\"1,1,1a\"]")); } private FileSystemResource snippetResource(String name) { diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java index 679cab34..e9b1e491 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java @@ -27,13 +27,13 @@ import org.junit.rules.ExpectedException; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.restdocs.snippet.SnippetException; +import org.springframework.restdocs.templates.TemplateFormats; import org.springframework.restdocs.test.OperationBuilder; import static org.hamcrest.CoreMatchers.endsWith; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.startsWith; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; /** * Tests for failures when rendering {@link ResponseFieldsSnippet} due to missing or @@ -44,7 +44,8 @@ import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor public class ResponseFieldsSnippetFailureTests { @Rule - public OperationBuilder operationBuilder = new OperationBuilder(asciidoctor()); + public OperationBuilder operationBuilder = new OperationBuilder( + TemplateFormats.asciidoctor()); @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetFailureTests.java index 5941151b..9deda59f 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetFailureTests.java @@ -26,11 +26,11 @@ import org.junit.rules.ExpectedException; import org.springframework.restdocs.generate.RestDocumentationGenerator; import org.springframework.restdocs.snippet.SnippetException; +import org.springframework.restdocs.templates.TemplateFormats; import org.springframework.restdocs.test.OperationBuilder; import static org.hamcrest.CoreMatchers.equalTo; import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; /** * Tests for failures when rendering {@link PathParametersSnippet} due to missing or @@ -41,7 +41,8 @@ import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor public class PathParametersSnippetFailureTests { @Rule - public OperationBuilder operationBuilder = new OperationBuilder(asciidoctor()); + public OperationBuilder operationBuilder = new OperationBuilder( + TemplateFormats.asciidoctor()); @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetFailureTests.java index e1c923ea..636b29d8 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetFailureTests.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. @@ -25,11 +25,11 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.restdocs.snippet.SnippetException; +import org.springframework.restdocs.templates.TemplateFormats; import org.springframework.restdocs.test.OperationBuilder; import static org.hamcrest.CoreMatchers.equalTo; import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; /** * Tests for failures when rendering {@link RequestParametersSnippet} due to missing or @@ -40,7 +40,8 @@ import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor public class RequestParametersSnippetFailureTests { @Rule - public OperationBuilder operationBuilder = new OperationBuilder(asciidoctor()); + public OperationBuilder operationBuilder = new OperationBuilder( + TemplateFormats.asciidoctor()); @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetFailureTests.java index 63888490..331d7705 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetFailureTests.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. @@ -25,11 +25,11 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.restdocs.snippet.SnippetException; +import org.springframework.restdocs.templates.TemplateFormats; import org.springframework.restdocs.test.OperationBuilder; import static org.hamcrest.CoreMatchers.equalTo; import static org.springframework.restdocs.request.RequestDocumentation.partWithName; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; /** * Tests for failures when rendering {@link RequestPartsSnippet} due to missing or @@ -40,7 +40,8 @@ import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor public class RequestPartsSnippetFailureTests { @Rule - public OperationBuilder operationBuilder = new OperationBuilder(asciidoctor()); + public OperationBuilder operationBuilder = new OperationBuilder( + TemplateFormats.asciidoctor()); @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/StandardWriterResolverTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/StandardWriterResolverTests.java index bae92597..58855c58 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/StandardWriterResolverTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/StandardWriterResolverTests.java @@ -27,13 +27,13 @@ import org.junit.rules.TemporaryFolder; import org.springframework.restdocs.ManualRestDocumentation; import org.springframework.restdocs.RestDocumentationContext; +import org.springframework.restdocs.templates.TemplateFormats; import org.springframework.util.FileCopyUtils; import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; /** * Tests for {@link StandardWriterResolver}. @@ -49,7 +49,7 @@ public class StandardWriterResolverTests { PlaceholderResolverFactory.class); private final StandardWriterResolver resolver = new StandardWriterResolver( - this.placeholderResolverFactory, "UTF-8", asciidoctor()); + this.placeholderResolverFactory, "UTF-8", TemplateFormats.asciidoctor()); @Test public void absoluteInput() { diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/templates/StandardTemplateResourceResolverTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/templates/StandardTemplateResourceResolverTests.java index bd0484fa..87569875 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/templates/StandardTemplateResourceResolverTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/templates/StandardTemplateResourceResolverTests.java @@ -29,7 +29,6 @@ import org.springframework.core.io.Resource; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; /** * Tests for {@link TemplateResourceResolver}. @@ -42,7 +41,7 @@ public class StandardTemplateResourceResolverTests { public final ExpectedException thrown = ExpectedException.none(); private final TemplateResourceResolver resolver = new StandardTemplateResourceResolver( - asciidoctor()); + TemplateFormats.asciidoctor()); private final TestClassLoader classLoader = new TestClassLoader(); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OperationBuilder.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OperationBuilder.java index 032b0845..5f280de0 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OperationBuilder.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OperationBuilder.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. @@ -115,10 +115,10 @@ public class OperationBuilder extends OperationTestRule { new RestDocumentationContextPlaceholderResolverFactory(), "UTF-8", this.templateFormat)); return new StandardOperation(this.name, - (this.requestBuilder == null + ((this.requestBuilder == null) ? new OperationRequestBuilder("http://localhost/").buildRequest() : this.requestBuilder.buildRequest()), - this.responseBuilder == null + (this.responseBuilder == null) ? new OperationResponseBuilder().buildResponse() : this.responseBuilder.buildResponse(), this.attributes); @@ -259,7 +259,9 @@ public class OperationBuilder extends OperationTestRule { this.headers.add(name, value); return this; } + } + } /** diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OutputCapture.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OutputCapture.java index f2f93115..72ebec54 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OutputCapture.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OutputCapture.java @@ -104,7 +104,6 @@ public class OutputCapture implements TestRule { /** * Verify that the output is matched by the supplied {@code matcher}. Verification is * performed after the test method has executed. - * * @param matcher the matcher */ public final void expect(Matcher matcher) { diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/SnippetConditions.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/SnippetConditions.java index 137f6b05..df6eea02 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/SnippetConditions.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/SnippetConditions.java @@ -96,7 +96,7 @@ public final class SnippetConditions { return new MarkdownCodeBlockCondition(language); } - private static abstract class AbstractSnippetContentCondition + private abstract static class AbstractSnippetContentCondition extends Condition { private List lines = new ArrayList<>(); @@ -143,6 +143,7 @@ public final class SnippetConditions { } return writer.toString(); } + } /** @@ -170,8 +171,8 @@ public final class SnippetConditions { extends CodeBlockCondition { protected AsciidoctorCodeBlockCondition(String language, String options) { - this.addLine("[source" + (language == null ? "" : "," + language) - + (options == null ? "" : ",options=\"" + options + "\"") + "]"); + this.addLine("[source" + ((language != null) ? "," + language : "") + + ((options != null) ? ",options=\"" + options + "\"" : "") + "]"); this.addLine("----"); this.addLine("----"); } @@ -187,7 +188,7 @@ public final class SnippetConditions { extends CodeBlockCondition { protected MarkdownCodeBlockCondition(String language) { - this.addLine("```" + (language == null ? "" : language)); + this.addLine("```" + ((language != null) ? language : "")); this.addLine("```"); } @@ -198,7 +199,7 @@ public final class SnippetConditions { * * @param The type of the Condition */ - public static abstract class HttpCondition> + public abstract static class HttpCondition> extends Condition { private final CodeBlockCondition delegate; @@ -233,11 +234,6 @@ public final class SnippetConditions { return this.delegate.matches(item); } - // @Override - // public void describeTo(Description description) { - // this.delegate.describeTo(description); - // } - } /** @@ -275,7 +271,7 @@ public final class SnippetConditions { * * @param The concrete type of the Condition */ - public static abstract class TableCondition> + public abstract static class TableCondition> extends AbstractSnippetContentCondition { public abstract T row(String... entries); diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/IterableEnumeration.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/IterableEnumeration.java index d4b9653f..e91bb7e6 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/IterableEnumeration.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/IterableEnumeration.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. @@ -57,12 +57,11 @@ final class IterableEnumeration implements Iterable { /** * Creates an {@code Iterable} that will iterate over the given {@code enumeration}. - * * @param the type of the enumeration's elements - * @param enumeration The enumeration to expose as an {@code Iterable} + * @param enumeration the enumeration to expose as an {@code Iterable} * @return the iterable */ - static Iterable iterable(Enumeration enumeration) { + static Iterable of(Enumeration enumeration) { return new IterableEnumeration<>(enumeration); } diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverter.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverter.java index 45e0a9ba..89087b52 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverter.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverter.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. @@ -46,8 +46,6 @@ import org.springframework.util.FileCopyUtils; import org.springframework.util.StringUtils; import org.springframework.web.multipart.MultipartFile; -import static org.springframework.restdocs.mockmvc.IterableEnumeration.iterable; - /** * A converter for creating an {@link OperationRequest} from a * {@link MockHttpServletRequest}. @@ -172,7 +170,7 @@ class MockMvcRequestConverter implements RequestConverter - * * @param snippets the snippets * @return the new result handler */ @@ -106,7 +104,6 @@ public class RestDocumentationResultHandler implements ResultHandler { /** * Returns the {@link RestDocumentationGenerator} that is used as a delegate. - * * @return the delegate */ protected final RestDocumentationGenerator getDelegate() { diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/UriConfigurer.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/UriConfigurer.java index 9ec944b7..75a2d638 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/UriConfigurer.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/UriConfigurer.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. @@ -69,8 +69,7 @@ public class UriConfigurer /** * Configures any documented URIs to use the given {@code scheme}. The default is * {@code http}. - * - * @param scheme The URI scheme + * @param scheme the URI scheme * @return {@code this} */ public UriConfigurer withScheme(String scheme) { @@ -81,8 +80,7 @@ public class UriConfigurer /** * Configures any documented URIs to use the given {@code host}. The default is * {@code localhost}. - * - * @param host The URI host + * @param host the URI host * @return {@code this} */ public UriConfigurer withHost(String host) { @@ -93,8 +91,7 @@ public class UriConfigurer /** * Configures any documented URIs to use the given {@code port}. The default is * {@code 8080}. - * - * @param port The URI port + * @param port the URI port * @return {@code this} */ public UriConfigurer withPort(int port) { 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 3b347877..6b4732e4 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 @@ -48,7 +48,12 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.restdocs.JUnitRestDocumentation; import org.springframework.restdocs.mockmvc.MockMvcRestDocumentationIntegrationTests.TestConfiguration; +import org.springframework.restdocs.templates.TemplateFormat; +import org.springframework.restdocs.templates.TemplateFormats; +import org.springframework.restdocs.test.SnippetConditions; +import org.springframework.restdocs.test.SnippetConditions.CodeBlockCondition; import org.springframework.restdocs.test.SnippetConditions.HttpRequestCondition; +import org.springframework.restdocs.test.SnippetConditions.HttpResponseCondition; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; @@ -69,7 +74,6 @@ import static org.springframework.restdocs.headers.HeaderDocumentation.headerWit import static org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders; import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel; import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links; -import static org.springframework.restdocs.mockmvc.IterableEnumeration.iterable; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; @@ -88,11 +92,6 @@ import static org.springframework.restdocs.request.RequestDocumentation.partWith import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.restdocs.request.RequestDocumentation.requestParts; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; -import static org.springframework.restdocs.templates.TemplateFormats.markdown; -import static org.springframework.restdocs.test.SnippetConditions.codeBlock; -import static org.springframework.restdocs.test.SnippetConditions.httpRequest; -import static org.springframework.restdocs.test.SnippetConditions.httpResponse; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.fileUpload; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -141,7 +140,8 @@ public class MockMvcRestDocumentationIntegrationTests { public void markdownSnippetGeneration() throws Exception { MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context) .apply(new MockMvcRestDocumentationConfigurer(this.restDocumentation) - .snippets().withEncoding("UTF-8").withTemplateFormat(markdown())) + .snippets().withEncoding("UTF-8") + .withTemplateFormat(TemplateFormats.markdown())) .build(); mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(document("basic-markdown")); @@ -158,10 +158,11 @@ public class MockMvcRestDocumentationIntegrationTests { .andExpect(status().isOk()).andDo(document("curl-snippet-with-content")); assertThat(new File( "build/generated-snippets/curl-snippet-with-content/curl-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash").withContent(String - .format("$ curl 'http://localhost:8080/' -i -X POST \\%n" - + " -H 'Accept: application/json' \\%n" - + " -d 'content'")))); + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") + .withContent(String.format( + "$ curl 'http://localhost:8080/' -i -X POST \\%n" + + " -H 'Accept: application/json' \\%n" + + " -d 'content'")))); } @Test @@ -173,10 +174,11 @@ public class MockMvcRestDocumentationIntegrationTests { .andDo(document("curl-snippet-with-cookies")); assertThat(new File( "build/generated-snippets/curl-snippet-with-cookies/curl-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash").withContent(String - .format("$ curl 'http://localhost:8080/' -i -X GET \\%n" - + " -H 'Accept: application/json' \\%n" - + " --cookie 'cookieName=cookieVal'")))); + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") + .withContent(String.format( + "$ curl 'http://localhost:8080/' -i -X GET \\%n" + + " -H 'Accept: application/json' \\%n" + + " --cookie 'cookieName=cookieVal'")))); } @Test @@ -188,7 +190,7 @@ public class MockMvcRestDocumentationIntegrationTests { .andDo(document("curl-snippet-with-query-string")); assertThat(new File( "build/generated-snippets/curl-snippet-with-query-string/curl-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash") + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") .withContent(String.format("$ curl " + "'http://localhost:8080/?foo=bar' -i -X POST \\%n" + " -H 'Accept: application/json' \\%n" @@ -204,10 +206,11 @@ public class MockMvcRestDocumentationIntegrationTests { .andDo(document("curl-snippet-with-content-and-parameters")); assertThat(new File( "build/generated-snippets/curl-snippet-with-content-and-parameters/curl-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash").withContent(String - .format("$ curl 'http://localhost:8080/?a=alpha' -i -X POST \\%n" - + " -H 'Accept: application/json' \\%n" - + " -d 'some content'")))); + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") + .withContent(String.format( + "$ curl 'http://localhost:8080/?a=alpha' -i -X POST \\%n" + + " -H 'Accept: application/json' \\%n" + + " -d 'some content'")))); } @Test @@ -219,7 +222,7 @@ public class MockMvcRestDocumentationIntegrationTests { .andDo(document("httpie-snippet-with-content")); assertThat(new File( "build/generated-snippets/httpie-snippet-with-content/httpie-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash") + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") .withContent(String.format("$ echo 'content' | " + "http POST 'http://localhost:8080/' \\%n" + " 'Accept:application/json'")))); @@ -234,10 +237,11 @@ public class MockMvcRestDocumentationIntegrationTests { .andDo(document("httpie-snippet-with-cookies")); assertThat(new File( "build/generated-snippets/httpie-snippet-with-cookies/httpie-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash").withContent( - String.format("$ http GET 'http://localhost:8080/' \\%n" - + " 'Accept:application/json' \\%n" - + " 'Cookie:cookieName=cookieVal'")))); + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") + .withContent(String + .format("$ http GET 'http://localhost:8080/' \\%n" + + " 'Accept:application/json' \\%n" + + " 'Cookie:cookieName=cookieVal'")))); } @Test @@ -249,7 +253,7 @@ public class MockMvcRestDocumentationIntegrationTests { .andDo(document("httpie-snippet-with-query-string")); assertThat(new File( "build/generated-snippets/httpie-snippet-with-query-string/httpie-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash") + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") .withContent(String.format("$ http " + "--form POST 'http://localhost:8080/?foo=bar' \\%n" + " 'Accept:application/json' \\%n 'a=alpha'")))); @@ -264,10 +268,11 @@ public class MockMvcRestDocumentationIntegrationTests { .andDo(document("httpie-snippet-post-with-content-and-parameters")); assertThat(new File( "build/generated-snippets/httpie-snippet-post-with-content-and-parameters/httpie-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash").withContent( - String.format("$ echo " + "'some content' | http POST " - + "'http://localhost:8080/?a=alpha' \\%n" - + " 'Accept:application/json'")))); + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") + .withContent(String + .format("$ echo " + "'some content' | http POST " + + "'http://localhost:8080/?a=alpha' \\%n" + + " 'Accept:application/json'")))); } @Test @@ -356,9 +361,9 @@ public class MockMvcRestDocumentationIntegrationTests { responseHeaders(headerWithName(HttpHeaders.SET_COOKIE) .description("set-cookie")))); assertThat(new File("build/generated-snippets/set-cookie/http-response.adoc")) - .has(content(httpResponse(asciidoctor(), HttpStatus.OK).header( - HttpHeaders.SET_COOKIE, - "name=value; Domain=localhost; HttpOnly"))); + .has(content(httpResponse(TemplateFormats.asciidoctor(), HttpStatus.OK) + .header(HttpHeaders.SET_COOKIE, + "name=value; Domain=localhost; HttpOnly"))); } @Test @@ -427,9 +432,10 @@ public class MockMvcRestDocumentationIntegrationTests { HttpHeaders.CONTENT_LENGTH), replacePattern(pattern, "\"<>\"")))) .andReturn(); - HttpRequestCondition originalRequest = httpRequest(asciidoctor(), + HttpRequestCondition originalRequest = httpRequest(TemplateFormats.asciidoctor(), RequestMethod.GET, "/"); - for (String headerName : iterable(result.getRequest().getHeaderNames())) { + for (String headerName : IterableEnumeration + .of(result.getRequest().getHeaderNames())) { originalRequest.header(headerName, result.getRequest().getHeader(headerName)); } assertThat( @@ -437,11 +443,12 @@ public class MockMvcRestDocumentationIntegrationTests { .has(content(originalRequest.header("Host", "localhost:8080") .header("Content-Length", "13") .content("{\"a\":\"alpha\"}"))); - HttpRequestCondition preprocessedRequest = httpRequest(asciidoctor(), - RequestMethod.GET, "/"); + HttpRequestCondition preprocessedRequest = httpRequest( + TemplateFormats.asciidoctor(), RequestMethod.GET, "/"); List removedHeaders = Arrays.asList("a", HttpHeaders.HOST, HttpHeaders.CONTENT_LENGTH); - for (String headerName : iterable(result.getRequest().getHeaderNames())) { + for (String headerName : IterableEnumeration + .of(result.getRequest().getHeaderNames())) { if (!removedHeaders.contains(headerName)) { preprocessedRequest.header(headerName, result.getRequest().getHeader(headerName)); @@ -468,9 +475,9 @@ public class MockMvcRestDocumentationIntegrationTests { String original = "{\"a\":\"alpha\",\"links\":[{\"rel\":\"rel\"," + "\"href\":\"href\"}]}"; - assertThat( - new File("build/generated-snippets/original-response/http-response.adoc")) - .has(content(httpResponse(asciidoctor(), HttpStatus.OK) + assertThat(new File( + "build/generated-snippets/original-response/http-response.adoc")).has( + content(httpResponse(TemplateFormats.asciidoctor(), HttpStatus.OK) .header("a", "alpha") .header("Content-Type", "application/json;charset=UTF-8") .header(HttpHeaders.CONTENT_LENGTH, @@ -479,8 +486,8 @@ public class MockMvcRestDocumentationIntegrationTests { String prettyPrinted = String.format("{%n \"a\" : \"<>\",%n \"links\" : " + "[ {%n \"rel\" : \"rel\",%n \"href\" : \"...\"%n } ]%n}"); assertThat(new File( - "build/generated-snippets/preprocessed-response/http-response.adoc")) - .has(content(httpResponse(asciidoctor(), HttpStatus.OK) + "build/generated-snippets/preprocessed-response/http-response.adoc")).has( + content(httpResponse(TemplateFormats.asciidoctor(), HttpStatus.OK) .header("Content-Type", "application/json;charset=UTF-8") .header(HttpHeaders.CONTENT_LENGTH, prettyPrinted.getBytes().length) @@ -519,9 +526,10 @@ public class MockMvcRestDocumentationIntegrationTests { .andExpect(status().isOk()).andDo(document("custom-context-path")); assertThat(new File( "build/generated-snippets/custom-context-path/curl-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash").withContent(String - .format("$ curl 'http://localhost:8080/custom/' -i -X GET \\%n" - + " -H 'Accept: application/json'")))); + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") + .withContent(String.format( + "$ curl 'http://localhost:8080/custom/' -i -X GET \\%n" + + " -H 'Accept: application/json'")))); } @Test @@ -558,6 +566,19 @@ public class MockMvcRestDocumentationIntegrationTests { }; } + private CodeBlockCondition codeBlock(TemplateFormat format, String language) { + return SnippetConditions.codeBlock(format, language); + } + + private HttpRequestCondition httpRequest(TemplateFormat format, + RequestMethod requestMethod, String uri) { + return SnippetConditions.httpRequest(format, requestMethod, uri); + } + + private HttpResponseCondition httpResponse(TemplateFormat format, HttpStatus status) { + return SnippetConditions.httpResponse(format, status); + } + /** * Test configuration that enables Spring MVC. */ diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRequestConverter.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRequestConverter.java index 101564b0..08811060 100644 --- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRequestConverter.java +++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRequestConverter.java @@ -165,9 +165,9 @@ class RestAssuredRequestConverter List parts = new ArrayList<>(); for (MultiPartSpecification multiPartSpec : requestSpec.getMultiPartParams()) { HttpHeaders headers = new HttpHeaders(); - headers.setContentType( - multiPartSpec.getMimeType() == null ? MediaType.TEXT_PLAIN - : MediaType.parseMediaType(multiPartSpec.getMimeType())); + headers.setContentType((multiPartSpec.getMimeType() != null) + ? MediaType.parseMediaType(multiPartSpec.getMimeType()) + : MediaType.TEXT_PLAIN); parts.add(new OperationRequestPartFactory().create( multiPartSpec.getControlName(), multiPartSpec.getFileName(), convertContent(multiPartSpec.getContent()), headers)); diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentation.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentation.java index f9c62eb6..c203cf6e 100644 --- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentation.java +++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentation.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. @@ -44,7 +44,6 @@ public abstract class RestAssuredRestDocumentation { /** * Documents the API call with the given {@code identifier} using the given * {@code snippets}. - * * @param identifier an identifier for the API call that is being documented * @param snippets the snippets that will document the API call * @return a {@link RestDocumentationFilter} that will produce the documentation @@ -59,7 +58,6 @@ public abstract class RestAssuredRestDocumentation { * Documents the API call with the given {@code identifier} using the given * {@code snippets} in addition to any default snippets. The given * {@code requestPreprocessor} is applied to the request before it is documented. - * * @param identifier an identifier for the API call that is being documented * @param requestPreprocessor the request preprocessor * @param snippets the snippets @@ -75,7 +73,6 @@ public abstract class RestAssuredRestDocumentation { * Documents the API call with the given {@code identifier} using the given * {@code snippets} in addition to any default snippets. The given * {@code responsePreprocessor} is applied to the request before it is documented. - * * @param identifier an identifier for the API call that is being documented * @param responsePreprocessor the response preprocessor * @param snippets the snippets @@ -92,7 +89,6 @@ public abstract class RestAssuredRestDocumentation { * {@code snippets} in addition to any default snippets. The given * {@code requestPreprocessor} and {@code responsePreprocessor} are applied to the * request and response respectively before they are documented. - * * @param identifier an identifier for the API call that is being documented * @param requestPreprocessor the request preprocessor * @param responsePreprocessor the response preprocessor @@ -110,7 +106,6 @@ public abstract class RestAssuredRestDocumentation { /** * Provides access to a {@link RestAssuredRestDocumentationConfigurer} that can be * used to configure Spring REST Docs using the given {@code contextProvider}. - * * @param contextProvider the context provider * @return the configurer */ diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestDocumentationFilter.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestDocumentationFilter.java index f46f76de..57282c2a 100644 --- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestDocumentationFilter.java +++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestDocumentationFilter.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. @@ -66,7 +66,6 @@ public class RestDocumentationFilter implements Filter { /** * Returns the configuration that should be used when calling the delgate. The * configuration is derived from the given {@code requestSpec} and {@code context}. - * * @param requestSpec the request specification * @param context the filter context * @return the configuration @@ -86,7 +85,6 @@ public class RestDocumentationFilter implements Filter { /** * Adds the given {@code snippets} such that they are documented when this result * handler is called. - * * @param snippets the snippets to add * @return this {@code RestDocumentationFilter} * @deprecated since 1.1 in favor of {@link #document(Snippet...)} @@ -100,7 +98,6 @@ public class RestDocumentationFilter implements Filter { /** * Creates a new {@link RestDocumentationFilter} that will produce documentation using * the given {@code snippets}. - * * @param snippets the snippets * @return the new result handler */ diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/RestAssuredPreprocessors.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/RestAssuredPreprocessors.java index 6689333c..45a393a2 100644 --- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/RestAssuredPreprocessors.java +++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/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. @@ -42,7 +42,6 @@ public abstract class RestAssuredPreprocessors { /** * 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 */ public static UriModifyingOperationPreprocessor modifyUris() { diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/UriModifyingOperationPreprocessor.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/UriModifyingOperationPreprocessor.java index a9c74527..5c935fb9 100644 --- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/UriModifyingOperationPreprocessor.java +++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/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. @@ -75,7 +75,6 @@ public final class UriModifyingOperationPreprocessor implements OperationPreproc /** * Modifies the URI to use the given {@code scheme}. {@code null}, the default, will * leave the scheme unchanged. - * * @param scheme the scheme * @return {@code this} */ @@ -88,7 +87,6 @@ public final class UriModifyingOperationPreprocessor implements OperationPreproc /** * Modifies the URI to use the given {@code host}. {@code null}, the default, will * leave the host unchanged. - * * @param host the host * @return {@code this} */ @@ -100,7 +98,6 @@ public final class UriModifyingOperationPreprocessor implements OperationPreproc /** * Modifies the URI to use the given {@code port}. - * * @param port the port * @return {@code this} */ @@ -110,7 +107,6 @@ public final class UriModifyingOperationPreprocessor implements OperationPreproc /** * Removes the port from the URI. - * * @return {@code this} */ public UriModifyingOperationPreprocessor removePort() { @@ -143,7 +139,7 @@ public final class UriModifyingOperationPreprocessor implements OperationPreproc URI modifiedUri = uriBuilder.build(true).toUri(); HttpHeaders modifiedHeaders = modify(request.getHeaders()); modifiedHeaders.set(HttpHeaders.HOST, modifiedUri.getHost() - + (modifiedUri.getPort() == -1 ? "" : ":" + modifiedUri.getPort())); + + ((modifiedUri.getPort() != -1) ? ":" + modifiedUri.getPort() : "")); return this.contentModifyingDelegate.preprocess(new OperationRequestFactory() .create(uriBuilder.build(true).toUri(), request.getMethod(), request.getContent(), modifiedHeaders, request.getParameters(), diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRequestConverter.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRequestConverter.java index a2cb3a74..b6a657dd 100644 --- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRequestConverter.java +++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRequestConverter.java @@ -164,9 +164,9 @@ class RestAssuredRequestConverter List parts = new ArrayList<>(); for (MultiPartSpecification multiPartSpec : requestSpec.getMultiPartParams()) { HttpHeaders headers = new HttpHeaders(); - headers.setContentType( - multiPartSpec.getMimeType() == null ? MediaType.TEXT_PLAIN - : MediaType.parseMediaType(multiPartSpec.getMimeType())); + headers.setContentType((multiPartSpec.getMimeType() != null) + ? MediaType.parseMediaType(multiPartSpec.getMimeType()) + : MediaType.TEXT_PLAIN); parts.add(new OperationRequestPartFactory().create( multiPartSpec.getControlName(), multiPartSpec.getFileName(), convertContent(multiPartSpec.getContent()), headers)); diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentation.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentation.java index 65beb5a4..44663b89 100644 --- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentation.java +++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentation.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. @@ -41,7 +41,6 @@ public abstract class RestAssuredRestDocumentation { /** * Documents the API call with the given {@code identifier} using the given * {@code snippets}. - * * @param identifier an identifier for the API call that is being documented * @param snippets the snippets that will document the API call * @return a {@link RestDocumentationFilter} that will produce the documentation @@ -56,7 +55,6 @@ public abstract class RestAssuredRestDocumentation { * Documents the API call with the given {@code identifier} using the given * {@code snippets} in addition to any default snippets. The given * {@code requestPreprocessor} is applied to the request before it is documented. - * * @param identifier an identifier for the API call that is being documented * @param requestPreprocessor the request preprocessor * @param snippets the snippets @@ -72,7 +70,6 @@ public abstract class RestAssuredRestDocumentation { * Documents the API call with the given {@code identifier} using the given * {@code snippets} in addition to any default snippets. The given * {@code responsePreprocessor} is applied to the request before it is documented. - * * @param identifier an identifier for the API call that is being documented * @param responsePreprocessor the response preprocessor * @param snippets the snippets @@ -89,7 +86,6 @@ public abstract class RestAssuredRestDocumentation { * {@code snippets} in addition to any default snippets. The given * {@code requestPreprocessor} and {@code responsePreprocessor} are applied to the * request and response respectively before they are documented. - * * @param identifier an identifier for the API call that is being documented * @param requestPreprocessor the request preprocessor * @param responsePreprocessor the response preprocessor @@ -107,7 +103,6 @@ public abstract class RestAssuredRestDocumentation { /** * Provides access to a {@link RestAssuredRestDocumentationConfigurer} that can be * used to configure Spring REST Docs using the given {@code contextProvider}. - * * @param contextProvider the context provider * @return the configurer */ diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestDocumentationFilter.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestDocumentationFilter.java index b91b06f0..7e2f53f2 100644 --- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestDocumentationFilter.java +++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestDocumentationFilter.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. @@ -63,7 +63,6 @@ public class RestDocumentationFilter implements Filter { /** * Returns the configuration that should be used when calling the delgate. The * configuration is derived from the given {@code requestSpec} and {@code context}. - * * @param requestSpec the request specification * @param context the filter context * @return the configuration @@ -83,7 +82,6 @@ public class RestDocumentationFilter implements Filter { /** * Adds the given {@code snippets} such that they are documented when this result * handler is called. - * * @param snippets the snippets to add * @return this {@code RestDocumentationFilter} * @deprecated since 1.1 in favor of {@link #document(Snippet...)} @@ -97,7 +95,6 @@ public class RestDocumentationFilter implements Filter { /** * Creates a new {@link RestDocumentationFilter} that will produce documentation using * the given {@code snippets}. - * * @param snippets the snippets * @return the new result handler */ 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 2deb20cc..92b4c6a3 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. @@ -39,7 +39,6 @@ public abstract class RestAssuredPreprocessors { /** * 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 */ public static UriModifyingOperationPreprocessor modifyUris() { 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 7a418c21..8d570a8d 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. @@ -72,7 +72,6 @@ public final class UriModifyingOperationPreprocessor implements OperationPreproc /** * Modifies the URI to use the given {@code scheme}. {@code null}, the default, will * leave the scheme unchanged. - * * @param scheme the scheme * @return {@code this} */ @@ -85,7 +84,6 @@ public final class UriModifyingOperationPreprocessor implements OperationPreproc /** * Modifies the URI to use the given {@code host}. {@code null}, the default, will * leave the host unchanged. - * * @param host the host * @return {@code this} */ @@ -97,7 +95,6 @@ public final class UriModifyingOperationPreprocessor implements OperationPreproc /** * Modifies the URI to use the given {@code port}. - * * @param port the port * @return {@code this} */ @@ -107,7 +104,6 @@ public final class UriModifyingOperationPreprocessor implements OperationPreproc /** * Removes the port from the URI. - * * @return {@code this} */ public UriModifyingOperationPreprocessor removePort() { @@ -140,7 +136,7 @@ public final class UriModifyingOperationPreprocessor implements OperationPreproc URI modifiedUri = uriBuilder.build(true).toUri(); HttpHeaders modifiedHeaders = modify(request.getHeaders()); modifiedHeaders.set(HttpHeaders.HOST, modifiedUri.getHost() - + (modifiedUri.getPort() == -1 ? "" : ":" + modifiedUri.getPort())); + + ((modifiedUri.getPort() != -1) ? ":" + modifiedUri.getPort() : "")); return this.contentModifyingDelegate.preprocess(new OperationRequestFactory() .create(uriBuilder.build(true).toUri(), request.getMethod(), request.getContent(), modifiedHeaders, request.getParameters(), 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 920b2e90..11c5b7ae 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 @@ -25,6 +25,7 @@ import java.net.URLClassLoader; import java.nio.charset.StandardCharsets; import java.util.regex.Pattern; +import com.jayway.restassured.RestAssured; import com.jayway.restassured.builder.RequestSpecBuilder; import com.jayway.restassured.specification.RequestSpecification; import org.assertj.core.api.Condition; @@ -36,10 +37,16 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.restdocs.JUnitRestDocumentation; +import org.springframework.restdocs.restassured.operation.preprocess.RestAssuredPreprocessors; +import org.springframework.restdocs.templates.TemplateFormat; +import org.springframework.restdocs.templates.TemplateFormats; +import org.springframework.restdocs.test.SnippetConditions; +import org.springframework.restdocs.test.SnippetConditions.CodeBlockCondition; +import org.springframework.restdocs.test.SnippetConditions.HttpRequestCondition; +import org.springframework.restdocs.test.SnippetConditions.HttpResponseCondition; import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.RequestMethod; -import static com.jayway.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; @@ -61,13 +68,6 @@ import static org.springframework.restdocs.request.RequestDocumentation.partWith import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.restdocs.request.RequestDocumentation.requestParts; -import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document; -import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration; -import static org.springframework.restdocs.restassured.operation.preprocess.RestAssuredPreprocessors.modifyUris; -import static org.springframework.restdocs.templates.TemplateFormats.asciidoctor; -import static org.springframework.restdocs.test.SnippetConditions.codeBlock; -import static org.springframework.restdocs.test.SnippetConditions.httpRequest; -import static org.springframework.restdocs.test.SnippetConditions.httpResponse; /** * Integration tests for using Spring REST Docs with REST Assured. @@ -86,9 +86,11 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void defaultSnippetGeneration() { - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("default")).get("/").then().statusCode(200); + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation.document("default")).get("/").then() + .statusCode(200); assertExpectedSnippetFilesExist(new File("build/generated-snippets/default"), "http-request.adoc", "http-response.adoc", "curl-request.adoc"); } @@ -96,15 +98,17 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void curlSnippetWithContent() throws Exception { String contentType = "text/plain; charset=UTF-8"; - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("curl-snippet-with-content")).accept("application/json") - .content("content").contentType(contentType).post("/").then() - .statusCode(200); + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation + .document("curl-snippet-with-content")) + .accept("application/json").content("content").contentType(contentType) + .post("/").then().statusCode(200); assertThat(new File( "build/generated-snippets/curl-snippet-with-content/curl-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash") + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") .withContent(String.format("$ curl 'http://localhost:" + tomcat.getPort() + "/' -i -X POST \\%n" + " -H 'Accept: application/json' \\%n" @@ -115,14 +119,16 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void curlSnippetWithCookies() throws Exception { String contentType = "text/plain; charset=UTF-8"; - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("curl-snippet-with-cookies")).accept("application/json") - .contentType(contentType).cookie("cookieName", "cookieVal").get("/") - .then().statusCode(200); + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation + .document("curl-snippet-with-cookies")) + .accept("application/json").contentType(contentType) + .cookie("cookieName", "cookieVal").get("/").then().statusCode(200); assertThat(new File( "build/generated-snippets/curl-snippet-with-cookies/curl-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash") + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") .withContent(String.format("$ curl 'http://localhost:" + tomcat.getPort() + "/' -i -X GET \\%n" + " -H 'Accept: application/json' \\%n" @@ -133,17 +139,20 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void curlSnippetWithQueryStringOnPost() throws Exception { - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("curl-snippet-with-query-string")) + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation + .document("curl-snippet-with-query-string")) .accept("application/json").param("foo", "bar").param("a", "alpha") .post("/?foo=bar").then().statusCode(200); String contentType = "application/x-www-form-urlencoded; charset=ISO-8859-1"; assertThat(new File( "build/generated-snippets/curl-snippet-with-query-string/curl-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash").withContent( - String.format("$ curl " + "'http://localhost:" - + tomcat.getPort() + "/?foo=bar' -i -X POST \\%n" + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") + .withContent(String.format("$ curl " + + "'http://localhost:" + tomcat.getPort() + + "/?foo=bar' -i -X POST \\%n" + " -H 'Accept: application/json' \\%n" + " -H 'Content-Type: " + contentType + "' \\%n" + " -d 'a=alpha'")))); @@ -151,9 +160,10 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void linksSnippet() throws Exception { - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("links", + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation.document("links", links(linkWithRel("rel").description("The description")))) .accept("application/json").get("/").then().statusCode(200); assertExpectedSnippetFilesExist(new File("build/generated-snippets/links"), @@ -163,9 +173,10 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void pathParametersSnippet() throws Exception { - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("path-parameters", + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation.document("path-parameters", pathParameters( parameterWithName("foo").description("The description")))) .accept("application/json").get("/{foo}", "").then().statusCode(200); @@ -176,9 +187,10 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void requestParametersSnippet() throws Exception { - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("request-parameters", + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation.document("request-parameters", requestParameters( parameterWithName("foo").description("The description")))) .accept("application/json").param("foo", "bar").get("/").then() @@ -191,9 +203,10 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void requestFieldsSnippet() throws Exception { - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("request-fields", + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation.document("request-fields", requestFields(fieldWithPath("a").description("The description")))) .accept("application/json").content("{\"a\":\"alpha\"}").post("/").then() .statusCode(200); @@ -204,9 +217,10 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void requestPartsSnippet() throws Exception { - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("request-parts", + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation.document("request-parts", requestParts(partWithName("a").description("The description")))) .multiPart("a", "foo").post("/upload").then().statusCode(200); assertExpectedSnippetFilesExist( @@ -216,9 +230,10 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void responseFieldsSnippet() throws Exception { - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("response-fields", + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation.document("response-fields", responseFields(fieldWithPath("a").description("The description"), subsectionWithPath("links") .description("Links to other resources")))) @@ -230,9 +245,11 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void parameterizedOutputDirectory() throws Exception { - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("{method-name}")).get("/").then().statusCode(200); + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation.document("{method-name}")).get("/") + .then().statusCode(200); assertExpectedSnippetFilesExist( new File("build/generated-snippets/parameterized-output-directory"), "http-request.adoc", "http-response.adoc", "curl-request.adoc"); @@ -241,17 +258,19 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void multiStep() throws Exception { RequestSpecification spec = new RequestSpecBuilder().setPort(tomcat.getPort()) - .addFilter(documentationConfiguration(this.restDocumentation)) - .addFilter(document("{method-name}-{step}")).build(); - given(spec).get("/").then().statusCode(200); + .addFilter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .addFilter(RestAssuredRestDocumentation.document("{method-name}-{step}")) + .build(); + RestAssured.given(spec).get("/").then().statusCode(200); assertExpectedSnippetFilesExist( new File("build/generated-snippets/multi-step-1/"), "http-request.adoc", "http-response.adoc", "curl-request.adoc"); - given(spec).get("/").then().statusCode(200); + RestAssured.given(spec).get("/").then().statusCode(200); assertExpectedSnippetFilesExist( new File("build/generated-snippets/multi-step-2/"), "http-request.adoc", "http-response.adoc", "curl-request.adoc"); - given(spec).get("/").then().statusCode(200); + RestAssured.given(spec).get("/").then().statusCode(200); assertExpectedSnippetFilesExist( new File("build/generated-snippets/multi-step-3/"), "http-request.adoc", "http-response.adoc", "curl-request.adoc"); @@ -259,11 +278,13 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void additionalSnippets() throws Exception { - RestDocumentationFilter documentation = document("{method-name}-{step}"); + RestDocumentationFilter documentation = RestAssuredRestDocumentation + .document("{method-name}-{step}"); RequestSpecification spec = new RequestSpecBuilder().setPort(tomcat.getPort()) - .addFilter(documentationConfiguration(this.restDocumentation)) + .addFilter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) .addFilter(documentation).build(); - given(spec) + RestAssured.given(spec) .filter(documentation .document(responseHeaders(headerWithName("a").description("one"), headerWithName("Foo").description("two")))) @@ -276,70 +297,81 @@ public class RestAssuredRestDocumentationIntegrationTests { @Test public void responseWithCookie() { - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("set-cookie", + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation.document("set-cookie", preprocessResponse(removeHeaders(HttpHeaders.DATE, 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"); assertThat(new File("build/generated-snippets/set-cookie/http-response.adoc")) - .has(content(httpResponse(asciidoctor(), HttpStatus.OK).header( - HttpHeaders.SET_COOKIE, - "name=value; Domain=localhost; HttpOnly"))); + .has(content(httpResponse(TemplateFormats.asciidoctor(), HttpStatus.OK) + .header(HttpHeaders.SET_COOKIE, + "name=value; Domain=localhost; HttpOnly"))); } @Test public void preprocessedRequest() throws Exception { Pattern pattern = Pattern.compile("(\"alpha\")"); - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) .header("a", "alpha").header("b", "bravo").contentType("application/json") .accept("application/json").content("{\"a\":\"alpha\"}") - .filter(document("original-request")) - .filter(document("preprocessed-request", + .filter(RestAssuredRestDocumentation.document("original-request")) + .filter(RestAssuredRestDocumentation.document("preprocessed-request", preprocessRequest(prettyPrint(), replacePattern(pattern, "\"<>\""), - modifyUris().removePort(), + RestAssuredPreprocessors.modifyUris().removePort(), removeHeaders("a", HttpHeaders.CONTENT_LENGTH)))) .get("/").then().statusCode(200); assertThat( new File("build/generated-snippets/original-request/http-request.adoc")) - .has(content(httpRequest(asciidoctor(), RequestMethod.GET, "/") - .header("a", "alpha").header("b", "bravo") - .header("Accept", MediaType.APPLICATION_JSON_VALUE) - .header("Content-Type", "application/json; charset=UTF-8") - .header("Host", "localhost:" + tomcat.getPort()) - .header("Content-Length", "13") - .content("{\"a\":\"alpha\"}"))); + .has(content(httpRequest(TemplateFormats.asciidoctor(), + RequestMethod.GET, "/").header("a", "alpha") + .header("b", "bravo") + .header("Accept", + MediaType.APPLICATION_JSON_VALUE) + .header("Content-Type", + "application/json; charset=UTF-8") + .header("Host", "localhost:" + tomcat.getPort()) + .header("Content-Length", "13") + .content("{\"a\":\"alpha\"}"))); String prettyPrinted = String.format("{%n \"a\" : \"<>\"%n}"); assertThat(new File( "build/generated-snippets/preprocessed-request/http-request.adoc")) - .has(content(httpRequest(asciidoctor(), RequestMethod.GET, "/") - .header("b", "bravo") - .header("Accept", MediaType.APPLICATION_JSON_VALUE) - .header("Content-Type", "application/json; charset=UTF-8") - .header("Host", "localhost").content(prettyPrinted))); + .has(content(httpRequest(TemplateFormats.asciidoctor(), + RequestMethod.GET, "/") + .header("b", "bravo") + .header("Accept", + MediaType.APPLICATION_JSON_VALUE) + .header("Content-Type", + "application/json; charset=UTF-8") + .header("Host", "localhost") + .content(prettyPrinted))); } @Test public void preprocessedResponse() throws Exception { Pattern pattern = Pattern.compile("(\"alpha\")"); - given().port(tomcat.getPort()) - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("original-response")) - .filter(document("preprocessed-response", preprocessResponse( - prettyPrint(), maskLinks(), - removeHeaders("a", "Transfer-Encoding", "Date", "Server"), - replacePattern(pattern, "\"<>\""), modifyUris() - .scheme("https").host("api.example.com").removePort()))) + RestAssured.given().port(tomcat.getPort()) + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation.document("original-response")) + .filter(RestAssuredRestDocumentation.document("preprocessed-response", + preprocessResponse(prettyPrint(), maskLinks(), + removeHeaders("a", "Transfer-Encoding", "Date", "Server"), + replacePattern(pattern, "\"<>\""), + RestAssuredPreprocessors.modifyUris().scheme("https") + .host("api.example.com").removePort()))) .get("/").then().statusCode(200); String prettyPrinted = String.format("{%n \"a\" : \"<>\",%n \"links\" : " + "[ {%n \"rel\" : \"rel\",%n \"href\" : \"...\"%n } ]%n}"); assertThat(new File( - "build/generated-snippets/preprocessed-response/http-response.adoc")) - .has(content(httpResponse(asciidoctor(), HttpStatus.OK) + "build/generated-snippets/preprocessed-response/http-response.adoc")).has( + content(httpResponse(TemplateFormats.asciidoctor(), HttpStatus.OK) .header("Foo", "https://api.example.com/foo/bar") .header("Content-Type", "application/json;charset=UTF-8") .header(HttpHeaders.CONTENT_LENGTH, @@ -355,10 +387,12 @@ public class RestAssuredRestDocumentationIntegrationTests { ClassLoader previous = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(classLoader); try { - given().port(tomcat.getPort()).accept("application/json") - .filter(documentationConfiguration(this.restDocumentation)) - .filter(document("custom-snippet-template")).get("/").then() - .statusCode(200); + RestAssured.given().port(tomcat.getPort()).accept("application/json") + .filter(RestAssuredRestDocumentation + .documentationConfiguration(this.restDocumentation)) + .filter(RestAssuredRestDocumentation + .document("custom-snippet-template")) + .get("/").then().statusCode(200); } finally { Thread.currentThread().setContextClassLoader(previous); @@ -374,6 +408,19 @@ public class RestAssuredRestDocumentationIntegrationTests { } } + private CodeBlockCondition codeBlock(TemplateFormat format, String language) { + return SnippetConditions.codeBlock(format, language); + } + + private HttpRequestCondition httpRequest(TemplateFormat format, + RequestMethod requestMethod, String uri) { + return SnippetConditions.httpRequest(format, requestMethod, uri); + } + + private HttpResponseCondition httpResponse(TemplateFormat format, HttpStatus status) { + return SnippetConditions.httpResponse(format, status); + } + private Condition content(final Condition delegate) { return new Condition() { 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 2785fa74..0e1011f9 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 @@ -36,6 +36,12 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.restdocs.JUnitRestDocumentation; +import org.springframework.restdocs.templates.TemplateFormat; +import org.springframework.restdocs.templates.TemplateFormats; +import org.springframework.restdocs.test.SnippetConditions; +import org.springframework.restdocs.test.SnippetConditions.CodeBlockCondition; +import org.springframework.restdocs.test.SnippetConditions.HttpRequestCondition; +import org.springframework.restdocs.test.SnippetConditions.HttpResponseCondition; import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.RequestMethod; @@ -64,10 +70,6 @@ import static org.springframework.restdocs.request.RequestDocumentation.requestP 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.SnippetConditions.codeBlock; -import static org.springframework.restdocs.test.SnippetConditions.httpRequest; -import static org.springframework.restdocs.test.SnippetConditions.httpResponse; /** * Integration tests for using Spring REST Docs with REST Assured. @@ -103,7 +105,7 @@ public class RestAssuredRestDocumentationIntegrationTests { assertThat(new File( "build/generated-snippets/curl-snippet-with-content/curl-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash") + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") .withContent(String.format("$ curl 'http://localhost:" + tomcat.getPort() + "/' -i -X POST \\%n" + " -H 'Accept: application/json' \\%n" @@ -121,7 +123,7 @@ public class RestAssuredRestDocumentationIntegrationTests { .then().statusCode(200); assertThat(new File( "build/generated-snippets/curl-snippet-with-cookies/curl-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash") + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") .withContent(String.format("$ curl 'http://localhost:" + tomcat.getPort() + "/' -i -X GET \\%n" + " -H 'Accept: application/json' \\%n" @@ -140,9 +142,10 @@ public class RestAssuredRestDocumentationIntegrationTests { String contentType = "application/x-www-form-urlencoded; charset=ISO-8859-1"; assertThat(new File( "build/generated-snippets/curl-snippet-with-query-string/curl-request.adoc")) - .has(content(codeBlock(asciidoctor(), "bash").withContent( - String.format("$ curl " + "'http://localhost:" - + tomcat.getPort() + "/?foo=bar' -i -X POST \\%n" + .has(content(codeBlock(TemplateFormats.asciidoctor(), "bash") + .withContent(String.format("$ curl " + + "'http://localhost:" + tomcat.getPort() + + "/?foo=bar' -i -X POST \\%n" + " -H 'Accept: application/json' \\%n" + " -H 'Content-Type: " + contentType + "' \\%n" + " -d 'a=alpha'")))); @@ -284,9 +287,9 @@ public class RestAssuredRestDocumentationIntegrationTests { assertExpectedSnippetFilesExist(new File("build/generated-snippets/set-cookie"), "http-request.adoc", "http-response.adoc", "curl-request.adoc"); assertThat(new File("build/generated-snippets/set-cookie/http-response.adoc")) - .has(content(httpResponse(asciidoctor(), HttpStatus.OK).header( - HttpHeaders.SET_COOKIE, - "name=value; Domain=localhost; HttpOnly"))); + .has(content(httpResponse(TemplateFormats.asciidoctor(), HttpStatus.OK) + .header(HttpHeaders.SET_COOKIE, + "name=value; Domain=localhost; HttpOnly"))); } @Test @@ -305,21 +308,28 @@ public class RestAssuredRestDocumentationIntegrationTests { .get("/").then().statusCode(200); assertThat( new File("build/generated-snippets/original-request/http-request.adoc")) - .has(content(httpRequest(asciidoctor(), RequestMethod.GET, "/") - .header("a", "alpha").header("b", "bravo") - .header("Accept", MediaType.APPLICATION_JSON_VALUE) - .header("Content-Type", "application/json; charset=UTF-8") - .header("Host", "localhost:" + tomcat.getPort()) - .header("Content-Length", "13") - .content("{\"a\":\"alpha\"}"))); + .has(content(httpRequest(TemplateFormats.asciidoctor(), + RequestMethod.GET, "/").header("a", "alpha") + .header("b", "bravo") + .header("Accept", + MediaType.APPLICATION_JSON_VALUE) + .header("Content-Type", + "application/json; charset=UTF-8") + .header("Host", "localhost:" + tomcat.getPort()) + .header("Content-Length", "13") + .content("{\"a\":\"alpha\"}"))); String prettyPrinted = String.format("{%n \"a\" : \"<>\"%n}"); assertThat(new File( "build/generated-snippets/preprocessed-request/http-request.adoc")) - .has(content(httpRequest(asciidoctor(), RequestMethod.GET, "/") - .header("b", "bravo") - .header("Accept", MediaType.APPLICATION_JSON_VALUE) - .header("Content-Type", "application/json; charset=UTF-8") - .header("Host", "localhost").content(prettyPrinted))); + .has(content(httpRequest(TemplateFormats.asciidoctor(), + RequestMethod.GET, "/") + .header("b", "bravo") + .header("Accept", + MediaType.APPLICATION_JSON_VALUE) + .header("Content-Type", + "application/json; charset=UTF-8") + .header("Host", "localhost") + .content(prettyPrinted))); } @Test @@ -337,8 +347,8 @@ public class RestAssuredRestDocumentationIntegrationTests { String prettyPrinted = String.format("{%n \"a\" : \"<>\",%n \"links\" : " + "[ {%n \"rel\" : \"rel\",%n \"href\" : \"...\"%n } ]%n}"); assertThat(new File( - "build/generated-snippets/preprocessed-response/http-response.adoc")) - .has(content(httpResponse(asciidoctor(), HttpStatus.OK) + "build/generated-snippets/preprocessed-response/http-response.adoc")).has( + content(httpResponse(TemplateFormats.asciidoctor(), HttpStatus.OK) .header("Foo", "https://api.example.com/foo/bar") .header("Content-Type", "application/json;charset=UTF-8") .header(HttpHeaders.CONTENT_LENGTH, @@ -392,4 +402,17 @@ public class RestAssuredRestDocumentationIntegrationTests { }; } + private CodeBlockCondition codeBlock(TemplateFormat format, String language) { + return SnippetConditions.codeBlock(format, language); + } + + private HttpRequestCondition httpRequest(TemplateFormat format, + RequestMethod requestMethod, String uri) { + return SnippetConditions.httpRequest(format, requestMethod, uri); + } + + private HttpResponseCondition httpResponse(TemplateFormat format, HttpStatus status) { + return SnippetConditions.httpResponse(format, status); + } + }