diff --git a/build.gradle b/build.gradle index 7f849e63..ac4c5afa 100644 --- a/build.gradle +++ b/build.gradle @@ -47,8 +47,6 @@ subprojects { apply plugin: 'propdeps-eclipse' apply plugin: 'propdeps-maven' apply plugin: 'maven' - apply plugin: 'checkstyle' - apply from: "${rootProject.projectDir}/gradle/publish-maven.gradle" sourceCompatibility = 1.7 targetCompatibility = 1.7 @@ -73,8 +71,32 @@ subprojects { } } + test { + testLogging { + exceptionFormat "full" + } + } + + eclipseJdt { + inputFile = rootProject.file('config/eclipse/org.eclipse.jdt.core.prefs') + doLast { + project.file('.settings/org.eclipse.jdt.ui.prefs').withWriter { writer -> + writer << rootProject.file('config/eclipse/org.eclipse.jdt.ui.prefs').text + } + } + } + +} + +configure(subprojects - project(":docs")) { subproject -> + + apply plugin: 'checkstyle' + apply from: "${rootProject.projectDir}/gradle/publish-maven.gradle" + checkstyle { - configFile = rootProject.file('checkstyle.xml') + configFile = rootProject.file('config/checkstyle/checkstyle.xml') + configProperties = [ 'checkstyle.config.dir' : rootProject.file('config/checkstyle') ] + toolVersion = '6.10.1' } configurations { @@ -85,12 +107,6 @@ subprojects { jacoco 'org.jacoco:org.jacoco.agent::runtime' } - test { - testLogging { - exceptionFormat "full" - } - } - javadoc { description = "Generates project-level javadoc for use in -javadoc jar" options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED @@ -101,9 +117,6 @@ subprojects { options.addStringOption '-quiet' } - eclipseJdt.onlyIf { false } - cleanEclipseJdt.onlyIf { false } - task sourcesJar(type: Jar) { classifier = 'sources' from project.sourceSets.main.allSource diff --git a/checkstyle.xml b/checkstyle.xml deleted file mode 100644 index 4e7653a2..00000000 --- a/checkstyle.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/checkstyle/checkstyle-header.txt b/config/checkstyle/checkstyle-header.txt new file mode 100644 index 00000000..154aaa1a --- /dev/null +++ b/config/checkstyle/checkstyle-header.txt @@ -0,0 +1,17 @@ +^\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 new file mode 100644 index 00000000..af08f1a2 --- /dev/null +++ b/config/checkstyle/checkstyle-import-control.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/config/checkstyle/checkstyle-suppressions.xml b/config/checkstyle/checkstyle-suppressions.xml new file mode 100644 index 00000000..f74d9234 --- /dev/null +++ b/config/checkstyle/checkstyle-suppressions.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 00000000..117567d1 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-restdocs-core/.settings/org.eclipse.jdt.core.prefs b/config/eclipse/org.eclipse.jdt.core.prefs similarity index 79% rename from spring-restdocs-core/.settings/org.eclipse.jdt.core.prefs rename to config/eclipse/org.eclipse.jdt.core.prefs index f9627361..5281c3b4 100644 --- a/spring-restdocs-core/.settings/org.eclipse.jdt.core.prefs +++ b/config/eclipse/org.eclipse.jdt.core.prefs @@ -10,14 +10,100 @@ org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=default +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=default +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=ignore +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 @@ -46,8 +132,8 @@ org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=1 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 org.eclipse.jdt.core.formatter.blank_lines_before_method=1 @@ -100,7 +186,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=8 +org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert @@ -128,7 +214,7 @@ org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert diff --git a/config/eclipse/org.eclipse.jdt.ui.prefs b/config/eclipse/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..c5e23c90 --- /dev/null +++ b/config/eclipse/org.eclipse.jdt.ui.prefs @@ -0,0 +1,125 @@ +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=false +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=true +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_functional_interfaces=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=false +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.insert_inferred_type_arguments=false +cleanup.make_local_variable_final=false +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=false +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_redundant_type_arguments=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=false +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_anonymous_class_creation=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_lambda=true +cleanup.use_parentheses_in_expressions=false +cleanup.use_this_for_non_static_field_access=false +cleanup.use_this_for_non_static_field_access_only_if_necessary=false +cleanup.use_this_for_non_static_method_access=false +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_type_arguments=false +cleanup_profile=_Spring REST Docs Cleanup Conventions +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_Spring REST Docs Java Conventions +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=e +org.eclipse.jdt.ui.gettersetter.use.is=false +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com;;\#; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=9999 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=9999 +org.eclipse.jdt.ui.text.custom_code_templates= +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=true +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=true +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b5166dad..e8c6bf7b 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d94401f1..ed0a26aa 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Jul 28 11:16:06 BST 2015 +#Wed Sep 23 15:50:30 BST 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip diff --git a/gradlew b/gradlew index 91a7e269..97fac783 100755 --- a/gradlew +++ b/gradlew @@ -42,11 +42,6 @@ case "`uname`" in ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" @@ -114,6 +109,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` diff --git a/samples/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.core.prefs b/samples/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.core.prefs index 83412a90..30f00a94 100644 --- a/samples/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.core.prefs +++ b/samples/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.core.prefs @@ -8,6 +8,7 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 diff --git a/samples/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.ui.prefs b/samples/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.ui.prefs index 6518db6a..1f4325cd 100644 --- a/samples/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.ui.prefs +++ b/samples/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.ui.prefs @@ -13,7 +13,7 @@ cleanup.always_use_this_for_non_static_field_access=true cleanup.always_use_this_for_non_static_method_access=false cleanup.convert_functional_interfaces=false cleanup.convert_to_enhanced_for_loop=false -cleanup.correct_indentation=false +cleanup.correct_indentation=true cleanup.format_source_code=true cleanup.format_source_code_changes_only=false cleanup.insert_inferred_type_arguments=false diff --git a/samples/rest-notes-spring-hateoas/.settings/org.eclipse.jdt.ui.prefs b/samples/rest-notes-spring-hateoas/.settings/org.eclipse.jdt.ui.prefs index 6518db6a..1f4325cd 100644 --- a/samples/rest-notes-spring-hateoas/.settings/org.eclipse.jdt.ui.prefs +++ b/samples/rest-notes-spring-hateoas/.settings/org.eclipse.jdt.ui.prefs @@ -13,7 +13,7 @@ cleanup.always_use_this_for_non_static_field_access=true cleanup.always_use_this_for_non_static_method_access=false cleanup.convert_functional_interfaces=false cleanup.convert_to_enhanced_for_loop=false -cleanup.correct_indentation=false +cleanup.correct_indentation=true cleanup.format_source_code=true cleanup.format_source_code_changes_only=false cleanup.insert_inferred_type_arguments=false diff --git a/spring-restdocs-core/.settings/org.eclipse.jdt.ui.prefs b/spring-restdocs-core/.settings/org.eclipse.jdt.ui.prefs index dc84ae74..c5e23c90 100644 --- a/spring-restdocs-core/.settings/org.eclipse.jdt.ui.prefs +++ b/spring-restdocs-core/.settings/org.eclipse.jdt.ui.prefs @@ -50,21 +50,27 @@ cleanup.use_blocks=true cleanup.use_blocks_only_for_return_and_throw=false cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=false -cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access=false cleanup.use_this_for_non_static_field_access_only_if_necessary=false cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access_only_if_necessary=true cleanup.use_type_arguments=false -cleanup_profile=_Spring Rest Docs Cleanup Conventions +cleanup_profile=_Spring REST Docs Cleanup Conventions cleanup_settings_version=2 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_Spring Rest Docs Java Conventions +formatter_profile=_Spring REST Docs Java Conventions formatter_settings_version=12 org.eclipse.jdt.ui.exception.name=e -org.eclipse.jdt.ui.gettersetter.use.is=true -org.eclipse.jdt.ui.keywordthis=true +org.eclipse.jdt.ui.gettersetter.use.is=false +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com;;\#; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=9999 org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=9999 +org.eclipse.jdt.ui.text.custom_code_templates= sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true @@ -75,22 +81,20 @@ sp_cleanup.add_missing_override_annotations=true sp_cleanup.add_missing_override_annotations_interface_methods=true sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_parentheses_in_expressions=true sp_cleanup.always_use_this_for_non_static_field_access=true -sp_cleanup.always_use_this_for_non_static_method_access=true -sp_cleanup.convert_functional_interfaces=false +sp_cleanup.always_use_this_for_non_static_method_access=false sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true sp_cleanup.format_source_code_changes_only=false -sp_cleanup.insert_inferred_type_arguments=false -sp_cleanup.make_local_variable_final=true +sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true +sp_cleanup.make_private_fields_final=false sp_cleanup.make_type_abstract_if_missing_method=false sp_cleanup.make_variable_declarations_final=false sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.never_use_parentheses_in_expressions=false sp_cleanup.on_save_use_additional_actions=true sp_cleanup.organize_imports=true sp_cleanup.qualify_static_field_accesses_with_declaring_class=false @@ -99,13 +103,12 @@ sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class= sp_cleanup.qualify_static_member_accesses_with_declaring_class=true sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_redundant_type_arguments=true -sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces=true sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_imports=true sp_cleanup.remove_unused_local_variables=false sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false @@ -113,13 +116,10 @@ sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false -sp_cleanup.use_anonymous_class_creation=false -sp_cleanup.use_blocks=false +sp_cleanup.use_blocks=true sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_lambda=true sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=true sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false sp_cleanup.use_this_for_non_static_method_access=false -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=false -sp_cleanup.use_type_arguments=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true 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 fc72501e..401b6713 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 @@ -37,7 +37,7 @@ public class RestDocumentation implements TestRule { /** * Creates a new {@code RestDocumentation} instance that will generate snippets to the - * given {@code outputDirectory} + * given {@code outputDirectory}. * * @param outputDirectory the output directory */ 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 cad0c71e..86dbf6c8 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,7 @@ 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. @@ -52,7 +52,7 @@ public final class RestDocumentationContext { } /** - * Returns the class whose tests are currently executing + * Returns the class whose tests are currently executing. * * @return The test class */ @@ -61,8 +61,8 @@ public final class RestDocumentationContext { } /** - * Returns the name of the test method that is currently executing - * + * Returns the name of the test method that is currently executing. + * * @return The name of the test method */ public String getTestMethodName() { @@ -70,7 +70,7 @@ public final class RestDocumentationContext { } /** - * Returns the current step count and then increments it + * Returns the current step count and then increments it. * * @return The step count prior to it being incremented */ @@ -79,7 +79,7 @@ public final class RestDocumentationContext { } /** - * Returns the current step count + * Returns the current step count. * * @return The current step count */ @@ -89,7 +89,7 @@ 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/constraints/Constraint.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/Constraint.java index 1adf117e..31a3fd51 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 @@ -19,8 +19,8 @@ package org.springframework.restdocs.constraints; import java.util.Map; /** - * A constraint - * + * A constraint. + * * @author Andy Wilkinson */ public class Constraint { @@ -32,7 +32,7 @@ public class Constraint { /** * Creates a new {@code Constraint} with the given {@code name} and * {@code configuration}. - * + * * @param name the name * @param configuration the configuration */ @@ -42,8 +42,8 @@ public class Constraint { } /** - * Returns the name of the constraint - * + * Returns the name of the constraint. + * * @return the name */ public String getName() { @@ -51,8 +51,8 @@ public class Constraint { } /** - * Returns the configuration of the 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 7a428e3f..2bd63472 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 @@ -18,7 +18,7 @@ package org.springframework.restdocs.constraints; /** * Resolves a description for a {@link Constraint}. - * + * * @author Andy Wilkinson * */ @@ -26,9 +26,9 @@ public interface ConstraintDescriptionResolver { /** * Resolves the description for the given {@code constraint}. - * + * * @param constraint the constraint * @return the description */ - public String resolveDescription(Constraint constraint); + String resolveDescription(Constraint constraint); } 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 23d55d8c..7fc11026 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 @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.List; /** - * Provides access to descriptions of a class's constraints - * + * Provides access to descriptions of a class's constraints. + * * @author Andy Wilkinson */ public class ConstraintDescriptions { @@ -38,7 +38,7 @@ 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 +51,7 @@ 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 */ @@ -63,7 +63,7 @@ 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 */ @@ -76,7 +76,7 @@ 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 @@ -89,8 +89,8 @@ public class ConstraintDescriptions { } /** - * Returns a list of the descriptions for the constraints on the given property - * + * Returns a list of the descriptions for the constraints on the given property. + * * @param property the property * @return the list of constraint descriptions */ @@ -104,5 +104,4 @@ 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 8f5c6580..ed5ce37a 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 @@ -20,7 +20,7 @@ import java.util.List; /** * An abstraction for resolving a class's constraints. - * + * * @author Andy Wilkinson */ public interface ConstraintResolver { @@ -28,7 +28,7 @@ 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 7ea94a8d..660ed4b5 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 @@ -45,7 +45,7 @@ import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; * {@code javax.validation.constraints.NotNull.description}. *

* Default descriptions are provided for Bean Validation 1.1's constraints: - * + * *

    *
  • {@link AssertFalse} *
  • {@link AssertTrue} @@ -61,7 +61,7 @@ import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; *
  • {@link Pattern} *
  • {@link Size} *
- * + * * @author Andy Wilkinson */ public class ResourceBundleConstraintDescriptionResolver implements @@ -78,7 +78,7 @@ public class ResourceBundleConstraintDescriptionResolver implements * Creates a new {@code ResourceBundleConstraintDescriptionResolver} that will resolve * descriptions by looking them up in a resource bundle with the base name * {@code org.springframework.restdocs.constraints.ConstraintDescriptions} in the - * default locale loaded using the thread context class loader + * default locale loaded using the thread context class loader. */ public ResourceBundleConstraintDescriptionResolver() { this(getBundle("ConstraintDescriptions")); @@ -87,7 +87,7 @@ public class ResourceBundleConstraintDescriptionResolver implements /** * 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) { @@ -126,7 +126,8 @@ public class ResourceBundleConstraintDescriptionResolver implements return this.defaultDescriptions.getString(key); } - private static class ConstraintPlaceholderResolver implements PlaceholderResolver { + private static final class ConstraintPlaceholderResolver implements + PlaceholderResolver { private final Constraint constraint; 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 041f2bd3..664691c6 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 @@ -32,7 +32,7 @@ import javax.validation.metadata.PropertyDescriptor; * constraints. The name of the constraint is the fully-qualified class name of the * constraint annotation. For example, a {@link NotNull} constraint will be named * {@code javax.validation.constraints.NotNull}. - * + * * @author Andy Wilkinson * */ @@ -43,7 +43,7 @@ public class ValidatorConstraintResolver implements ConstraintResolver { /** * Creates a new {@code ValidatorConstraintResolver} that will use a {@link Validator} * in its default configuration to resolve constraints. - * + * * @see Validation#buildDefaultValidatorFactory() * @see ValidatorFactory#getValidator() */ @@ -54,7 +54,7 @@ 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) { @@ -78,5 +78,4 @@ public class ValidatorConstraintResolver implements ConstraintResolver { } return constraints; } - } diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/package-info.java index 1692913c..9fc48616 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/package-info.java @@ -17,4 +17,5 @@ /** * Documenting a RESTful API's constraints. */ -package org.springframework.restdocs.constraints; \ No newline at end of file +package org.springframework.restdocs.constraints; + 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 0802bdf4..9270c126 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 @@ -53,7 +53,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 */ protected CurlRequestSnippet(Map attributes) { 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 12409098..85ee026a 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 @@ -17,4 +17,5 @@ /** * Documenting the curl command required to make a request to a RESTful API. */ -package org.springframework.restdocs.curl; \ No newline at end of file +package org.springframework.restdocs.curl; + 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 c097e40e..9aae38b7 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 @@ -22,7 +22,7 @@ import org.springframework.restdocs.snippet.Snippet; /** * Static factory methods for documenting a RESTful API's HTTP requests. - * + * * @author Andy Wilkinson * @author Jonathan Pearlin */ @@ -35,7 +35,7 @@ public abstract class HttpDocumentation { /** * Returns a handler that will produce a snippet containing the HTTP request for the * API call. - * + * * @return the handler that will produce the snippet */ public static Snippet httpRequest() { 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 322474d6..23bba3a9 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 @@ -55,7 +55,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 */ protected HttpRequestSnippet(Map attributes) { @@ -186,4 +186,4 @@ public class HttpRequestSnippet extends TemplatedSnippet { return header; } -} \ No newline at end of file +} 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 b3483a54..e8f65950 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 @@ -47,7 +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 */ protected HttpResponseSnippet(Map attributes) { @@ -86,4 +86,5 @@ public class HttpResponseSnippet extends TemplatedSnippet { header.put("value", value); return header; } -} \ No newline at end of file + +} diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/package-info.java index 258da97d..5d320601 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/http/package-info.java @@ -18,4 +18,5 @@ * Documenting the HTTP request sent to a RESTful API and the HTTP response that is * returned. */ -package org.springframework.restdocs.http; \ No newline at end of file +package org.springframework.restdocs.http; + diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/AbstractJsonLinkExtractor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/AbstractJsonLinkExtractor.java index ed877ab7..4b952ca2 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/AbstractJsonLinkExtractor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/AbstractJsonLinkExtractor.java @@ -25,8 +25,8 @@ import org.springframework.restdocs.operation.OperationResponse; import com.fasterxml.jackson.databind.ObjectMapper; /** - * Abstract base class for a {@link LinkExtractor} that extracts links from JSON - * + * Abstract base class for a {@link LinkExtractor} that extracts links from JSON. + * * @author Andy Wilkinson */ abstract class AbstractJsonLinkExtractor implements LinkExtractor { @@ -43,4 +43,5 @@ abstract class AbstractJsonLinkExtractor implements LinkExtractor { } protected abstract Map> extractLinks(Map json); -} \ No newline at end of file + +} 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 e7bc955f..ad12497a 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 @@ -25,7 +25,7 @@ import org.springframework.util.MultiValueMap; /** * {@link LinkExtractor} that extracts links in Atom format. - * + * * @author Andy Wilkinson */ @SuppressWarnings("unchecked") @@ -62,4 +62,5 @@ class AtomLinkExtractor extends AbstractJsonLinkExtractor { extractedLinks.add(link.getRel(), link); } } -} \ No newline at end of file + +} 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 7bc57fff..c3f28d73 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 @@ -28,7 +28,7 @@ import org.springframework.http.MediaType; /** * {@link LinkExtractor} that extracts links in Hypermedia Application Language (HAL) * format. - * + * * @author Andy Wilkinson */ class HalLinkExtractor extends AbstractJsonLinkExtractor { @@ -77,4 +77,5 @@ class HalLinkExtractor extends AbstractJsonLinkExtractor { links.add(possibleLink); } } -} \ No newline at end of file + +} 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 968f5dad..b167225e 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 @@ -23,7 +23,7 @@ import org.springframework.restdocs.snippet.Snippet; /** * Static factory methods for documenting a RESTful API that utilizes Hypermedia. - * + * * @author Andy Wilkinson */ public abstract class HypermediaDocumentation { @@ -34,7 +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 * @return a {@code LinkDescriptor} ready for further configuration */ @@ -46,7 +46,7 @@ public abstract class HypermediaDocumentation { * Returns a handler that will produce a snippet documenting the links in the API * call's response. Links will be extracted from the response automatically based on * its content type. - * + * * @param descriptors The descriptions of the response's links * @return the handler */ @@ -60,22 +60,22 @@ public abstract class HypermediaDocumentation { * call's response. The given {@code attributes} will be available during snippet * generation. Links will be extracted from the response automatically based on its * content type. - * + * * @param attributes Attributes made available during rendering of the links snippet * @param descriptors The descriptions of the response's links * @return the handler */ public static Snippet links(Map attributes, LinkDescriptor... descriptors) { - return new LinksSnippet(new ContentTypeLinkExtractor(), Arrays.asList(descriptors), - attributes); + return new LinksSnippet(new ContentTypeLinkExtractor(), + Arrays.asList(descriptors), attributes); } /** * Returns a handler that will produce a snippet documenting the links in the API * call's response. Links will be extracted from the response using the given * {@code linkExtractor}. - * + * * @param linkExtractor Used to extract the links from the response * @param descriptors The descriptions of the response's links * @return the handler @@ -90,7 +90,7 @@ public abstract class HypermediaDocumentation { * call's response. The given {@code attributes} will be available during snippet * generation. Links will be extracted from the response using the given * {@code linkExtractor}. - * + * * @param attributes Attributes made available during rendering of the links snippet * @param linkExtractor Used to extract the links from the response * @param descriptors The descriptions of the response's links @@ -98,8 +98,7 @@ public abstract class HypermediaDocumentation { */ public static Snippet links(LinkExtractor linkExtractor, Map attributes, LinkDescriptor... descriptors) { - return new LinksSnippet(linkExtractor, Arrays.asList(descriptors), - attributes); + return new LinksSnippet(linkExtractor, Arrays.asList(descriptors), attributes); } /** 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 694eec9e..eed9dfb4 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 @@ -19,7 +19,7 @@ package org.springframework.restdocs.hypermedia; import org.springframework.core.style.ToStringCreator; /** - * Representation of a link used in a Hypermedia-based API + * Representation of a link used in a Hypermedia-based API. * * @author Andy Wilkinson */ @@ -30,7 +30,7 @@ public class Link { private final String href; /** - * Creates a new {@code Link} with the given {@code rel} and {@code href} + * 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 @@ -41,7 +41,7 @@ public class Link { } /** - * Returns the link's {@code rel} + * Returns the link's {@code rel}. * @return the link's {@code rel} */ public String getRel() { @@ -49,7 +49,7 @@ public class Link { } /** - * Returns the link's {@code href} + * Returns the link's {@code href}. * @return the link's {@code href} */ public String getHref() { 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 cb7e9909..810a5244 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 @@ -19,11 +19,10 @@ package org.springframework.restdocs.hypermedia; import org.springframework.restdocs.snippet.AbstractDescriptor; /** - * A description of a link found in a hypermedia API - * - * @see HypermediaDocumentation#linkWithRel(String) - * + * A description of a link found in a hypermedia API. + * * @author Andy Wilkinson + * @see HypermediaDocumentation#linkWithRel(String) */ public class LinkDescriptor extends AbstractDescriptor { @@ -33,7 +32,7 @@ public class LinkDescriptor extends AbstractDescriptor { /** * 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,7 @@ public class LinkDescriptor extends AbstractDescriptor { } /** - * Marks the link as optional + * Marks the link as optional. * * @return {@code this} */ @@ -51,8 +50,8 @@ public class LinkDescriptor extends AbstractDescriptor { } /** - * Returns the rel of the link described by this descriptor - * + * Returns the rel of the link described by this descriptor. + * * @return the rel */ public final String getRel() { @@ -60,8 +59,8 @@ public class LinkDescriptor extends AbstractDescriptor { } /** - * Returns {@code true} if the described link is optional, otherwise {@code false} - * + * 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/LinksSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinksSnippet.java index d6b225e0..8b5a04d4 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 @@ -52,7 +52,7 @@ 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}. - * + * * @param linkExtractor the link extractor * @param descriptors the link descriptors */ @@ -64,7 +64,7 @@ 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}. The * given {@code attributes} will be included in the model during template rendering. - * + * * @param linkExtractor the link extractor * @param descriptors the link descriptors * @param attributes the additional attributes @@ -139,7 +139,7 @@ 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() { @@ -147,8 +147,8 @@ public class LinksSnippet extends TemplatedSnippet { } /** - * Returns a model for the given {@code descriptor} - * + * Returns a model for the given {@code descriptor}. + * * @param descriptor the descriptor * @return the model */ @@ -161,4 +161,4 @@ public class LinksSnippet extends TemplatedSnippet { return model; } -} \ No newline at end of file +} diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/package-info.java index a792c083..c8d3dab7 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/package-info.java @@ -17,4 +17,5 @@ /** * Documenting a RESTful API that uses hypermedia. */ -package org.springframework.restdocs.hypermedia; \ No newline at end of file +package org.springframework.restdocs.hypermedia; + 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 fdd5fe11..a0053363 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 @@ -20,35 +20,35 @@ import java.util.Map; /** * Describes an operation performed on a RESTful service. - * + * * @author Andy Wilkinson */ 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 919e84ad..052093ce 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 @@ -24,7 +24,7 @@ import org.springframework.http.HttpMethod; /** * The request that was sent as part of performing an operation on a RESTful service. - * + * * @author Andy Wilkinson * @see Operation#getRequest() */ @@ -32,22 +32,22 @@ public interface OperationRequest { /** * Returns the contents of the request. If the request has no content an empty array - * is returned - * + * is returned. + * * @return the contents, never {@code null} */ byte[] getContent(); /** * Returns the headers that were included in the request. - * + * * @return the headers */ HttpHeaders getHeaders(); /** - * Returns the HTTP method of the request - * + * Returns the HTTP method of the request. + * * @return the HTTP method */ HttpMethod getMethod(); @@ -56,7 +56,7 @@ 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(); @@ -64,14 +64,14 @@ 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(); 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 09e9bb80..69a6feca 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 @@ -19,37 +19,37 @@ package org.springframework.restdocs.operation; import org.springframework.http.HttpHeaders; /** - * A part of a multipart request - * - * @author awilkinson + * A part of a multipart request. + * + * @author Andy Wilkinson * @see OperationRequest#getParts() */ 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(); /** * Returns the part's headers. - * + * * @return the headers */ HttpHeaders getHeaders(); 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 d7254477..18485fdb 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 @@ -21,7 +21,7 @@ import org.springframework.http.HttpStatus; /** * The response that was received as part of performing an operation on a RESTful service. - * + * * @author Andy Wilkinson * @see Operation * @see Operation#getRequest() @@ -30,14 +30,14 @@ 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 +45,7 @@ public interface OperationResponse { /** * Returns the contents of the response. If the response has no content an empty array * is returned. - * + * * @return the contents, never {@code null} */ byte[] getContent(); 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 d53392d1..9660a981 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 @@ -24,8 +24,8 @@ import java.util.Map; import org.springframework.util.LinkedMultiValueMap; /** - * The parameters received in a request - * + * The parameters received in a request. + * * @author Andy Wilkinson */ @SuppressWarnings("serial") @@ -33,8 +33,8 @@ 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 - * + * a form-encoded request. + * * @return the query string */ public String toQueryString() { 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 a748df45..736fc4b5 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 @@ -19,8 +19,8 @@ package org.springframework.restdocs.operation; import java.util.Map; /** - * Standard implementation of {@link Operation} - * + * Standard implementation of {@link Operation}. + * * @author Andy Wilkinson */ public class StandardOperation implements Operation { @@ -34,8 +34,8 @@ public class StandardOperation implements Operation { private final Map attributes; /** - * Creates a new {@code StandardOperation} - * + * 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 b4bac39c..9dfac8c0 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 @@ -26,7 +26,7 @@ import org.springframework.http.HttpMethod; /** * Standard implementation of {@link OperationRequest}. - * + * * @author Andy Wilkinson */ public class StandardOperationRequest implements OperationRequest { @@ -46,7 +46,7 @@ public class StandardOperationRequest implements OperationRequest { /** * Creates a new request with the given {@code uri} and {@code method}. The request * will have the given {@code headers}, {@code parameters}, and {@code parts}. - * + * * @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 cfa93d11..b6c7bd03 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 @@ -20,7 +20,7 @@ import org.springframework.http.HttpHeaders; /** * Standard implementation of {@code OperationRequestPart}. - * + * * @author Andy Wilkinson */ public class StandardOperationRequestPart implements OperationRequestPart { @@ -35,7 +35,7 @@ public class StandardOperationRequestPart implements OperationRequestPart { /** * 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 c8fcf401..faac5f5a 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 @@ -21,7 +21,7 @@ import org.springframework.http.HttpStatus; /** * Standard implementation of {@link OperationResponse}. - * + * * @author Andy Wilkinson */ public class StandardOperationResponse implements OperationResponse { @@ -35,7 +35,7 @@ public class StandardOperationResponse implements OperationResponse { /** * 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/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/package-info.java index 2321f69e..d7786bca 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/package-info.java @@ -18,4 +18,5 @@ * Operation API that describes a request that was sent and the response that was * received when calling a RESTful API. */ -package org.springframework.restdocs.operation; \ No newline at end of file +package org.springframework.restdocs.operation; + 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 54fb8279..642c0027 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 @@ -23,15 +23,15 @@ import org.springframework.restdocs.operation.OperationResponse; * A {@code ContentModifier} modifies the content of an {@link OperationRequest} or * {@link OperationResponse} during the preprocessing that is performed prior to * documentation generation. - * + * * @author Andy Wilkinson * @see ContentModifyingOperationPreprocessor */ public interface ContentModifier { /** - * Returns modified content based on the given {@code originalContent} - * + * Returns modified content based on the given {@code originalContent}. + * * @param originalContent the original content * @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 0531c46d..18f5602a 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 @@ -25,7 +25,7 @@ import org.springframework.restdocs.operation.StandardOperationResponse; /** * An {@link OperationPreprocessor} that applies a {@link ContentModifier} to the content * of the request or response. - * + * * @author Andy Wilkinson */ public class ContentModifyingOperationPreprocessor implements OperationPreprocessor { @@ -35,7 +35,7 @@ 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 ee57e83a..76490760 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 @@ -25,7 +25,7 @@ import org.springframework.util.Assert; * An {@link OperationRequestPreprocessor} that delgates to one or more * {@link OperationPreprocessor OperationPreprocessors} to preprocess an * {@link OperationRequest}. - * + * * @author Andy Wilkinson * */ @@ -37,7 +37,7 @@ 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 e200c25d..f55ce4eb 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 @@ -25,7 +25,7 @@ import org.springframework.util.Assert; * An {@link OperationResponsePreprocessor} that delgates to one or more * {@link OperationPreprocessor OperationPreprocessors} to preprocess an * {@link OperationResponse}. - * + * * @author Andy Wilkinson */ class DelegatingOperationResponsePreprocessor implements OperationResponsePreprocessor { @@ -36,7 +36,7 @@ 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/HeaderRemovingOperationPreprocessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeaderRemovingOperationPreprocessor.java index ef258a15..36eba207 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeaderRemovingOperationPreprocessor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeaderRemovingOperationPreprocessor.java @@ -27,8 +27,8 @@ import org.springframework.restdocs.operation.StandardOperationRequest; import org.springframework.restdocs.operation.StandardOperationResponse; /** - * An {@link OperationPreprocessor} that removes headers - * + * An {@link OperationPreprocessor} that removes headers. + * * @author Andy Wilkinson */ class HeaderRemovingOperationPreprocessor implements OperationPreprocessor { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/LinkMaskingContentModifier.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/LinkMaskingContentModifier.java index 74a5ff5f..1a2b56cd 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/LinkMaskingContentModifier.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/LinkMaskingContentModifier.java @@ -19,8 +19,8 @@ package org.springframework.restdocs.operation.preprocess; import java.util.regex.Pattern; /** - * A content modifier the masks the {@code href} of any hypermedia links - * + * A content modifier the masks the {@code href} of any hypermedia links. + * * @author Andy Wilkinson */ class LinkMaskingContentModifier implements ContentModifier { 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 e28bcadd..bfdfbc25 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 @@ -23,22 +23,22 @@ import org.springframework.restdocs.operation.OperationResponse; /** * An {@code OperationPreprocessor} processes the {@link OperationRequest} and * {@link OperationResponse} of an {@link Operation} prior to it being documented. - * + * * @author Andy Wilkinson */ public interface OperationPreprocessor { /** - * Processes the given {@code request} - * + * Processes the given {@code request}. + * * @param request the request to process * @return the processed request */ OperationRequest preprocess(OperationRequest request); /** - * Processes the given {@code response} - * + * 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/OperationRequestPreprocessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationRequestPreprocessor.java index 39fd2132..24cf7535 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 @@ -21,7 +21,7 @@ import org.springframework.restdocs.operation.OperationRequest; /** * An {@code OperationRequestPreprocessor} is used to modify an {@code OperationRequest} * prior to it being documented. - * + * * @author Andy Wilkinson */ public interface OperationRequestPreprocessor { @@ -29,7 +29,7 @@ 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/PatternReplacingContentModifier.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifier.java index 0b702f91..81464c91 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 @@ -22,7 +22,7 @@ import java.util.regex.Pattern; /** * A {@link ContentModifier} that modifies the content by replacing occurrences of a * regular expression {@link Pattern}. - * + * * @author Andy Wilkinson * @author Dewet Diener */ @@ -35,7 +35,7 @@ class PatternReplacingContentModifier implements ContentModifier { /** * Creates a new {@link PatternReplacingContentModifier} that will replace occurences * 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 563b8b53..b4aa590d 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 @@ -28,10 +28,10 @@ import org.springframework.restdocs.operation.OperationResponse; * OperationPreprocessors} that can be applied to an {@link Operation Operation's} * {@link OperationRequest request} or {@link OperationResponse response} before it is * documented. - * + * * @author Andy Wilkinson */ -public class Preprocessors { +public final class Preprocessors { private Preprocessors() { @@ -40,7 +40,7 @@ public 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 */ @@ -52,7 +52,7 @@ public 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 */ @@ -64,7 +64,7 @@ public class Preprocessors { /** * Returns an {@code OperationPreprocessor} that will pretty print the content of the * request or response. - * + * * @return the preprocessor */ public static OperationPreprocessor prettyPrint() { @@ -75,7 +75,7 @@ public class Preprocessors { /** * Returns an {@code OperationPreprocessor} that will remove headers from the request * or response. - * + * * @param headersToRemove the names of the headers to remove * @return the preprocessor */ @@ -86,7 +86,7 @@ public 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() { @@ -96,7 +96,7 @@ public 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 */ @@ -108,8 +108,8 @@ public class Preprocessors { /** * Returns an {@code OperationPreprocessor} that will modify the content of the * request or response by replacing occurences of the given {@code pattern} with the - * given {@code replacement} - * + * given {@code replacement}. + * * @param pattern the pattern * @param replacement the replacement * @return the preprocessor diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifier.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifier.java index 9e193b3e..6902e121 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifier.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifier.java @@ -34,7 +34,7 @@ import com.fasterxml.jackson.databind.SerializationFeature; /** * A {@link ContentModifier} that modifies the content by pretty printing it. - * + * * @author Andy Wilkinson */ public class PrettyPrintingContentModifier implements ContentModifier { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/package-info.java index 2a50da0c..55913531 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/package-info.java @@ -17,4 +17,5 @@ /** * Support for preprocessing an operation prior to it being documented. */ -package org.springframework.restdocs.operation.preprocess; \ No newline at end of file +package org.springframework.restdocs.operation.preprocess; + diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/package-info.java index c237f39a..2d3767b2 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/package-info.java @@ -15,6 +15,7 @@ */ /** - * Core Spring REST Docs classes. + * Core Spring REST Docs classes. */ -package org.springframework.restdocs; \ No newline at end of file +package org.springframework.restdocs; + 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 1aea09df..c96b58f4 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 @@ -46,7 +46,7 @@ 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. - * + * * @param type the type of the fields * @param descriptors the field descriptors * @param attributes the additional attributes @@ -130,7 +130,7 @@ 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 */ @@ -139,7 +139,7 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { /** * Returns the content of the request or response extracted form the given * {@code operation}. - * + * * @param operation The operation * @return The content * @throws IOException if the content cannot be extracted @@ -149,7 +149,7 @@ 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() { @@ -157,8 +157,8 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { } /** - * Returns a model for the given {@code descriptor} - * + * Returns a model for the given {@code descriptor}. + * * @param descriptor the descriptor * @return the model */ @@ -172,4 +172,4 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet { return model; } -} \ No newline at end of file +} 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 0104f143..ce99ff00 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 @@ -19,8 +19,8 @@ package org.springframework.restdocs.payload; import java.util.List; /** - * A handler for the content of a request or response - * + * A handler for the content of a request or response. + * * @author Andy Wilkinson */ interface ContentHandler { @@ -29,7 +29,7 @@ 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 +41,7 @@ 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,10 +52,10 @@ interface ContentHandler { /** * Returns the type of the field with the given {@code path} based on the content of * the payload. - * + * * @param path the field path * @return the type of the field */ Object determineFieldType(String path); -} \ No newline at end of file +} 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 1edd352a..7df08f1f 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 @@ -19,12 +19,11 @@ package org.springframework.restdocs.payload; import org.springframework.restdocs.snippet.AbstractDescriptor; /** - * A description of a field found in a request or response payload - * - * @see PayloadDocumentation#fieldWithPath(String) - * + * A description of a field found in a request or response payload. + * * @author Andreas Evers * @author Andy Wilkinson + * @see PayloadDocumentation#fieldWithPath(String) */ public class FieldDescriptor extends AbstractDescriptor { @@ -46,7 +45,7 @@ public class FieldDescriptor extends AbstractDescriptor { /** * 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 * @return {@code this} * @see JsonFieldType @@ -57,8 +56,8 @@ public class FieldDescriptor extends AbstractDescriptor { } /** - * Marks the field as optional - * + * Marks the field as optional. + * * @return {@code this} */ public final FieldDescriptor optional() { @@ -67,8 +66,8 @@ public class FieldDescriptor extends AbstractDescriptor { } /** - * Returns the path of the field described by this descriptor - * + * Returns the path of the field described by this descriptor. + * * @return the path */ public final String getPath() { @@ -76,8 +75,8 @@ public class FieldDescriptor extends AbstractDescriptor { } /** - * Returns the type of the field described by this descriptor - * + * Returns the type of the field described by this descriptor. + * * @return the type */ public final Object getType() { @@ -85,8 +84,8 @@ public class FieldDescriptor extends AbstractDescriptor { } /** - * Returns {@code true} if the described field is optional, otherwise {@code false} - * + * 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 e2cf4906..37d79493 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 @@ -19,7 +19,7 @@ package org.springframework.restdocs.payload; /** * A {@code FieldDoesNotExistException} is thrown when a requested field does not exist in * a payload. - * + * * @author Andy Wilkinson */ @SuppressWarnings("serial") @@ -28,7 +28,7 @@ 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(JsonFieldPath fieldPath) { 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 c9fa4121..6538491c 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 @@ -19,7 +19,7 @@ package org.springframework.restdocs.payload; /** * A {@code FieldTypeRequiredException} is thrown when a field's type cannot be determined * automatically and, therefore, must be explicitly provided. - * + * * @author Andy Wilkinson */ @SuppressWarnings("serial") @@ -28,7 +28,7 @@ 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/JsonContentHandler.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonContentHandler.java index e20b4f8d..fab1d1a5 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonContentHandler.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonContentHandler.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; /** - * A {@link ContentHandler} for JSON content + * A {@link ContentHandler} for JSON content. * * @author Andy Wilkinson */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldPath.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldPath.java index aca86bcb..3eefe20c 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldPath.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldPath.java @@ -22,8 +22,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * A path that identifies a field in a JSON payload - * + * A path that identifies a field in a JSON payload. + * * @author Andy Wilkinson * @author Jeremy Rickard * 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 e1aa72d6..7ef5df39 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 @@ -24,8 +24,8 @@ import java.util.concurrent.atomic.AtomicReference; /** * A {@code JsonFieldProcessor} processes a payload's fields, allowing them to be - * extracted and removed - * + * extracted and removed. + * * @author Andy Wilkinson * */ @@ -212,8 +212,8 @@ final class JsonFieldProcessor { this(payload, path, null, null); } - private ProcessingContext(Object payload, JsonFieldPath path, List segments, - Match parent) { + private ProcessingContext(Object payload, JsonFieldPath path, + List segments, Match parent) { this.payload = payload; this.path = path; this.segments = segments == null ? path.getSegments() : segments; diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldType.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldType.java index 0e3b287a..fcaffa6d 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldType.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldType.java @@ -21,13 +21,46 @@ import java.util.Locale; import org.springframework.util.StringUtils; /** - * An enumeration of the possible types for a field in a JSON request or response payload - * + * An enumeration of the possible types for a field in a JSON request or response payload. + * * @author Andy Wilkinson */ public enum JsonFieldType { - ARRAY, BOOLEAN, OBJECT, NUMBER, NULL, STRING, VARIES; + /** + * An array. + */ + ARRAY, + + /** + * A boolean value. + */ + BOOLEAN, + + /** + * An object (map). + */ + OBJECT, + + /** + * A number. + */ + NUMBER, + + /** + * {@code null}. + */ + NULL, + + /** + * A string. + */ + STRING, + + /** + * A variety of different types. + */ + VARIES; @Override public String toString() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldTypeResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldTypeResolver.java index ca55dac5..f5bc6ec3 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldTypeResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldTypeResolver.java @@ -20,8 +20,8 @@ import java.util.Collection; import java.util.Map; /** - * Resolves the type of a field in a JSON request or response payload - * + * Resolves the type of a field in a JSON request or response payload. + * * @author Andy Wilkinson */ class JsonFieldTypeResolver { 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 c32df1ba..653442ed 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 @@ -23,7 +23,7 @@ import org.springframework.restdocs.snippet.Snippet; /** * Static factory methods for documenting a RESTful API's request and response payloads. - * + * * @author Andreas Evers * @author Andy Wilkinson */ @@ -43,27 +43,27 @@ public abstract class PayloadDocumentation { * When documenting a JSON payload, the {@code path} uses '.' to descend into a child * object and ' {@code []}' to descend into an array. For example, with this JSON * payload: - * + * *
 	 * {
-     *    "a":{
-     *        "b":[
-     *            {
-     *                "c":"one"
-     *            },
-     *            {
-     *                "c":"two"
-     *            },
-     *            {
-     *                "d":"three"
-     *            }
-     *        ]
-     *    }
-     * }
+	 *    "a":{
+	 *        "b":[
+	 *            {
+	 *                "c":"one"
+	 *            },
+	 *            {
+	 *                "c":"two"
+	 *            },
+	 *            {
+	 *                "d":"three"
+	 *            }
+	 *        ]
+	 *    }
+	 * }
 	 * 
- * + * * The following paths are all present: - * + * * * * @@ -90,7 +90,7 @@ public abstract class PayloadDocumentation { * * *
PathThe string "three"
- * + * * @param path The path of the field * @return a {@code FieldDescriptor} ready for further configuration */ @@ -108,7 +108,7 @@ public abstract class PayloadDocumentation { * a failure will also occur. For payloads with a hierarchical structure, documenting * a field is sufficient for all of its descendants to also be treated as having been * documented. - * + * * @param descriptors The descriptions of the request's fields * @return the handler * @see #fieldWithPath(String) @@ -128,7 +128,7 @@ public abstract class PayloadDocumentation { * a failure will also occur. For payloads with a hierarchical structure, documenting * a field is sufficient for all of its descendants to also be treated as having been * documented. - * + * * @param attributes Attributes made available during rendering of the snippet * @param descriptors The descriptions of the request's fields * @return the handler @@ -149,7 +149,7 @@ public abstract class PayloadDocumentation { * a failure will also occur. For payloads with a hierarchical structure, documenting * a field is sufficient for all of its descendants to also be treated as having been * documented. - * + * * @param descriptors The descriptions of the response's fields * @return the handler * @see #fieldWithPath(String) @@ -169,7 +169,7 @@ public abstract class PayloadDocumentation { * a failure will also occur. For payloads with a hierarchical structure, documenting * a field is sufficient for all of its descendants to also be treated as having been * documented. - * + * * @param attributes Attributes made available during rendering of the snippet * @param descriptors The descriptions of the response's fields * @return the handler 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 10362718..383ba222 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 @@ -17,7 +17,7 @@ package org.springframework.restdocs.payload; /** - * Thrown to indicate that a failure has occurred during payload handling + * Thrown to indicate that a failure has occurred during payload handling. * * @author Andy Wilkinson * @@ -26,7 +26,7 @@ package org.springframework.restdocs.payload; class PayloadHandlingException extends RuntimeException { /** - * Creates a new {@code PayloadHandlingException} with the given cause + * Creates a new {@code PayloadHandlingException} with the given cause. * @param cause the cause of the failure */ PayloadHandlingException(Throwable cause) { 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 130357fa..354a0283 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 @@ -26,7 +26,7 @@ import org.springframework.restdocs.snippet.Snippet; /** * A {@link Snippet} that documents the fields in a request. - * + * * @author Andy Wilkinson * @see PayloadDocumentation#requestFields(FieldDescriptor...) * @see PayloadDocumentation#requestFields(Map, FieldDescriptor...) @@ -36,7 +36,7 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { /** * Creates a new {@code RequestFieldsSnippet} that will document the fields in the * request using the given {@code descriptors}. - * + * * @param descriptors the descriptors */ protected RequestFieldsSnippet(List descriptors) { @@ -47,7 +47,7 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet { * Creates a new {@code RequestFieldsSnippet} that will document the fields 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/payload/ResponseFieldsSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ResponseFieldsSnippet.java index 4e829cad..82015ef8 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 @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.restdocs.payload; import java.io.IOException; @@ -25,7 +26,7 @@ import org.springframework.restdocs.snippet.Snippet; /** * A {@link Snippet} that documents the fields in a response. - * + * * @author Andy Wilkinson * @see PayloadDocumentation#responseFields(FieldDescriptor...) * @see PayloadDocumentation#responseFields(Map, FieldDescriptor...) @@ -35,7 +36,7 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { /** * Creates a new {@code ResponseFieldsSnippet} that will document the fields in the * response using the given {@code descriptors}. - * + * * @param descriptors the descriptors */ protected ResponseFieldsSnippet(List descriptors) { @@ -46,7 +47,7 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet { * Creates a new {@code ResponseFieldsSnippet} that will document the fields 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/payload/XmlContentHandler.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/XmlContentHandler.java index 53eb22e6..a971f049 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/XmlContentHandler.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/XmlContentHandler.java @@ -40,8 +40,8 @@ import org.w3c.dom.NodeList; import org.xml.sax.InputSource; /** - * A {@link ContentHandler} for XML content - * + * A {@link ContentHandler} for XML content. + * * @author Andy Wilkinson */ class XmlContentHandler implements ContentHandler { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/package-info.java index 1e164515..f306a019 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/package-info.java @@ -17,4 +17,5 @@ /** * Documenting the payload of a RESTful API's requests and responses. */ -package org.springframework.restdocs.payload; \ No newline at end of file +package org.springframework.restdocs.payload; + 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 f0597fef..144c8d67 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 @@ -45,7 +45,7 @@ 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. - * + * * @param snippetName The snippet name * @param descriptors The descriptors * @param attributes The additional attributes @@ -73,7 +73,7 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet { return model; } - protected void verifyParameterDescriptors(Operation operation) { + private void verifyParameterDescriptors(Operation operation) { Set actualParameters = extractActualParameters(operation); Set expectedParameters = this.descriptorsByName.keySet(); Set undocumentedParameters = new HashSet(actualParameters); @@ -84,13 +84,25 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet { if (!undocumentedParameters.isEmpty() || !missingParameters.isEmpty()) { verificationFailed(undocumentedParameters, missingParameters); } - else { - Assert.isTrue(actualParameters.equals(expectedParameters)); - } } + /** + * Extracts the names of the parameters that were present in the given + * {@code operation}. + * + * @param operation the operation + * @return the parameters + */ protected abstract Set extractActualParameters(Operation operation); + /** + * 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 + * the operation + */ protected abstract void verificationFailed(Set undocumentedParameters, Set missingParameters); @@ -98,7 +110,7 @@ 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 getFieldDescriptors() { @@ -107,7 +119,7 @@ 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 a1a2840f..ff9d561d 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 @@ -19,8 +19,8 @@ package org.springframework.restdocs.request; import org.springframework.restdocs.snippet.AbstractDescriptor; /** - * A descriptor of a request or path parameter - * + * A descriptor of a request or path parameter. + * * @author Andy Wilkinson * @see RequestDocumentation#parameterWithName * @@ -32,7 +32,7 @@ public class ParameterDescriptor extends AbstractDescriptor /** * Creates a new {@code ParameterDescriptor} describing the parameter with the given * {@code name}. - * + * * @param name the name of the parameter */ protected ParameterDescriptor(String name) { @@ -40,8 +40,8 @@ public class ParameterDescriptor extends AbstractDescriptor } /** - * Returns the name of the parameter being described by this descriptor - * + * Returns the name of the parameter being described by this descriptor. + * * @return the name of the parameter */ public final String getName() { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/PathParametersSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/PathParametersSnippet.java index b67a9985..5df99f6f 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/PathParametersSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/PathParametersSnippet.java @@ -42,7 +42,7 @@ public class PathParametersSnippet extends AbstractParametersSnippet { /** * Creates a new {@code PathParametersSnippet} that will document the request's path * parameters using the given {@code descriptors}. - * + * * @param descriptors the parameter descriptors */ protected PathParametersSnippet(List descriptors) { @@ -53,7 +53,7 @@ public class PathParametersSnippet extends AbstractParametersSnippet { * Creates a new {@code PathParametersSnippet} that will document the request's path * parameters using the given {@code descriptors}. The given {@code attributes} will * be included in the model during template rendering. - * + * * @param descriptors the parameter descriptors * @param attributes the additional attributes */ 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 1a051077..345ec58c 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 @@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.RequestParam; /** * Static factory methods for documenting aspects of a request sent to a RESTful API. - * + * * @author Andy Wilkinson */ public abstract class RequestDocumentation { @@ -39,7 +39,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 * @return a {@link ParameterDescriptor} ready for further configuration */ @@ -50,7 +50,7 @@ public abstract class RequestDocumentation { /** * Returns a snippet that will document the path parameters from the API call's * request. - * + * * @param descriptors The descriptions of the parameters in the request's path * @return the snippet * @see PathVariable @@ -62,7 +62,7 @@ public abstract class RequestDocumentation { /** * Returns a snippet that will document the path parameters from the API call's * request. The given {@code attributes} will be available during snippet rendering. - * + * * @param attributes Attributes made available during rendering of the path parameters * snippet * @param descriptors The descriptions of the parameters in the request's path @@ -77,7 +77,7 @@ public abstract class RequestDocumentation { /** * Returns a snippet that will document the request parameters from the API call's * request. - * + * * @param descriptors The descriptions of the request's parameters * @return the snippet * @see RequestParam @@ -90,7 +90,7 @@ public abstract class RequestDocumentation { /** * Returns a snippet that will document the request parameters from the API call's * request. The given {@code attributes} will be available during snippet rendering. - * + * * @param attributes Attributes made available during rendering of the request * parameters snippet * @param descriptors The descriptions of the request's parameters 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 dbe4e372..5b1f9ba8 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 @@ -41,7 +41,7 @@ public class RequestParametersSnippet extends AbstractParametersSnippet { /** * Creates a new {@code RequestParametersSnippet} that will document the request's * parameters using the given {@code descriptors}. - * + * * @param descriptors the parameter descriptors */ protected RequestParametersSnippet(List descriptors) { @@ -52,7 +52,7 @@ public class RequestParametersSnippet extends AbstractParametersSnippet { * Creates a new {@code RequestParametersSnippet} that will document the request's * parameters using the given {@code descriptors}. The given {@code attributes} will * be included in the model during template rendering. - * + * * @param descriptors the parameter descriptors * @param attributes the additional attributes */ diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/package-info.java index 9e78ff29..744aa7f0 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/package-info.java @@ -17,4 +17,5 @@ /** * Documenting query and path parameters of requests sent to a RESTful API. */ -package org.springframework.restdocs.request; \ No newline at end of file +package org.springframework.restdocs.request; + 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 34efc728..a0b67a3a 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 @@ -25,9 +25,8 @@ import org.springframework.restdocs.snippet.Attributes.Attribute; * Base class for descriptors. Provides the ability to associate arbitrary attributes with * a descriptor. * - * @author Andy Wilkinson - * * @param the type of the descriptor + * @author Andy Wilkinson */ public abstract class AbstractDescriptor> { @@ -36,7 +35,7 @@ public abstract class AbstractDescriptor> { private Object description; /** - * Adds the given {@code attributes} to the descriptor + * Adds the given {@code attributes} to the descriptor. * * @param attributes the attributes * @return the descriptor @@ -50,8 +49,8 @@ public abstract class AbstractDescriptor> { } /** - * Specifies the description - * + * Specifies the description. + * * @param description the description * @return the descriptor */ @@ -62,8 +61,8 @@ public abstract class AbstractDescriptor> { } /** - * Returns the description - * + * Returns the description. + * * @return the description */ public final Object getDescription() { @@ -71,7 +70,7 @@ public abstract class AbstractDescriptor> { } /** - * Returns the descriptor's attributes + * Returns the descriptor's attributes. * * @return the attributes */ 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 db8462f3..b5f1a9c3 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 @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.restdocs.snippet; import java.util.HashMap; import java.util.Map; /** - * A fluent API for building a map of attributes - * + * A fluent API for building a map of attributes. + * * @author Andy Wilkinson */ public abstract class Attributes { @@ -32,7 +33,7 @@ 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 * @see AttributeBuilder#value(Object) @@ -43,7 +44,7 @@ public abstract class Attributes { /** * Creates a {@code Map} of the given {@code attributes}. - * + * * @param attributes The attributes * @return A Map of the attributes */ @@ -56,9 +57,9 @@ public abstract class Attributes { } /** - * A simple builder for an attribute (key-value pair) + * A simple builder for an attribute (key-value pair). */ - public static class AttributeBuilder { + public static final class AttributeBuilder { private final String key; @@ -67,8 +68,8 @@ public abstract class Attributes { } /** - * Configures the value of the attribute - * + * Configures the value of the attribute. + * * @param value The attribute's value * @return A newly created {@code Attribute} */ @@ -81,7 +82,7 @@ public abstract class Attributes { /** * An attribute (key-value pair). */ - public static class Attribute { + public static final class Attribute { private final String key; @@ -89,6 +90,7 @@ public abstract class Attributes { /** * Creates a new attribute with the given {@code key} and {@code value}. + * * @param key the key * @param value the value */ @@ -98,7 +100,8 @@ public abstract class Attributes { } /** - * Returns the attribute's key + * Returns the attribute's key. + * * @return the key */ public String getKey() { @@ -106,7 +109,8 @@ public abstract class Attributes { } /** - * Returns the attribute's value + * Returns the attribute's value. + * * @return the value */ public Object getValue() { 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 d3655527..93c60192 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 @@ -13,23 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.restdocs.snippet; -import org.springframework.restdocs.operation.Operation; +package org.springframework.restdocs.snippet; /** * An exception that can be thrown by a {@link TemplatedSnippet} to indicate that a * failure has occurred during model creation. - * + * * @author Andy Wilkinson - * @see TemplatedSnippet#createModel(Operation) + * @see TemplatedSnippet#createModel(org.springframework.restdocs.operation.Operation) */ @SuppressWarnings("serial") public class ModelCreationException extends RuntimeException { /** * Creates a new {@code ModelCreationException} with the given {@code cause}. - * + * * @param cause the cause */ public ModelCreationException(Throwable cause) { @@ -39,7 +38,7 @@ 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/RestDocumentationContextPlaceholderResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolver.java index 51f63c7b..908f3d5e 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 @@ -46,7 +46,7 @@ import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; * {@link RestDocumentationContext#getTestClass() current test class} formatted using * snake case * - * + * * @author Andy Wilkinson */ public class RestDocumentationContextPlaceholderResolver implements PlaceholderResolver { @@ -58,7 +58,7 @@ 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) { @@ -93,7 +93,7 @@ public class RestDocumentationContextPlaceholderResolver implements PlaceholderR /** * Converts the given {@code string} from camelCase to kebab-case. - * + * * @param string the string * @return the converted string */ @@ -103,7 +103,7 @@ public class RestDocumentationContextPlaceholderResolver implements PlaceholderR /** * Converts the given {@code string} from camelCase to snake_case. - * + * * @param string the string * @return the converted string */ @@ -114,7 +114,7 @@ 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 63438924..a4309156 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 @@ -22,14 +22,14 @@ import org.springframework.restdocs.operation.Operation; /** * A {@link Snippet} is used to document aspects of a call to a RESTful API. - * + * * @author Andy Wilkinson */ 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 f846b8f3..9928c352 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 @@ -19,14 +19,15 @@ package org.springframework.restdocs.snippet; /** * A {@link RuntimeException} thrown to indicate a problem with the generation of a * documentation snippet. - * + * * @author Andy Wilkinson */ @SuppressWarnings("serial") public class SnippetException extends RuntimeException { /** - * Creates a new {@code SnippetException} described by the given {@code message} + * 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 2ba5d366..1ef51ea4 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 @@ -28,10 +28,10 @@ import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; /** * Standard implementation of {@link WriterResolver}. - * + * * @author Andy Wilkinson */ -public class StandardWriterResolver implements WriterResolver { +public final class StandardWriterResolver implements WriterResolver { private String encoding = "UTF-8"; @@ -44,7 +44,7 @@ public class StandardWriterResolver implements WriterResolver { * Creates a new {@code StandardWriterResolver} that will use the given * {@code placeholderResolver} to resolve any placeholders in the * {@code operationName}. - * + * * @param placeholderResolver the placeholder resolver */ public StandardWriterResolver(PlaceholderResolver placeholderResolver) { @@ -71,7 +71,7 @@ public class StandardWriterResolver implements WriterResolver { this.encoding = encoding; } - protected File resolveFile(String outputDirectory, String fileName, + File resolveFile(String outputDirectory, String fileName, RestDocumentationContext context) { File outputFile = new File(outputDirectory, fileName); if (!outputFile.isAbsolute()) { 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 3ec4afbb..015d1fe8 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 @@ -42,7 +42,7 @@ public abstract class TemplatedSnippet implements Snippet { * Creates a new {@code TemplatedSnippet} that will produce a snippet with the given * {@code snippetName}. 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 */ @@ -74,7 +74,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 * @return the model * @throws ModelCreationException if model creation fails @@ -84,7 +84,7 @@ 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() { @@ -93,11 +93,11 @@ public abstract class TemplatedSnippet implements Snippet { /** * Returns the name of the snippet that will be created. - * + * * @return the snippet name */ protected final String getSnippetName() { return this.snippetName; } -} \ No newline at end of file +} 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 9adca5ca..29c2393e 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 @@ -24,7 +24,7 @@ import org.springframework.restdocs.RestDocumentationContext; /** * A {@code WriterResolver} is used to access the {@link Writer} that should be used to * write a snippet for an operation that is being documented. - * + * * @author Andy Wilkinson */ public interface WriterResolver { @@ -32,6 +32,7 @@ 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 @@ -43,7 +44,8 @@ public interface WriterResolver { /** * Configures the encoding that should be used by any writers produced by this - * resolver + * resolver. + * * @param encoding the encoding */ void setEncoding(String encoding); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/package-info.java index 1e8540b9..9c16a3e2 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/package-info.java @@ -17,4 +17,5 @@ /** * Snippet generation. */ -package org.springframework.restdocs.snippet; \ No newline at end of file +package org.springframework.restdocs.snippet; + 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 eb8fb455..4e3d38e3 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 @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.restdocs.templates; import org.springframework.core.io.ClassPathResource; @@ -26,7 +27,7 @@ import org.springframework.core.io.Resource; * resource exists {@code default-} is prepended to the name and the classpath is checked * again. The built-in snippet templates are all named {@code default- name}, thereby * allowing them to be overridden. - * + * * @author Andy Wilkinson */ public class StandardTemplateResourceResolver implements TemplateResourceResolver { 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 2ab90571..17c2dfc7 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 @@ -22,7 +22,7 @@ import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; /** * A {@code TemplateEngine} is used to render documentation snippets. - * + * * @author Andy Wilkinson * @see MustacheTemplateEngine */ @@ -32,7 +32,7 @@ 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/TemplateResourceResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateResourceResolver.java index d4259af1..7def9462 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 @@ -21,17 +21,17 @@ import org.springframework.core.io.Resource; /** * A {@code TemplateResourceResolver} is responsible for resolving a name for a template * into a {@link Resource} from which the template can be read. - * + * * @author Andy Wilkinson */ 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 */ - public Resource resolveTemplateResource(String name); + Resource resolveTemplateResource(String name); } 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 52421732..9b359edb 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 @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.restdocs.templates.mustache; import java.util.Map; @@ -22,7 +23,7 @@ import org.springframework.restdocs.templates.Template; /** * An adapter that exposes a compiled Mustache * template as a {@link Template}. - * + * * @author Andy Wilkinson */ public class MustacheTemplate implements Template { @@ -33,6 +34,7 @@ public class MustacheTemplate implements Template { * Creates a new {@code MustacheTemplate} that adapts the given {@code delegate}. When * rendered, the given {@code defaultContext} will be combined with the render context * prior to executing the delegate. + * * @param delegate The delegate to adapt */ public MustacheTemplate(org.springframework.restdocs.mustache.Template delegate) { 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 0b16ae81..df142045 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 @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.restdocs.templates.mustache; import java.io.IOException; @@ -30,7 +31,7 @@ import org.springframework.restdocs.templates.TemplateResourceResolver; * implemented using JMustache. *

* Note that JMustache has been repackaged and embedded to prevent classpath conflicts. - * + * * @author Andy Wilkinson */ public class MustacheTemplateEngine implements TemplateEngine { @@ -42,7 +43,7 @@ public class MustacheTemplateEngine implements TemplateEngine { /** * Creates a new {@link MustacheTemplateEngine} that will use the given * {@code templateResourceResolver} to resolve template paths. - * + * * @param templateResourceResolver The resolve to use */ public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver) { diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/package-info.java index 0b4246df..244b8d9e 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/package-info.java @@ -17,4 +17,5 @@ /** * JMustache-based implementation of the template API. */ -package org.springframework.restdocs.templates.mustache; \ No newline at end of file +package org.springframework.restdocs.templates.mustache; + diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/package-info.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/package-info.java index 7f9b1d10..cac448dd 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/package-info.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/package-info.java @@ -17,4 +17,5 @@ /** * Template API used to render documentation snippets. */ -package org.springframework.restdocs.templates; \ No newline at end of file +package org.springframework.restdocs.templates; + diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ConstraintDescriptionsTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ConstraintDescriptionsTests.java index e69192e2..6968fccf 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ConstraintDescriptionsTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ConstraintDescriptionsTests.java @@ -16,10 +16,6 @@ package org.springframework.restdocs.constraints; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.hasSize; -import static org.junit.Assert.assertThat; - import java.math.BigDecimal; import java.util.Date; @@ -39,8 +35,12 @@ import javax.validation.constraints.Size; import org.junit.Test; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.hasSize; +import static org.junit.Assert.assertThat; + /** - * Tests for {@link ConstraintDescriptions} + * Tests for {@link ConstraintDescriptions}. * * @author Andy Wilkinson */ 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 efb0f235..8f2fa07d 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 @@ -16,10 +16,6 @@ package org.springframework.restdocs.constraints; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - import java.net.URL; import java.util.Collections; import java.util.HashMap; @@ -43,8 +39,12 @@ import javax.validation.constraints.Size; import org.junit.Test; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + /** - * Tests for {@link ResourceBundleConstraintDescriptionResolver} + * Tests for {@link ResourceBundleConstraintDescriptionResolver}. * * @author Andy Wilkinson */ @@ -55,14 +55,14 @@ public class ResourceBundleConstraintDescriptionResolverTests { @Test public void defaultMessageAssertFalse() { String description = this.resolver.resolveDescription(new Constraint( - AssertFalse.class.getName(), Collections. emptyMap())); + AssertFalse.class.getName(), Collections.emptyMap())); assertThat(description, is(equalTo("Must be false"))); } @Test public void defaultMessageAssertTrue() { String description = this.resolver.resolveDescription(new Constraint( - AssertTrue.class.getName(), Collections. emptyMap())); + AssertTrue.class.getName(), Collections.emptyMap())); assertThat(description, is(equalTo("Must be true"))); } @@ -98,7 +98,7 @@ public class ResourceBundleConstraintDescriptionResolverTests { @Test public void defaultMessageFuture() { String description = this.resolver.resolveDescription(new Constraint(Future.class - .getName(), Collections. emptyMap())); + .getName(), Collections.emptyMap())); assertThat(description, is(equalTo("Must be in the future"))); } @@ -123,21 +123,21 @@ public class ResourceBundleConstraintDescriptionResolverTests { @Test public void defaultMessageNotNull() { String description = this.resolver.resolveDescription(new Constraint( - NotNull.class.getName(), Collections. emptyMap())); + NotNull.class.getName(), Collections.emptyMap())); assertThat(description, is(equalTo("Must not be null"))); } @Test public void defaultMessageNull() { String description = this.resolver.resolveDescription(new Constraint(Null.class - .getName(), Collections. emptyMap())); + .getName(), Collections.emptyMap())); assertThat(description, is(equalTo("Must be null"))); } @Test public void defaultMessagePast() { String description = this.resolver.resolveDescription(new Constraint(Past.class - .getName(), Collections. emptyMap())); + .getName(), Collections.emptyMap())); assertThat(description, is(equalTo("Must be in the past"))); } @@ -179,7 +179,7 @@ public class ResourceBundleConstraintDescriptionResolverTests { try { String description = new ResourceBundleConstraintDescriptionResolver() .resolveDescription(new Constraint(NotNull.class.getName(), - Collections. emptyMap())); + Collections.emptyMap())); assertThat(description, is(equalTo("Should not be null"))); } @@ -201,7 +201,7 @@ public class ResourceBundleConstraintDescriptionResolverTests { }; String description = new ResourceBundleConstraintDescriptionResolver(bundle) .resolveDescription(new Constraint(NotNull.class.getName(), Collections - . emptyMap())); + .emptyMap())); assertThat(description, is(equalTo("Not null"))); } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ValidatorConstraintResolverTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ValidatorConstraintResolverTests.java index e07abd7f..89bce77b 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ValidatorConstraintResolverTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/constraints/ValidatorConstraintResolverTests.java @@ -16,11 +16,6 @@ package org.springframework.restdocs.constraints; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.hasSize; -import static org.junit.Assert.assertThat; - import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -43,8 +38,13 @@ import org.hibernate.validator.constraints.ConstraintComposition; import org.hibernate.validator.constraints.NotBlank; import org.junit.Test; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.hasSize; +import static org.junit.Assert.assertThat; + /** - * Tests for {@link ValidatorConstraintResolver} + * Tests for {@link ValidatorConstraintResolver}. * * @author Andy Wilkinson */ @@ -86,6 +86,10 @@ public class ValidatorConstraintResolverTests { assertThat(constraints, hasSize(1)); } + private ConstraintMatcher constraint(final Class annotation) { + return new ConstraintMatcher(annotation); + } + private static class ConstrainedFields { @NotNull @@ -108,7 +112,7 @@ public class ValidatorConstraintResolverTests { @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) @javax.validation.Constraint(validatedBy = {}) - public @interface CompositeConstraint { + private @interface CompositeConstraint { String message() default "Must be null or not blank"; @@ -118,11 +122,7 @@ public class ValidatorConstraintResolverTests { } - private ConstraintMatcher constraint(final Class annotation) { - return new ConstraintMatcher(annotation); - } - - private static class ConstraintMatcher extends BaseMatcher { + private static final class ConstraintMatcher extends BaseMatcher { private final Class annotation; diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/curl/CurlRequestSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/curl/CurlRequestSnippetTests.java index 2e15a116..f84cf0e1 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/curl/CurlRequestSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/curl/CurlRequestSnippetTests.java @@ -16,13 +16,6 @@ package org.springframework.restdocs.curl; -import static org.hamcrest.CoreMatchers.containsString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.springframework.restdocs.snippet.Attributes.attributes; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.restdocs.test.SnippetMatchers.codeBlock; - import java.io.IOException; import org.junit.Rule; @@ -38,8 +31,15 @@ import org.springframework.restdocs.test.ExpectedSnippet; import org.springframework.restdocs.test.OperationBuilder; import org.springframework.util.Base64Utils; +import static org.hamcrest.CoreMatchers.containsString; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.springframework.restdocs.snippet.Attributes.attributes; +import static org.springframework.restdocs.snippet.Attributes.key; +import static org.springframework.restdocs.test.SnippetMatchers.codeBlock; + /** - * Tests for {@link CurlRequestSnippet} + * Tests for {@link CurlRequestSnippet}. * * @author Andy Wilkinson * @author Yann Le Guern @@ -247,8 +247,8 @@ public class CurlRequestSnippetTests { this.snippet.expectCurlRequest("custom-attributes").withContents( containsString("curl request title")); TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("curl-request")) - .thenReturn( + given(resolver.resolveTemplateResource("curl-request")) + .willReturn( new FileSystemResource( "src/test/resources/custom-snippet-templates/curl-request-with-title.snippet")); new CurlRequestSnippet(attributes(key("title").value("curl request title"))) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java index 8da93faa..6dcdcbbe 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java @@ -16,16 +16,6 @@ package org.springframework.restdocs.http; -import static org.hamcrest.CoreMatchers.containsString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.springframework.restdocs.snippet.Attributes.attributes; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.restdocs.test.SnippetMatchers.httpRequest; -import static org.springframework.web.bind.annotation.RequestMethod.GET; -import static org.springframework.web.bind.annotation.RequestMethod.POST; -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - import java.io.IOException; import org.junit.Rule; @@ -38,10 +28,18 @@ import org.springframework.restdocs.templates.TemplateResourceResolver; import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; import org.springframework.restdocs.test.ExpectedSnippet; import org.springframework.restdocs.test.OperationBuilder; +import org.springframework.web.bind.annotation.RequestMethod; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.springframework.restdocs.snippet.Attributes.attributes; +import static org.springframework.restdocs.snippet.Attributes.key; +import static org.springframework.restdocs.test.SnippetMatchers.httpRequest; /** - * Tests for {@link HttpRequestSnippet} - * + * Tests for {@link HttpRequestSnippet}. + * * @author Andy Wilkinson * @author Jonathan Pearlin * @@ -56,8 +54,8 @@ public class HttpRequestSnippetTests { @Test public void getRequest() throws IOException { this.snippet.expectHttpRequest("get-request").withContents( - httpRequest(GET, "/foo").header(HttpHeaders.HOST, "localhost").header( - "Alpha", "a")); + httpRequest(RequestMethod.GET, "/foo").header(HttpHeaders.HOST, + "localhost").header("Alpha", "a")); new HttpRequestSnippet().document(new OperationBuilder("get-request", this.snippet.getOutputDirectory()).request("http://localhost/foo") @@ -67,7 +65,8 @@ public class HttpRequestSnippetTests { @Test public void getRequestWithQueryString() throws IOException { this.snippet.expectHttpRequest("get-request-with-query-string").withContents( - httpRequest(GET, "/foo?bar=baz").header(HttpHeaders.HOST, "localhost")); + httpRequest(RequestMethod.GET, "/foo?bar=baz").header(HttpHeaders.HOST, + "localhost")); new HttpRequestSnippet().document(new OperationBuilder( "get-request-with-query-string", this.snippet.getOutputDirectory()) @@ -77,8 +76,8 @@ public class HttpRequestSnippetTests { @Test public void postRequestWithContent() throws IOException { this.snippet.expectHttpRequest("post-request-with-content").withContents( - httpRequest(POST, "/foo").header(HttpHeaders.HOST, "localhost").content( - "Hello, world")); + httpRequest(RequestMethod.POST, "/foo").header(HttpHeaders.HOST, + "localhost").content("Hello, world")); new HttpRequestSnippet().document(new OperationBuilder( "post-request-with-content", this.snippet.getOutputDirectory()) @@ -89,7 +88,8 @@ public class HttpRequestSnippetTests { @Test public void postRequestWithParameter() throws IOException { this.snippet.expectHttpRequest("post-request-with-parameter").withContents( - httpRequest(POST, "/foo").header(HttpHeaders.HOST, "localhost") + httpRequest(RequestMethod.POST, "/foo") + .header(HttpHeaders.HOST, "localhost") .header("Content-Type", "application/x-www-form-urlencoded") .content("b%26r=baz&a=alpha")); @@ -102,8 +102,8 @@ public class HttpRequestSnippetTests { @Test public void putRequestWithContent() throws IOException { this.snippet.expectHttpRequest("put-request-with-content").withContents( - httpRequest(PUT, "/foo").header(HttpHeaders.HOST, "localhost").content( - "Hello, world")); + httpRequest(RequestMethod.PUT, "/foo").header(HttpHeaders.HOST, + "localhost").content("Hello, world")); new HttpRequestSnippet().document(new OperationBuilder( "put-request-with-content", this.snippet.getOutputDirectory()) @@ -114,7 +114,8 @@ public class HttpRequestSnippetTests { @Test public void putRequestWithParameter() throws IOException { this.snippet.expectHttpRequest("put-request-with-parameter").withContents( - httpRequest(PUT, "/foo").header(HttpHeaders.HOST, "localhost") + httpRequest(RequestMethod.PUT, "/foo") + .header(HttpHeaders.HOST, "localhost") .header("Content-Type", "application/x-www-form-urlencoded") .content("b%26r=baz&a=alpha")); @@ -129,7 +130,7 @@ public class HttpRequestSnippetTests { String expectedContent = createPart(String.format("Content-Disposition: " + "form-data; " + "name=image%n%n<< data >>")); this.snippet.expectHttpRequest("multipart-post").withContents( - httpRequest(POST, "/upload") + httpRequest(RequestMethod.POST, "/upload") .header(HttpHeaders.HOST, "localhost") .header("Content-Type", "multipart/form-data; boundary=" + BOUNDARY) @@ -153,7 +154,7 @@ public class HttpRequestSnippetTests { + "name=image%n%n<< data >>")); String expectedContent = param1Part + param2Part + param3Part + filePart; this.snippet.expectHttpRequest("multipart-post-with-parameters").withContents( - httpRequest(POST, "/upload") + httpRequest(RequestMethod.POST, "/upload") .header(HttpHeaders.HOST, "localhost") .header("Content-Type", "multipart/form-data; boundary=" + BOUNDARY) @@ -172,7 +173,7 @@ public class HttpRequestSnippetTests { .format("Content-Disposition: form-data; name=image%nContent-Type: " + "image/png%n%n<< data >>")); this.snippet.expectHttpRequest("multipart-post-with-content-type").withContents( - httpRequest(POST, "/upload") + httpRequest(RequestMethod.POST, "/upload") .header(HttpHeaders.HOST, "localhost") .header("Content-Type", "multipart/form-data; boundary=" + BOUNDARY) @@ -188,7 +189,8 @@ public class HttpRequestSnippetTests { @Test public void getRequestWithCustomHost() throws IOException { this.snippet.expectHttpRequest("get-request-custom-host").withContents( - httpRequest(GET, "/foo").header(HttpHeaders.HOST, "api.example.com")); + httpRequest(RequestMethod.GET, "/foo").header(HttpHeaders.HOST, + "api.example.com")); new HttpRequestSnippet().document(new OperationBuilder("get-request-custom-host", this.snippet.getOutputDirectory()).request("http://localhost/foo") .header(HttpHeaders.HOST, "api.example.com").build()); @@ -199,8 +201,8 @@ public class HttpRequestSnippetTests { this.snippet.expectHttpRequest("request-with-snippet-attributes").withContents( containsString("Title for the request")); TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("http-request")) - .thenReturn( + given(resolver.resolveTemplateResource("http-request")) + .willReturn( new FileSystemResource( "src/test/resources/custom-snippet-templates/http-request-with-title.snippet")); new HttpRequestSnippet(attributes(key("title").value("Title for the request"))) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpResponseSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpResponseSnippetTests.java index cfe68c60..ab13d950 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpResponseSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpResponseSnippetTests.java @@ -16,21 +16,13 @@ package org.springframework.restdocs.http; -import static org.hamcrest.CoreMatchers.containsString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.springframework.http.HttpStatus.BAD_REQUEST; -import static org.springframework.http.HttpStatus.OK; -import static org.springframework.restdocs.snippet.Attributes.attributes; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.restdocs.test.SnippetMatchers.httpResponse; - import java.io.IOException; import org.junit.Rule; import org.junit.Test; import org.springframework.core.io.FileSystemResource; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.restdocs.templates.TemplateEngine; import org.springframework.restdocs.templates.TemplateResourceResolver; @@ -38,8 +30,15 @@ import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; import org.springframework.restdocs.test.ExpectedSnippet; import org.springframework.restdocs.test.OperationBuilder; +import static org.hamcrest.CoreMatchers.containsString; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.springframework.restdocs.snippet.Attributes.attributes; +import static org.springframework.restdocs.snippet.Attributes.key; +import static org.springframework.restdocs.test.SnippetMatchers.httpResponse; + /** - * Tests for {@link HttpResponseSnippet} + * Tests for {@link HttpResponseSnippet}. * * @author Andy Wilkinson * @author Jonathan Pearlin @@ -51,7 +50,8 @@ public class HttpResponseSnippetTests { @Test public void basicResponse() throws IOException { - this.snippet.expectHttpResponse("basic-response").withContents(httpResponse(OK)); + this.snippet.expectHttpResponse("basic-response").withContents( + httpResponse(HttpStatus.OK)); new HttpResponseSnippet().document(new OperationBuilder("basic-response", this.snippet.getOutputDirectory()).build()); } @@ -59,16 +59,16 @@ public class HttpResponseSnippetTests { @Test public void nonOkResponse() throws IOException { this.snippet.expectHttpResponse("non-ok-response").withContents( - httpResponse(BAD_REQUEST)); + httpResponse(HttpStatus.BAD_REQUEST)); new HttpResponseSnippet().document(new OperationBuilder("non-ok-response", - this.snippet.getOutputDirectory()).response().status(BAD_REQUEST.value()) - .build()); + this.snippet.getOutputDirectory()).response() + .status(HttpStatus.BAD_REQUEST.value()).build()); } @Test public void responseWithHeaders() throws IOException { this.snippet.expectHttpResponse("response-with-headers").withContents( - httpResponse(OK) // + httpResponse(HttpStatus.OK) // .header("Content-Type", "application/json") // .header("a", "alpha")); new HttpResponseSnippet().document(new OperationBuilder("response-with-headers", @@ -80,7 +80,7 @@ public class HttpResponseSnippetTests { @Test public void responseWithContent() throws IOException { this.snippet.expectHttpResponse("response-with-content").withContents( - httpResponse(OK).content("content")); + httpResponse(HttpStatus.OK).content("content")); new HttpResponseSnippet().document(new OperationBuilder("response-with-content", this.snippet.getOutputDirectory()).response().content("content").build()); } @@ -90,8 +90,8 @@ public class HttpResponseSnippetTests { this.snippet.expectHttpResponse("response-with-snippet-attributes").withContents( containsString("Title for the response")); TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("http-response")) - .thenReturn( + given(resolver.resolveTemplateResource("http-response")) + .willReturn( new FileSystemResource( "src/test/resources/custom-snippet-templates/http-response-with-title.snippet")); new HttpResponseSnippet(attributes(key("title").value("Title for the response"))) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/ContentTypeLinkExtractorTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/ContentTypeLinkExtractorTests.java index 161fefbf..5157e07b 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/ContentTypeLinkExtractorTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/ContentTypeLinkExtractorTests.java @@ -16,9 +16,6 @@ package org.springframework.restdocs.hypermedia; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -31,9 +28,12 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.restdocs.operation.StandardOperationResponse; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + /** * Tests for {@link ContentTypeLinkExtractor}. - * + * * @author Andy Wilkinson */ public class ContentTypeLinkExtractorTests { @@ -73,5 +73,4 @@ public class ContentTypeLinkExtractorTests { new ContentTypeLinkExtractor(extractors).extractLinks(response); verify(extractor).extractLinks(response); } - } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinkExtractorsPayloadTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinkExtractorsPayloadTests.java index 6711ae19..02adf5cb 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinkExtractorsPayloadTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinkExtractorsPayloadTests.java @@ -16,8 +16,6 @@ package org.springframework.restdocs.hypermedia; -import static org.junit.Assert.assertEquals; - import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -37,6 +35,8 @@ import org.springframework.util.FileCopyUtils; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import static org.junit.Assert.assertEquals; + /** * Parameterized tests for {@link HalLinkExtractor} and {@link AtomLinkExtractor} with * various payloads. @@ -88,14 +88,14 @@ public class LinkExtractorsPayloadTests { public void noLinks() throws IOException { Map> links = this.linkExtractor .extractLinks(createResponse("no-links")); - assertLinks(Collections. emptyList(), links); + assertLinks(Collections.emptyList(), links); } @Test public void linksInTheWrongFormat() throws IOException { Map> links = this.linkExtractor .extractLinks(createResponse("wrong-format")); - assertLinks(Collections. emptyList(), links); + assertLinks(Collections.emptyList(), links); } private void assertLinks(List expectedLinks, Map> actualLinks) { diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetTests.java index 24bd7ec7..57b9f755 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetTests.java @@ -16,14 +16,6 @@ package org.springframework.restdocs.hypermedia; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.springframework.restdocs.snippet.Attributes.attributes; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.restdocs.test.SnippetMatchers.tableWithHeader; - import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -42,8 +34,16 @@ import org.springframework.restdocs.test.OperationBuilder; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.startsWith; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.springframework.restdocs.snippet.Attributes.attributes; +import static org.springframework.restdocs.snippet.Attributes.key; +import static org.springframework.restdocs.test.SnippetMatchers.tableWithHeader; + /** - * Tests for {@link LinksSnippet} + * Tests for {@link LinksSnippet}. * * @author Andy Wilkinson */ @@ -61,7 +61,7 @@ public class LinksSnippetTests { this.thrown.expectMessage(equalTo("Links with the following relations were not" + " documented: [foo]")); new LinksSnippet(new StubLinkExtractor().withLinks(new Link("foo", "bar")), - Collections. emptyList()).document(new OperationBuilder( + Collections.emptyList()).document(new OperationBuilder( "undocumented-link", this.snippet.getOutputDirectory()).build()); } @@ -77,9 +77,8 @@ public class LinksSnippetTests { @Test public void documentedOptionalLink() throws IOException { - this.snippet.expectLinks("documented-optional-link").withContents( // - tableWithHeader("Relation", "Description") // - .row("foo", "bar")); + this.snippet.expectLinks("documented-optional-link").withContents( + tableWithHeader("Relation", "Description").row("foo", "bar")); new LinksSnippet(new StubLinkExtractor().withLinks(new Link("foo", "blah")), Arrays.asList(new LinkDescriptor("foo").description("bar").optional())) .document(new OperationBuilder("documented-optional-link", this.snippet @@ -88,9 +87,8 @@ public class LinksSnippetTests { @Test public void missingOptionalLink() throws IOException { - this.snippet.expectLinks("missing-optional-link").withContents( // - tableWithHeader("Relation", "Description") // - .row("foo", "bar")); + this.snippet.expectLinks("missing-optional-link").withContents( + tableWithHeader("Relation", "Description").row("foo", "bar")); new LinksSnippet(new StubLinkExtractor(), Arrays.asList(new LinkDescriptor("foo") .description("bar").optional())).document(new OperationBuilder( "missing-optional-link", this.snippet.getOutputDirectory()).build()); @@ -110,9 +108,8 @@ public class LinksSnippetTests { @Test public void documentedLinks() throws IOException { - this.snippet.expectLinks("documented-links").withContents( // - tableWithHeader("Relation", "Description") // - .row("a", "one") // + this.snippet.expectLinks("documented-links").withContents( + tableWithHeader("Relation", "Description").row("a", "one") .row("b", "two")); new LinksSnippet(new StubLinkExtractor().withLinks(new Link("a", "alpha"), new Link("b", "bravo")), Arrays.asList( @@ -124,15 +121,15 @@ public class LinksSnippetTests { @Test public void linksWithCustomDescriptorAttributes() throws IOException { - this.snippet.expectLinks("links-with-custom-descriptor-attributes").withContents( // - tableWithHeader("Relation", "Description", "Foo") // - .row("a", "one", "alpha") // - .row("b", "two", "bravo")); TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("links")) - .thenReturn( + given(resolver.resolveTemplateResource("links")) + .willReturn( new FileSystemResource( "src/test/resources/custom-snippet-templates/links-with-extra-column.snippet")); + this.snippet.expectLinks("links-with-custom-descriptor-attributes").withContents( + tableWithHeader("Relation", "Description", "Foo") + .row("a", "one", "alpha").row("b", "two", "bravo")); + new LinksSnippet(new StubLinkExtractor().withLinks(new Link("a", "alpha"), new Link("b", "bravo")), Arrays.asList( new LinkDescriptor("a").description("one").attributes( @@ -146,21 +143,21 @@ public class LinksSnippetTests { @Test public void linksWithCustomAttributes() throws IOException { - this.snippet.expectLinks("links-with-custom-attributes").withContents( - startsWith(".Title for the links")); TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("links")) - .thenReturn( + given(resolver.resolveTemplateResource("links")) + .willReturn( new FileSystemResource( "src/test/resources/custom-snippet-templates/links-with-title.snippet")); + this.snippet.expectLinks("links-with-custom-attributes").withContents( + startsWith(".Title for the links")); + new LinksSnippet(new StubLinkExtractor().withLinks(new Link("a", "alpha"), new Link("b", "bravo")), Arrays.asList( new LinkDescriptor("a").description("one"), - new LinkDescriptor("b").description("two")), attributes(key("title").value( - "Title for the links"))) - .document(new OperationBuilder("links-with-custom-attributes", - this.snippet.getOutputDirectory()).attribute( - TemplateEngine.class.getName(), + new LinkDescriptor("b").description("two")), attributes(key("title") + .value("Title for the links"))).document(new OperationBuilder( + "links-with-custom-attributes", this.snippet.getOutputDirectory()) + .attribute(TemplateEngine.class.getName(), new MustacheTemplateEngine(resolver)).build()); } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/ContentModifyingOperationPreprocessorTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/ContentModifyingOperationPreprocessorTests.java index f13509b5..6923b7db 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/ContentModifyingOperationPreprocessorTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/ContentModifyingOperationPreprocessorTests.java @@ -16,10 +16,6 @@ package org.springframework.restdocs.operation.preprocess; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - import java.net.URI; import java.util.Collections; @@ -34,8 +30,12 @@ import org.springframework.restdocs.operation.Parameters; import org.springframework.restdocs.operation.StandardOperationRequest; import org.springframework.restdocs.operation.StandardOperationResponse; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + /** - * Tests for {@link ContentModifyingOperationPreprocessor} + * Tests for {@link ContentModifyingOperationPreprocessor}. * * @author Andy Wilkinson * @@ -57,7 +57,7 @@ public class ContentModifyingOperationPreprocessorTests { StandardOperationRequest request = new StandardOperationRequest( URI.create("http://localhost"), HttpMethod.GET, "content".getBytes(), new HttpHeaders(), new Parameters(), - Collections. emptyList()); + Collections.emptyList()); OperationRequest preprocessed = this.preprocessor.preprocess(request); assertThat(preprocessed.getContent(), is(equalTo("modified".getBytes()))); } @@ -75,7 +75,7 @@ public class ContentModifyingOperationPreprocessorTests { StandardOperationRequest request = new StandardOperationRequest( URI.create("http://localhost"), HttpMethod.GET, "content".getBytes(), new HttpHeaders(), new Parameters(), - Collections. emptyList()); + Collections.emptyList()); OperationRequest preprocessed = this.preprocessor.preprocess(request); assertThat(preprocessed.getHeaders().getContentLength(), is(equalTo(-1L))); } @@ -87,7 +87,7 @@ public class ContentModifyingOperationPreprocessorTests { StandardOperationRequest request = new StandardOperationRequest( URI.create("http://localhost"), HttpMethod.GET, "content".getBytes(), httpHeaders, new Parameters(), - Collections. emptyList()); + Collections.emptyList()); OperationRequest preprocessed = this.preprocessor.preprocess(request); assertThat(preprocessed.getHeaders().getContentLength(), is(equalTo(8L))); } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationRequestPreprocessorTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationRequestPreprocessorTests.java index fdfe17c7..622dc5a8 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationRequestPreprocessorTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationRequestPreprocessorTests.java @@ -16,19 +16,19 @@ package org.springframework.restdocs.operation.preprocess; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import java.util.Arrays; import org.junit.Test; import org.springframework.restdocs.operation.OperationRequest; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; + /** - * Tests for {@link DelegatingOperationRequestPreprocessor} - * + * Tests for {@link DelegatingOperationRequestPreprocessor}. + * * @author Andy Wilkinson */ public class DelegatingOperationRequestPreprocessorTests { @@ -36,19 +36,17 @@ public class DelegatingOperationRequestPreprocessorTests { @Test public void delegationOccurs() { OperationRequest originalRequest = mock(OperationRequest.class); - OperationPreprocessor preprocessor1 = mock(OperationPreprocessor.class); OperationRequest preprocessedRequest1 = mock(OperationRequest.class); - when(preprocessor1.preprocess(originalRequest)).thenReturn(preprocessedRequest1); - OperationPreprocessor preprocessor2 = mock(OperationPreprocessor.class); OperationRequest preprocessedRequest2 = mock(OperationRequest.class); - when(preprocessor2.preprocess(preprocessedRequest1)).thenReturn( - preprocessedRequest2); - OperationPreprocessor preprocessor3 = mock(OperationPreprocessor.class); OperationRequest preprocessedRequest3 = mock(OperationRequest.class); - when(preprocessor3.preprocess(preprocessedRequest2)).thenReturn( + + given(preprocessor1.preprocess(originalRequest)).willReturn(preprocessedRequest1); + given(preprocessor2.preprocess(preprocessedRequest1)).willReturn( + preprocessedRequest2); + given(preprocessor3.preprocess(preprocessedRequest2)).willReturn( preprocessedRequest3); OperationRequest result = new DelegatingOperationRequestPreprocessor( @@ -57,4 +55,5 @@ public class DelegatingOperationRequestPreprocessorTests { assertThat(result, is(preprocessedRequest3)); } + } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationResponsePreprocessorTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationResponsePreprocessorTests.java index 764eb63d..0ddb85a3 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationResponsePreprocessorTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/DelegatingOperationResponsePreprocessorTests.java @@ -16,19 +16,19 @@ package org.springframework.restdocs.operation.preprocess; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import java.util.Arrays; import org.junit.Test; import org.springframework.restdocs.operation.OperationResponse; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; + /** - * Tests for {@link DelegatingOperationResponsePreprocessor} - * + * Tests for {@link DelegatingOperationResponsePreprocessor}. + * * @author Andy Wilkinson */ public class DelegatingOperationResponsePreprocessorTests { @@ -36,20 +36,18 @@ public class DelegatingOperationResponsePreprocessorTests { @Test public void delegationOccurs() { OperationResponse originalResponse = mock(OperationResponse.class); - OperationPreprocessor preprocessor1 = mock(OperationPreprocessor.class); OperationResponse preprocessedResponse1 = mock(OperationResponse.class); - when(preprocessor1.preprocess(originalResponse)) - .thenReturn(preprocessedResponse1); - OperationPreprocessor preprocessor2 = mock(OperationPreprocessor.class); OperationResponse preprocessedResponse2 = mock(OperationResponse.class); - when(preprocessor2.preprocess(preprocessedResponse1)).thenReturn( - preprocessedResponse2); - OperationPreprocessor preprocessor3 = mock(OperationPreprocessor.class); OperationResponse preprocessedResponse3 = mock(OperationResponse.class); - when(preprocessor3.preprocess(preprocessedResponse2)).thenReturn( + + given(preprocessor1.preprocess(originalResponse)).willReturn( + preprocessedResponse1); + given(preprocessor2.preprocess(preprocessedResponse1)).willReturn( + preprocessedResponse2); + given(preprocessor3.preprocess(preprocessedResponse2)).willReturn( preprocessedResponse3); OperationResponse result = new DelegatingOperationResponsePreprocessor( diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/HeaderRemovingOperationPreprocessorTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/HeaderRemovingOperationPreprocessorTests.java index cf710c81..808b9ab9 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/HeaderRemovingOperationPreprocessorTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/HeaderRemovingOperationPreprocessorTests.java @@ -16,11 +16,6 @@ package org.springframework.restdocs.operation.preprocess; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.hasEntry; -import static org.junit.Assert.assertThat; - import java.net.URI; import java.util.Arrays; import java.util.Collections; @@ -36,8 +31,13 @@ import org.springframework.restdocs.operation.Parameters; import org.springframework.restdocs.operation.StandardOperationRequest; import org.springframework.restdocs.operation.StandardOperationResponse; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.hasEntry; +import static org.junit.Assert.assertThat; + /** - * Tests for {@link HeaderRemovingOperationPreprocessorTests} + * Tests for {@link HeaderRemovingOperationPreprocessorTests}. * * @author Andy Wilkinson * @@ -52,7 +52,7 @@ public class HeaderRemovingOperationPreprocessorTests { StandardOperationRequest request = new StandardOperationRequest( URI.create("http://localhost"), HttpMethod.GET, new byte[0], getHttpHeaders(), new Parameters(), - Collections. emptyList()); + Collections.emptyList()); OperationRequest preprocessed = this.preprocessor.preprocess(request); assertThat(preprocessed.getHeaders().size(), is(equalTo(1))); assertThat(preprocessed.getHeaders(), hasEntry("a", Arrays.asList("alpha"))); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/LinkMaskingContentModifierTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/LinkMaskingContentModifierTests.java index aa881ba8..e63b887c 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/LinkMaskingContentModifierTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/LinkMaskingContentModifierTests.java @@ -16,10 +16,6 @@ package org.springframework.restdocs.operation.preprocess; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; @@ -34,8 +30,12 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + /** - * Tests for {@link LinkMaskingContentModifier} + * Tests for {@link LinkMaskingContentModifier}. * * @author Andy Wilkinson * @@ -125,21 +125,22 @@ public class LinkMaskingContentModifierTests { return payload; } - static final class AtomPayload { + private static final class AtomPayload { private List links; + @SuppressWarnings("unused") + public List getLinks() { + return this.links; + } + public void setLinks(List links) { this.links = links; } - public List getLinks() { - return this.links; - } - } - static final class HalPayload { + private static final class HalPayload { private Map links; diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifierTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifierTests.java index c7a1e2c9..de9ba056 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifierTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifierTests.java @@ -16,16 +16,16 @@ package org.springframework.restdocs.operation.preprocess; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - import java.util.regex.Pattern; import org.junit.Test; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + /** - * Tests for {@link PatternReplacingContentModifier} + * Tests for {@link PatternReplacingContentModifier}. * * @author Andy Wilkinson * diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java index 8e6aa197..abedadf3 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java @@ -16,14 +16,14 @@ package org.springframework.restdocs.operation.preprocess; +import org.junit.Test; + import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; -import org.junit.Test; - /** - * Tests for {@link PrettyPrintingContentModifier} - * + * Tests for {@link PrettyPrintingContentModifier}. + * * @author Andy Wilkinson * */ diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldPathTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldPathTests.java index f219abce..04397796 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldPathTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldPathTests.java @@ -16,16 +16,16 @@ package org.springframework.restdocs.payload; +import org.junit.Test; + import static org.hamcrest.Matchers.contains; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -import org.junit.Test; - /** - * Tests for {@link JsonFieldPath} - * + * Tests for {@link JsonFieldPath}. + * * @author Andy Wilkinson * @author Jeremy Rickard */ @@ -113,17 +113,20 @@ public class JsonFieldPathTests { @Test public void compilationOfMultipleElementPathWithBrackets() { - assertThat(JsonFieldPath.compile("['a']['b']['c']").getSegments(), contains("a", "b", "c")); + assertThat(JsonFieldPath.compile("['a']['b']['c']").getSegments(), + contains("a", "b", "c")); } @Test public void compilationOfMultipleElementPathWithAndWithoutBrackets() { - assertThat(JsonFieldPath.compile("['a'][].b['c']").getSegments(), contains("a", "[]", "b", "c")); + assertThat(JsonFieldPath.compile("['a'][].b['c']").getSegments(), + contains("a", "[]", "b", "c")); } @Test public void compilationOfMultipleElementPathWithAndWithoutBracketsAndEmbeddedDots() { - assertThat(JsonFieldPath.compile("['a.key'][].b['c']").getSegments(), contains("a.key", "[]", "b", "c")); + assertThat(JsonFieldPath.compile("['a.key'][].b['c']").getSegments(), + contains("a.key", "[]", "b", "c")); } } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldProcessorTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldProcessorTests.java index 35ed2d64..d48212f0 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldProcessorTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldProcessorTests.java @@ -16,9 +16,6 @@ package org.springframework.restdocs.payload; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - import java.io.IOException; import java.util.Arrays; import java.util.HashMap; @@ -29,9 +26,12 @@ import org.junit.Test; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + /** - * Tests for {@link JsonFieldProcessor} - * + * Tests for {@link JsonFieldProcessor}. + * * @author Andy Wilkinson */ public class JsonFieldProcessorTests { diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldTypeResolverTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldTypeResolverTests.java index 46868951..7ef74aa7 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldTypeResolverTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldTypeResolverTests.java @@ -16,9 +16,6 @@ package org.springframework.restdocs.payload; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - import java.io.IOException; import java.util.Map; @@ -28,9 +25,12 @@ import org.junit.rules.ExpectedException; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + /** - * Tests for {@link JsonFieldTypeResolver} - * + * Tests for {@link JsonFieldTypeResolver}. + * * @author Andy Wilkinson * */ @@ -74,7 +74,8 @@ public class JsonFieldTypeResolverTests { @Test public void nestedField() throws IOException { assertThat(this.fieldTypeResolver.resolveFieldType("a.b.c", - createPayload("{\"a\":{\"b\":{\"c\":{}}}}")), equalTo(JsonFieldType.OBJECT)); + createPayload("{\"a\":{\"b\":{\"c\":{}}}}")), + equalTo(JsonFieldType.OBJECT)); } @Test diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetTests.java index 7e603a5b..1c1481c8 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetTests.java @@ -16,16 +16,6 @@ package org.springframework.restdocs.payload; -import static org.hamcrest.CoreMatchers.endsWith; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; -import static org.springframework.restdocs.snippet.Attributes.attributes; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.restdocs.test.SnippetMatchers.tableWithHeader; - import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -43,9 +33,19 @@ import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; import org.springframework.restdocs.test.ExpectedSnippet; 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.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.snippet.Attributes.attributes; +import static org.springframework.restdocs.snippet.Attributes.key; +import static org.springframework.restdocs.test.SnippetMatchers.tableWithHeader; + /** - * Tests for {@link RequestFieldsSnippet} - * + * Tests for {@link RequestFieldsSnippet}. + * * @author Andy Wilkinson */ public class RequestFieldsSnippetTests { @@ -58,10 +58,9 @@ public class RequestFieldsSnippetTests { @Test public void mapRequestWithFields() throws IOException { - this.snippet.expectRequestFields("map-request-with-fields").withContents( // - tableWithHeader("Path", "Type", "Description") // - .row("a.b", "Number", "one") // - .row("a.c", "String", "two") // + this.snippet.expectRequestFields("map-request-with-fields").withContents( + tableWithHeader("Path", "Type", "Description") + .row("a.b", "Number", "one").row("a.c", "String", "two") .row("a", "Object", "three")); new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a.b").description("one"), @@ -74,10 +73,9 @@ public class RequestFieldsSnippetTests { @Test public void arrayRequestWithFields() throws IOException { - this.snippet.expectRequestFields("array-request-with-fields").withContents( // - tableWithHeader("Path", "Type", "Description") // - .row("[]a.b", "Number", "one") // - .row("[]a.c", "String", "two") // + this.snippet.expectRequestFields("array-request-with-fields").withContents( + tableWithHeader("Path", "Type", "Description") + .row("[]a.b", "Number", "one").row("[]a.c", "String", "two") .row("[]a", "Object", "three")); new RequestFieldsSnippet(Arrays.asList(fieldWithPath("[]a.b").description("one"), @@ -94,7 +92,7 @@ public class RequestFieldsSnippetTests { this.thrown .expectMessage(startsWith("The following parts of the payload were not" + " documented:")); - new RequestFieldsSnippet(Collections. emptyList()) + new RequestFieldsSnippet(Collections.emptyList()) .document(new OperationBuilder("undocumented-request-field", this.snippet .getOutputDirectory()).request("http://localhost") .content("{\"a\": 5}").build()); @@ -140,15 +138,16 @@ public class RequestFieldsSnippetTests { @Test public void requestFieldsWithCustomDescriptorAttributes() throws IOException { - this.snippet.expectRequestFields( - "request-fields-with-custom-descriptor-attributes").withContents( // - tableWithHeader("Path", "Type", "Description", "Foo") // - .row("a.b", "Number", "one", "alpha") // - .row("a.c", "String", "two", "bravo") // - .row("a", "Object", "three", "charlie")); TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("request-fields")).thenReturn( + given(resolver.resolveTemplateResource("request-fields")).willReturn( snippetResource("request-fields-with-extra-column")); + this.snippet.expectRequestFields( + "request-fields-with-custom-descriptor-attributes").withContents( + tableWithHeader("Path", "Type", "Description", "Foo") + .row("a.b", "Number", "one", "alpha") + .row("a.c", "String", "two", "bravo") + .row("a", "Object", "three", "charlie")); + new RequestFieldsSnippet(Arrays.asList( fieldWithPath("a.b").description("one").attributes( key("foo").value("alpha")), @@ -165,11 +164,12 @@ public class RequestFieldsSnippetTests { @Test public void requestFieldsWithCustomAttributes() throws IOException { + TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); + given(resolver.resolveTemplateResource("request-fields")).willReturn( + snippetResource("request-fields-with-title")); this.snippet.expectRequestFields("request-fields-with-custom-attributes") .withContents(startsWith(".Custom title")); - TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("request-fields")).thenReturn( - snippetResource("request-fields-with-title")); + new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a").description("one")), attributes(key("title").value("Custom title"))) .document(new OperationBuilder("request-fields-with-custom-attributes", @@ -181,15 +181,16 @@ public class RequestFieldsSnippetTests { @Test public void requestFieldsWithListDescription() throws IOException { + TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); + given(resolver.resolveTemplateResource("request-fields")).willReturn( + snippetResource("request-fields-with-list-description")); this.snippet.expectRequestFields("request-fields-with-list-description") .withContents( tableWithHeader("Path", "Type", "Description") // .row("a", "String", String.format(" - one%n - two")) .configuration("[cols=\"1,1,1a\"]")); - TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("request-fields")).thenReturn( - snippetResource("request-fields-with-list-description")); + new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a").description( Arrays.asList("one", "two")))) .document(new OperationBuilder("request-fields-with-list-description", @@ -201,11 +202,9 @@ public class RequestFieldsSnippetTests { @Test public void xmlRequestFields() throws IOException { - this.snippet.expectRequestFields("xml-request").withContents( // - tableWithHeader("Path", "Type", "Description") // - .row("a/b", "b", "one") // - .row("a/c", "c", "two") // - .row("a", "a", "three")); + this.snippet.expectRequestFields("xml-request").withContents( + tableWithHeader("Path", "Type", "Description").row("a/b", "b", "one") + .row("a/c", "c", "two").row("a", "a", "three")); new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a/b").description("one") .type("b"), fieldWithPath("a/c").description("two").type("c"), @@ -224,7 +223,7 @@ public class RequestFieldsSnippetTests { this.thrown .expectMessage(startsWith("The following parts of the payload were not" + " documented:")); - new RequestFieldsSnippet(Collections. emptyList()) + new RequestFieldsSnippet(Collections.emptyList()) .document(new OperationBuilder("undocumented-xml-request-field", this.snippet.getOutputDirectory()) .request("http://localhost") diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java index e8459d7f..56bf5688 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java @@ -13,17 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.restdocs.payload; -import static org.hamcrest.CoreMatchers.endsWith; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; -import static org.springframework.restdocs.snippet.Attributes.attributes; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.restdocs.test.SnippetMatchers.tableWithHeader; +package org.springframework.restdocs.payload; import java.io.IOException; import java.util.Arrays; @@ -42,8 +33,18 @@ import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; import org.springframework.restdocs.test.ExpectedSnippet; 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.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.snippet.Attributes.attributes; +import static org.springframework.restdocs.snippet.Attributes.key; +import static org.springframework.restdocs.test.SnippetMatchers.tableWithHeader; + /** - * Tests for {@link ReponseFieldsSnippet} + * Tests for {@link ResponseFieldsSnippet}. * * @author Andy Wilkinson */ @@ -57,13 +58,11 @@ public class ResponseFieldsSnippetTests { @Test public void mapResponseWithFields() throws IOException { - this.snippet.expectResponseFields("map-response-with-fields").withContents(// - tableWithHeader("Path", "Type", "Description") // - .row("id", "Number", "one") // - .row("date", "String", "two") // - .row("assets", "Array", "three") // - .row("assets[]", "Object", "four") // - .row("assets[].id", "Number", "five") // + this.snippet.expectResponseFields("map-response-with-fields").withContents( + tableWithHeader("Path", "Type", "Description").row("id", "Number", "one") + .row("date", "String", "two").row("assets", "Array", "three") + .row("assets[]", "Object", "four") + .row("assets[].id", "Number", "five") .row("assets[].name", "String", "six")); new ResponseFieldsSnippet(Arrays.asList(fieldWithPath("id").description("one"), fieldWithPath("date").description("two"), fieldWithPath("assets") @@ -82,10 +81,9 @@ public class ResponseFieldsSnippetTests { @Test public void arrayResponseWithFields() throws IOException { - this.snippet.expectResponseFields("array-response-with-fields").withContents( // - tableWithHeader("Path", "Type", "Description") // - .row("[]a.b", "Number", "one") // - .row("[]a.c", "String", "two") // + this.snippet.expectResponseFields("array-response-with-fields").withContents( + tableWithHeader("Path", "Type", "Description") + .row("[]a.b", "Number", "one").row("[]a.c", "String", "two") .row("[]a", "Object", "three")); new ResponseFieldsSnippet(Arrays.asList( fieldWithPath("[]a.b").description("one"), fieldWithPath("[]a.c") @@ -98,9 +96,10 @@ public class ResponseFieldsSnippetTests { @Test public void arrayResponse() throws IOException { - this.snippet.expectResponseFields("array-response").withContents( // - tableWithHeader("Path", "Type", "Description") // - .row("[]", "String", "one")); + this.snippet.expectResponseFields("array-response") + .withContents( + tableWithHeader("Path", "Type", "Description").row("[]", + "String", "one")); new ResponseFieldsSnippet(Arrays.asList(fieldWithPath("[]").description("one"))) .document(new OperationBuilder("array-response", this.snippet .getOutputDirectory()).response() @@ -109,15 +108,16 @@ public class ResponseFieldsSnippetTests { @Test public void responseFieldsWithCustomDescriptorAttributes() throws IOException { - this.snippet.expectResponseFields("response-fields-with-custom-attributes") - .withContents( // - tableWithHeader("Path", "Type", "Description", "Foo") // - .row("a.b", "Number", "one", "alpha") // - .row("a.c", "String", "two", "bravo") // - .row("a", "Object", "three", "charlie")); TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("response-fields")).thenReturn( + given(resolver.resolveTemplateResource("response-fields")).willReturn( snippetResource("response-fields-with-extra-column")); + this.snippet.expectResponseFields("response-fields-with-custom-attributes") + .withContents( + tableWithHeader("Path", "Type", "Description", "Foo") + .row("a.b", "Number", "one", "alpha") + .row("a.c", "String", "two", "bravo") + .row("a", "Object", "three", "charlie")); + new ResponseFieldsSnippet(Arrays.asList( fieldWithPath("a.b").description("one").attributes( key("foo").value("alpha")), @@ -134,11 +134,12 @@ public class ResponseFieldsSnippetTests { @Test public void responseFieldsWithCustomAttributes() throws IOException { + TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); + given(resolver.resolveTemplateResource("response-fields")).willReturn( + snippetResource("response-fields-with-title")); this.snippet.expectResponseFields("response-fields-with-custom-attributes") .withContents(startsWith(".Custom title")); - TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("response-fields")).thenReturn( - snippetResource("response-fields-with-title")); + new ResponseFieldsSnippet(Arrays.asList(fieldWithPath("a").description("one")), attributes(key("title").value("Custom title"))) .document(new OperationBuilder("response-fields-with-custom-attributes", @@ -150,11 +151,9 @@ public class ResponseFieldsSnippetTests { @Test public void xmlResponseFields() throws IOException { - this.snippet.expectResponseFields("xml-response").withContents( // - tableWithHeader("Path", "Type", "Description") // - .row("a/b", "b", "one") // - .row("a/c", "c", "two") // - .row("a", "a", "three")); + this.snippet.expectResponseFields("xml-response").withContents( + tableWithHeader("Path", "Type", "Description").row("a/b", "b", "one") + .row("a/c", "c", "two").row("a", "a", "three")); new ResponseFieldsSnippet(Arrays.asList(fieldWithPath("a/b").description("one") .type("b"), fieldWithPath("a/c").description("two").type("c"), fieldWithPath("a").description("three").type("a"))) @@ -172,7 +171,7 @@ public class ResponseFieldsSnippetTests { this.thrown .expectMessage(startsWith("The following parts of the payload were not" + " documented:")); - new ResponseFieldsSnippet(Collections. emptyList()) + new ResponseFieldsSnippet(Collections.emptyList()) .document(new OperationBuilder("undocumented-xml-response-field", this.snippet.getOutputDirectory()) .response() diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java index 5d858d93..f7f0f462 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java @@ -16,16 +16,6 @@ package org.springframework.restdocs.request; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.snippet.Attributes.attributes; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.restdocs.test.SnippetMatchers.tableWithHeader; -import static org.springframework.restdocs.test.SnippetMatchers.tableWithTitleAndHeader; - import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -41,10 +31,20 @@ import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; import org.springframework.restdocs.test.ExpectedSnippet; import org.springframework.restdocs.test.OperationBuilder; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.startsWith; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; +import static org.springframework.restdocs.snippet.Attributes.attributes; +import static org.springframework.restdocs.snippet.Attributes.key; +import static org.springframework.restdocs.test.SnippetMatchers.tableWithHeader; +import static org.springframework.restdocs.test.SnippetMatchers.tableWithTitleAndHeader; + /** - * Tests for {@link PathParametersSnippet} - * - * @author awilkinson + * Tests for {@link PathParametersSnippet}. + * + * @author Andy Wilkinson * */ public class PathParametersSnippetTests { @@ -60,7 +60,7 @@ public class PathParametersSnippetTests { this.thrown.expect(SnippetException.class); this.thrown.expectMessage(equalTo("Path parameters with the following names were" + " not documented: [a]")); - new PathParametersSnippet(Collections. emptyList()) + new PathParametersSnippet(Collections.emptyList()) .document(new OperationBuilder("undocumented-path-parameter", this.snippet.getOutputDirectory()).attribute( "org.springframework.restdocs.urlTemplate", "/{a}/").build()); @@ -121,13 +121,14 @@ public class PathParametersSnippetTests { @Test public void pathParametersWithCustomDescriptorAttributes() throws IOException { + TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); + given(resolver.resolveTemplateResource("path-parameters")).willReturn( + snippetResource("path-parameters-with-extra-column")); this.snippet.expectPathParameters( "path-parameters-with-custom-descriptor-attributes").withContents( tableWithHeader("Parameter", "Description", "Foo").row("a", "one", "alpha").row("b", "two", "bravo")); - TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("path-parameters")).thenReturn( - snippetResource("path-parameters-with-extra-column")); + new PathParametersSnippet(Arrays.asList(parameterWithName("a").description("one") .attributes(key("foo").value("alpha")), parameterWithName("b") .description("two").attributes(key("foo").value("bravo")))) @@ -141,16 +142,15 @@ public class PathParametersSnippetTests { @Test public void pathParametersWithCustomAttributes() throws IOException { + TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); + given(resolver.resolveTemplateResource("path-parameters")).willReturn( + snippetResource("path-parameters-with-title")); this.snippet.expectPathParameters("path-parameters-with-custom-attributes") .withContents(startsWith(".The title")); - TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("path-parameters")).thenReturn( - snippetResource("path-parameters-with-title")); - new PathParametersSnippet( - Arrays.asList( - parameterWithName("a").description("one").attributes( - key("foo").value("alpha")), parameterWithName("b") - .description("two").attributes(key("foo").value("bravo"))), + + new PathParametersSnippet(Arrays.asList(parameterWithName("a").description("one") + .attributes(key("foo").value("alpha")), parameterWithName("b") + .description("two").attributes(key("foo").value("bravo"))), attributes(key("title").value("The title"))) .document(new OperationBuilder("path-parameters-with-custom-attributes", this.snippet.getOutputDirectory()) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetTests.java index 330d411c..9ac76972 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetTests.java @@ -16,15 +16,6 @@ package org.springframework.restdocs.request; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.snippet.Attributes.attributes; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.restdocs.test.SnippetMatchers.tableWithHeader; - import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -40,8 +31,17 @@ import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; import org.springframework.restdocs.test.ExpectedSnippet; import org.springframework.restdocs.test.OperationBuilder; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.startsWith; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; +import static org.springframework.restdocs.snippet.Attributes.attributes; +import static org.springframework.restdocs.snippet.Attributes.key; +import static org.springframework.restdocs.test.SnippetMatchers.tableWithHeader; + /** - * Tests for {@link RequestParametersSnippet} + * Tests for {@link RequestParametersSnippet}. * * @author Andy Wilkinson */ @@ -59,7 +59,7 @@ public class RequestParametersSnippetTests { this.thrown .expectMessage(equalTo("Request parameters with the following names were" + " not documented: [a]")); - new RequestParametersSnippet(Collections. emptyList()) + new RequestParametersSnippet(Collections.emptyList()) .document(new OperationBuilder("undocumented-parameter", this.snippet .getOutputDirectory()).request("http://localhost") .param("a", "alpha").build()); @@ -104,13 +104,14 @@ public class RequestParametersSnippetTests { @Test public void requestParametersWithCustomDescriptorAttributes() throws IOException { + TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); + given(resolver.resolveTemplateResource("request-parameters")).willReturn( + snippetResource("request-parameters-with-extra-column")); this.snippet.expectRequestParameters( "request-parameters-with-custom-descriptor-attributes").withContents( tableWithHeader("Parameter", "Description", "Foo").row("a", "one", "alpha").row("b", "two", "bravo")); - TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("request-parameters")).thenReturn( - snippetResource("request-parameters-with-extra-column")); + new RequestParametersSnippet(Arrays.asList( parameterWithName("a").description("one").attributes( key("foo").value("alpha")), @@ -125,24 +126,23 @@ public class RequestParametersSnippetTests { @Test public void requestParametersWithCustomAttributes() throws IOException { + TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); + given(resolver.resolveTemplateResource("request-parameters")).willReturn( + snippetResource("request-parameters-with-title")); this.snippet.expectRequestParameters("request-parameters-with-custom-attributes") .withContents(startsWith(".The title")); - TemplateResourceResolver resolver = mock(TemplateResourceResolver.class); - when(resolver.resolveTemplateResource("request-parameters")).thenReturn( - snippetResource("request-parameters-with-title")); - new RequestParametersSnippet( - Arrays.asList( - parameterWithName("a").description("one").attributes( - key("foo").value("alpha")), parameterWithName("b") - .description("two").attributes(key("foo").value("bravo"))), - attributes(key("title").value("The title"))) - .document(new OperationBuilder( - "request-parameters-with-custom-attributes", this.snippet - .getOutputDirectory()) - .attribute(TemplateEngine.class.getName(), - new MustacheTemplateEngine(resolver)) - .request("http://localhost").param("a", "alpha") - .param("b", "bravo").build()); + + new RequestParametersSnippet(Arrays.asList( + parameterWithName("a").description("one").attributes( + key("foo").value("alpha")), + parameterWithName("b").description("two").attributes( + key("foo").value("bravo"))), attributes(key("title").value( + "The title"))).document(new OperationBuilder( + "request-parameters-with-custom-attributes", this.snippet + .getOutputDirectory()) + .attribute(TemplateEngine.class.getName(), + new MustacheTemplateEngine(resolver)).request("http://localhost") + .param("a", "alpha").param("b", "bravo").build()); } private FileSystemResource snippetResource(String name) { diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolverTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolverTests.java index 37c19160..b70e936d 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolverTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolverTests.java @@ -16,15 +16,15 @@ package org.springframework.restdocs.snippet; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - import org.junit.Test; import org.springframework.restdocs.RestDocumentationContext; import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + /** - * Tests for {@link RestDocumentationContextPlaceholderResolver} + * Tests for {@link RestDocumentationContextPlaceholderResolver}. * * @author Andy Wilkinson * 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 2f186dd0..55ae2218 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 @@ -16,20 +16,20 @@ package org.springframework.restdocs.snippet; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; - import java.io.File; import org.junit.Test; import org.springframework.restdocs.RestDocumentationContext; import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; + /** * Tests for {@link StandardWriterResolver}. - * + * * @author Andy Wilkinson */ public class StandardWriterResolverTests { 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 bb221c76..ef807ee2 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 @@ -13,11 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.restdocs.templates; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +package org.springframework.restdocs.templates; import java.net.URL; import java.util.HashMap; @@ -29,9 +26,13 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.core.io.Resource; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + /** * Tests for {@link TemplateResourceResolver}. - * + * * @author Andy Wilkinson */ public class StandardTemplateResourceResolverTests { diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/ExpectedSnippet.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/ExpectedSnippet.java index 9786aa20..c20b0df0 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/ExpectedSnippet.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/ExpectedSnippet.java @@ -16,9 +16,6 @@ package org.springframework.restdocs.test; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - import java.io.File; import java.io.IOException; @@ -29,10 +26,13 @@ import org.junit.runners.model.Statement; import org.springframework.restdocs.snippet.TemplatedSnippet; import org.springframework.restdocs.test.SnippetMatchers.SnippetMatcher; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + /** * The {@code ExpectedSnippet} rule is used to verify that a {@link TemplatedSnippet} has * generated the expected snippet. - * + * * @author Andy Wilkinson */ public class ExpectedSnippet implements TestRule { @@ -52,22 +52,6 @@ public class ExpectedSnippet implements TestRule { return new ExpectedSnippetStatement(base); } - private final class ExpectedSnippetStatement extends Statement { - - private final Statement delegate; - - public ExpectedSnippetStatement(Statement delegate) { - this.delegate = delegate; - } - - @Override - public void evaluate() throws Throwable { - this.delegate.evaluate(); - verifySnippet(); - } - - } - private void verifySnippet() throws IOException { if (this.outputDirectory != null && this.expectedName != null) { File snippetDir = new File(this.outputDirectory, this.expectedName); @@ -130,4 +114,20 @@ public class ExpectedSnippet implements TestRule { return this.outputDirectory; } + private final class ExpectedSnippetStatement extends Statement { + + private final Statement delegate; + + private ExpectedSnippetStatement(Statement delegate) { + this.delegate = delegate; + } + + @Override + public void evaluate() throws Throwable { + this.delegate.evaluate(); + verifySnippet(); + } + + } + } 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 e28d5751..50d6cd83 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 @@ -43,6 +43,11 @@ import org.springframework.restdocs.templates.StandardTemplateResourceResolver; import org.springframework.restdocs.templates.TemplateEngine; import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; +/** + * Basic builder API for creating an {@link Operation}. + * + * @author Andy Wilkinson + */ public class OperationBuilder { private final Map attributes = new HashMap<>(); @@ -91,7 +96,10 @@ public class OperationBuilder { this.responseBuilder.buildResponse(), this.attributes); } - public class OperationRequestBuilder { + /** + * Basic builder API for creating an {@link OperationRequest}. + */ + public final class OperationRequestBuilder { private URI requestUri = URI.create("http://localhost/"); @@ -105,7 +113,7 @@ public class OperationBuilder { private List partBuilders = new ArrayList<>(); - public OperationRequestBuilder(String uri) { + private OperationRequestBuilder(String uri) { this.requestUri = URI.create(uri); } @@ -151,7 +159,10 @@ public class OperationBuilder { return partBuilder; } - public class OperationRequestPartBuilder { + /** + * Basic builder API for creating an {@link OperationRequestPart}. + */ + public final class OperationRequestPartBuilder { private final String name; @@ -191,7 +202,10 @@ public class OperationBuilder { } } - public class OperationResponseBuilder { + /** + * Basic builder API for creating an {@link OperationResponse}. + */ + public final class OperationResponseBuilder { private HttpStatus status = HttpStatus.OK; diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/SnippetMatchers.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/SnippetMatchers.java index 444b2b53..8bbb6de3 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/SnippetMatchers.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/SnippetMatchers.java @@ -35,10 +35,14 @@ import org.springframework.web.bind.annotation.RequestMethod; /** * {@link Matcher Matchers} for verify the contents of generated documentation snippets. - * + * * @author Andy Wilkinson */ -public class SnippetMatchers { +public final class SnippetMatchers { + + private SnippetMatchers() { + + } public static SnippetMatcher snippet() { return new SnippetMatcher(); @@ -117,6 +121,11 @@ public class SnippetMatchers { } } + /** + * A {@link Matcher} for an Asciidoctor code block. + * + * @param The type of the matcher + */ public static class AsciidoctorCodeBlockMatcher> extends AbstractSnippetContentMatcher { @@ -134,6 +143,11 @@ public class SnippetMatchers { } + /** + * A {@link Matcher} for an HTTP request or response. + * + * @param The type of the matcher + */ public static abstract class HttpMatcher> extends AsciidoctorCodeBlockMatcher> { @@ -151,25 +165,36 @@ public class SnippetMatchers { } - public static class HttpResponseMatcher extends HttpMatcher { + /** + * A {@link Matcher} for an HTTP response. + */ + public static final class HttpResponseMatcher extends + HttpMatcher { - public HttpResponseMatcher(HttpStatus status) { + private HttpResponseMatcher(HttpStatus status) { this.content("HTTP/1.1 " + status.value() + " " + status.getReasonPhrase()); this.content(""); } } - public static class HttpRequestMatcher extends HttpMatcher { + /** + * A {@link Matcher} for an HTTP request. + */ + public static final class HttpRequestMatcher extends HttpMatcher { - public HttpRequestMatcher(RequestMethod requestMethod, String uri) { + private HttpRequestMatcher(RequestMethod requestMethod, String uri) { this.content(requestMethod.name() + " " + uri + " HTTP/1.1"); this.content(""); } } - public static class AsciidoctorTableMatcher extends AbstractSnippetContentMatcher { + /** + * A {@link Matcher} for an Asciidoctor table. + */ + public static final class AsciidoctorTableMatcher extends + AbstractSnippetContentMatcher { private AsciidoctorTableMatcher(String title, String... columns) { if (StringUtils.hasText(title)) { @@ -198,6 +223,9 @@ public class SnippetMatchers { } } + /** + * A {@link Matcher} for a snippet file. + */ public static class SnippetMatcher extends BaseMatcher { private Matcher expectedContents; diff --git a/spring-restdocs-mockmvc/.settings/org.eclipse.jdt.core.prefs b/spring-restdocs-mockmvc/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b9206d84..00000000 --- a/spring-restdocs-mockmvc/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,305 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.codeComplete.argumentPrefixes= -org.eclipse.jdt.core.codeComplete.argumentSuffixes= -org.eclipse.jdt.core.codeComplete.fieldPrefixes= -org.eclipse.jdt.core.codeComplete.fieldSuffixes= -org.eclipse.jdt.core.codeComplete.localPrefixes= -org.eclipse.jdt.core.codeComplete.localSuffixes= -org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=1 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=1 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=false -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=false -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=do not insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=90 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=8 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=true -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=90 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=tab -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.use_on_off_tags=false -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true \ No newline at end of file diff --git a/spring-restdocs-mockmvc/.settings/org.eclipse.jdt.ui.prefs b/spring-restdocs-mockmvc/.settings/org.eclipse.jdt.ui.prefs index 3f14d635..c5e23c90 100644 --- a/spring-restdocs-mockmvc/.settings/org.eclipse.jdt.ui.prefs +++ b/spring-restdocs-mockmvc/.settings/org.eclipse.jdt.ui.prefs @@ -50,21 +50,27 @@ cleanup.use_blocks=true cleanup.use_blocks_only_for_return_and_throw=false cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=false -cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access=false cleanup.use_this_for_non_static_field_access_only_if_necessary=false cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access_only_if_necessary=true cleanup.use_type_arguments=false -cleanup_profile=_Spring Rest Docs Cleanup Conventions +cleanup_profile=_Spring REST Docs Cleanup Conventions cleanup_settings_version=2 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_Spring Rest Docs Java Conventions +formatter_profile=_Spring REST Docs Java Conventions formatter_settings_version=12 org.eclipse.jdt.ui.exception.name=e -org.eclipse.jdt.ui.gettersetter.use.is=true -org.eclipse.jdt.ui.keywordthis=true +org.eclipse.jdt.ui.gettersetter.use.is=false +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com;;\#; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=9999 org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=9999 +org.eclipse.jdt.ui.text.custom_code_templates= sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true @@ -75,22 +81,20 @@ sp_cleanup.add_missing_override_annotations=true sp_cleanup.add_missing_override_annotations_interface_methods=true sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_parentheses_in_expressions=true sp_cleanup.always_use_this_for_non_static_field_access=true -sp_cleanup.always_use_this_for_non_static_method_access=true -sp_cleanup.convert_functional_interfaces=false +sp_cleanup.always_use_this_for_non_static_method_access=false sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true sp_cleanup.format_source_code_changes_only=false -sp_cleanup.insert_inferred_type_arguments=false -sp_cleanup.make_local_variable_final=true +sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true +sp_cleanup.make_private_fields_final=false sp_cleanup.make_type_abstract_if_missing_method=false sp_cleanup.make_variable_declarations_final=false sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.never_use_parentheses_in_expressions=false sp_cleanup.on_save_use_additional_actions=true sp_cleanup.organize_imports=true sp_cleanup.qualify_static_field_accesses_with_declaring_class=false @@ -99,13 +103,12 @@ sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class= sp_cleanup.qualify_static_member_accesses_with_declaring_class=true sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_redundant_type_arguments=true -sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces=true sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_imports=true sp_cleanup.remove_unused_local_variables=false sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false @@ -113,13 +116,10 @@ sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false -sp_cleanup.use_anonymous_class_creation=false -sp_cleanup.use_blocks=false +sp_cleanup.use_blocks=true sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_lambda=true sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=true sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false sp_cleanup.use_this_for_non_static_method_access=false -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=false -sp_cleanup.use_type_arguments=false \ No newline at end of file +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/AbstractConfigurer.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/AbstractConfigurer.java index ebb0a4c4..f8effd0a 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/AbstractConfigurer.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/AbstractConfigurer.java @@ -21,13 +21,14 @@ import org.springframework.mock.web.MockHttpServletRequest; /** * Abstract configurer that declares methods that are internal to the documentation * configuration implementation. - * + * * @author Andy Wilkinson */ abstract class AbstractConfigurer { /** - * Applies the configuration, possibly by modifying the given {@code request} + * Applies the configuration, possibly by modifying the given {@code request}. + * * @param request the request that may be modified */ abstract void apply(MockHttpServletRequest request); diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/AbstractNestedConfigurer.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/AbstractNestedConfigurer.java index 57153d70..a4444e7c 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/AbstractNestedConfigurer.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/AbstractNestedConfigurer.java @@ -23,9 +23,9 @@ import org.springframework.web.context.WebApplicationContext; /** * Base class for {@link NestedConfigurer} implementations. - * - * @author Andy Wilkinson + * * @param The type of the configurer's parent + * @author Andy Wilkinson */ abstract class AbstractNestedConfigurer extends AbstractConfigurer implements NestedConfigurer, MockMvcConfigurer { 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 5e7a7580..d80edb13 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 @@ -21,10 +21,9 @@ import java.util.Iterator; /** * An adapter to expose an {@link Enumeration} as an {@link Iterable}. - * - * @author Andy Wilkinson * * @param the type of the Enumeration's contents + * @author Andy Wilkinson */ final class IterableEnumeration implements Iterable { @@ -57,8 +56,8 @@ final class IterableEnumeration implements Iterable { } /** - * Creates a new {@code Iterable} that will iterate over the given {@code enumeration} - * + * 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} * @return the iterable diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcOperationRequestFactory.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcOperationRequestFactory.java index 4d1c4a9f..417f29e8 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcOperationRequestFactory.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcOperationRequestFactory.java @@ -16,8 +16,6 @@ package org.springframework.restdocs.mockmvc; -import static org.springframework.restdocs.mockmvc.IterableEnumeration.iterable; - import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; @@ -43,10 +41,12 @@ 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 factory for creating an {@link OperationRequest} from a * {@link MockHttpServletRequest}. - * + * * @author Andy Wilkinson * */ @@ -62,7 +62,7 @@ class MockMvcOperationRequestFactory { /** * Creates a new {@code OperationRequest} derived from the given {@code mockRequest}. - * + * * @param mockRequest the request * @return the {@code OperationRequest} * @throws Exception if the request could not be created diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcOperationResponseFactory.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcOperationResponseFactory.java index 0f6f6b8a..54915697 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcOperationResponseFactory.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcOperationResponseFactory.java @@ -25,14 +25,14 @@ import org.springframework.restdocs.operation.StandardOperationResponse; /** * A factory for creating an {@link OperationResponse} derived from a * {@link MockHttpServletResponse}. - * + * * @author Andy Wilkinson */ class MockMvcOperationResponseFactory { /** * Create a new {@code OperationResponse} derived from the given {@code mockResponse}. - * + * * @param mockResponse the response * @return the {@code OperationResponse} */ diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentation.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentation.java index 2a2cc2d6..a41ed1cf 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentation.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentation.java @@ -26,8 +26,8 @@ import org.springframework.test.web.servlet.setup.ConfigurableMockMvcBuilder; import org.springframework.test.web.servlet.setup.MockMvcConfigurer; /** - * Static factory methods for documenting RESTful APIs using Spring MVC Test - * + * Static factory methods for documenting RESTful APIs using Spring MVC Test. + * * @author Andy Wilkinson */ public abstract class MockMvcRestDocumentation { @@ -39,7 +39,7 @@ public abstract class MockMvcRestDocumentation { /** * Provides access to a {@link MockMvcConfigurer} that can be used to configure a * {@link MockMvc} instance using the given {@code restDocumentation}. - * + * * @param restDocumentation the REST documentation * @return the configurer * @see ConfigurableMockMvcBuilder#apply(MockMvcConfigurer) @@ -52,7 +52,7 @@ public abstract class MockMvcRestDocumentation { /** * 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 Mock MVC {@code ResultHandler} that will produce the documentation @@ -68,7 +68,7 @@ public abstract class MockMvcRestDocumentation { * Documents the API call with the given {@code identifier} using the given * {@code 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 that will document the API call @@ -86,7 +86,7 @@ public abstract class MockMvcRestDocumentation { * Documents the API call with the given {@code identifier} using the given * {@code 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 that will document the API call @@ -105,7 +105,7 @@ public abstract class MockMvcRestDocumentation { * {@code 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 diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/NestedConfigurer.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/NestedConfigurer.java index 2fc73bb3..1c6768c8 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/NestedConfigurer.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/NestedConfigurer.java @@ -20,15 +20,15 @@ import org.springframework.test.web.servlet.setup.MockMvcConfigurer; /** * A configurer that is nested and, therefore, has a parent. - * - * @author Andy Wilkinson + * * @param The parent's type + * @author Andy Wilkinson */ interface NestedConfigurer { /** - * Returns the configurer's parent - * + * Returns the configurer's parent. + * * @return the parent */ PARENT and(); diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationMockMvcConfigurer.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationMockMvcConfigurer.java index e13025eb..0fd6d7ca 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationMockMvcConfigurer.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationMockMvcConfigurer.java @@ -33,8 +33,8 @@ import org.springframework.util.StringUtils; import org.springframework.web.context.WebApplicationContext; /** - * A {@link MockMvcConfigurer} that can be used to configure the documentation - * + * A {@link MockMvcConfigurer} that can be used to configure the documentation. + * * @author Andy Wilkinson * @author Dmitriy Mayboroda * @see ConfigurableMockMvcBuilder#apply(MockMvcConfigurer) @@ -55,7 +55,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter /** * Creates a new {code RestDocumentationMockMvcConfigurer} that will use the given * {@code restDocumentation} when configuring MockMvc. - * + * * @param restDocumentation the rest documentation * @see MockMvcRestDocumentation#documentationConfiguration(RestDocumentation) */ @@ -69,7 +69,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter /** * Returns a {@link UriConfigurer} that can be used to configure the request URIs that * will be documented. - * + * * @return the URI configurer */ public UriConfigurer uris() { @@ -79,7 +79,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter /** * Returns a {@link SnippetConfigurer} that can be used to configure the snippets that * will be generated. - * + * * @return the snippet configurer */ public SnippetConfigurer snippets() { @@ -88,7 +88,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter /** * Configures the {@link TemplateEngine} that will be used for snippet rendering. - * + * * @param templateEngine the template engine to use * @return {@code this} */ @@ -100,7 +100,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter /** * Configures the {@link WriterResolver} that will be used to resolve a writer for a * snippet. - * + * * @param writerResolver The writer resolver to use * @return {@code this} */ @@ -115,7 +115,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter return this.requestPostProcessor; } - private static class ContentLengthHeaderConfigurer extends AbstractConfigurer { + private static final class ContentLengthHeaderConfigurer extends AbstractConfigurer { @Override void apply(MockHttpServletRequest request) { @@ -128,7 +128,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter } - private static class TemplateEngineConfigurer extends AbstractConfigurer { + private static final class TemplateEngineConfigurer extends AbstractConfigurer { private TemplateEngine templateEngine = new MustacheTemplateEngine( new StandardTemplateResourceResolver()); @@ -144,7 +144,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter } - private static class WriterResolverConfigurer extends AbstractConfigurer { + private static final class WriterResolverConfigurer extends AbstractConfigurer { private WriterResolver writerResolver; @@ -167,7 +167,7 @@ public class RestDocumentationMockMvcConfigurer extends MockMvcConfigurerAdapter } - private static class ConfigurerApplyingRequestPostProcessor implements + private static final class ConfigurerApplyingRequestPostProcessor implements RequestPostProcessor { private final RestDocumentation restDocumentation; diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuilders.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuilders.java index dc6f7a25..2c9dc452 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuilders.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuilders.java @@ -29,7 +29,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; * template and makes it available for documentation. Required when * {@link RequestDocumentation#pathParameters(org.springframework.restdocs.request.ParameterDescriptor...) * ) documenting path parameters} and recommended for general usage. - * + * * @author Andy Wilkinson * @see MockMvcRequestBuilders * @see RequestDocumentation#pathParameters(org.springframework.restdocs.request.ParameterDescriptor...) @@ -47,7 +47,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a GET request. The url template * will be captured and made available for documentation. - * + * * @param urlTemplate a URL template; the resulting URL will be encoded * @param urlVariables zero or more URL variables * @return the builder for the GET request @@ -60,7 +60,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a GET request. - * + * * @param uri the URL * @return the builder for the GET request */ @@ -71,7 +71,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a POST request. The url template * will be captured and made available for documentation. - * + * * @param urlTemplate a URL template; the resulting URL will be encoded * @param urlVariables zero or more URL variables * @return the builder for the POST request @@ -84,7 +84,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a POST request. - * + * * @param uri the URL * @return the builder for the POST request */ @@ -95,7 +95,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a PUT request. The url template * will be captured and made available for documentation. - * + * * @param urlTemplate a URL template; the resulting URL will be encoded * @param urlVariables zero or more URL variables * @return the builder for the PUT request @@ -108,7 +108,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a PUT request. - * + * * @param uri the URL * @return the builder for the PUT request */ @@ -119,7 +119,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a PATCH request. The url * template will be captured and made available for documentation. - * + * * @param urlTemplate a URL template; the resulting URL will be encoded * @param urlVariables zero or more URL variables * @return the builder for the PATCH request @@ -132,7 +132,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a PATCH request. - * + * * @param uri the URL * @return the builder for the PATCH request */ @@ -143,7 +143,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a DELETE request. The url * template will be captured and made available for documentation. - * + * * @param urlTemplate a URL template; the resulting URL will be encoded * @param urlVariables zero or more URL variables * @return the builder for the DELETE request @@ -156,7 +156,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a DELETE request. - * + * * @param uri the URL * @return the builder for the DELETE request */ @@ -167,7 +167,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for an OPTIONS request. The url * template will be captured and made available for documentation. - * + * * @param urlTemplate a URL template; the resulting URL will be encoded * @param urlVariables zero or more URL variables * @return the builder for the OPTIONS request @@ -180,7 +180,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for an OPTIONS request. - * + * * @param uri the URL * @return the builder for the OPTIONS request */ @@ -191,7 +191,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a HEAD request. The url template * will be captured and made available for documentation. - * + * * @param urlTemplate a URL template; the resulting URL will be encoded * @param urlVariables zero or more URL variables * @return the builder for the HEAD request @@ -204,7 +204,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a HEAD request. - * + * * @param uri the URL * @return the builder for the HEAD request */ @@ -215,7 +215,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a request with the given HTTP * method. The url template will be captured and made available for documentation. - * + * * @param httpMethod the HTTP method * @param urlTemplate a URL template; the resulting URL will be encoded * @param urlVariables zero or more URL variables @@ -241,7 +241,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a multipart request. The url * template will be captured and made available for documentation. - * + * * @param urlTemplate a URL template; the resulting URL will be encoded * @param urlVariables zero or more URL variables * @return the builder for the file upload request @@ -255,7 +255,7 @@ public abstract class RestDocumentationRequestBuilders { /** * Create a {@link MockHttpServletRequestBuilder} for a multipart request. - * + * * @param uri the URL * @return the builder for the file upload request */ diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationResultHandler.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationResultHandler.java index 35d65436..425cd2fc 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationResultHandler.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationResultHandler.java @@ -16,8 +16,6 @@ package org.springframework.restdocs.mockmvc; -import static org.springframework.restdocs.mockmvc.IterableEnumeration.iterable; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -35,9 +33,11 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.ResultHandler; import org.springframework.util.Assert; +import static org.springframework.restdocs.mockmvc.IterableEnumeration.iterable; + /** * A Spring MVC Test {@code ResultHandler} for documenting RESTful APIs. - * + * * @author Andy Wilkinson * @author Andreas Evers * @see MockMvcRestDocumentation#document(String, Snippet...) @@ -105,7 +105,7 @@ public class RestDocumentationResultHandler implements ResultHandler { /** * Adds the given {@code snippets} such that that are documented when this result * handler is called. - * + * * @param snippets the snippets to add * @return this {@code ResultDocumentationResultHandler} */ @@ -123,7 +123,7 @@ public class RestDocumentationResultHandler implements ResultHandler { return combinedSnippets; } - static final class IdentityOperationRequestPreprocessor implements + private static final class IdentityOperationRequestPreprocessor implements OperationRequestPreprocessor { @Override @@ -133,7 +133,7 @@ public class RestDocumentationResultHandler implements ResultHandler { } - static final class IdentityOperationResponsePreprocessor implements + private static final class IdentityOperationResponsePreprocessor implements OperationResponsePreprocessor { @Override diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/SnippetConfigurer.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/SnippetConfigurer.java index ba874f42..2723d016 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/SnippetConfigurer.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/SnippetConfigurer.java @@ -27,7 +27,7 @@ import org.springframework.restdocs.snippet.WriterResolver; /** * A configurer that can be used to configure the generated documentation snippets. - * + * * @author Andy Wilkinson */ public class SnippetConfigurer extends @@ -38,7 +38,8 @@ public class SnippetConfigurer extends HttpDocumentation.httpResponse()); /** - * The default encoding for documentation snippets + * The default encoding for documentation snippets. + * * @see #withEncoding(String) */ public static final String DEFAULT_SNIPPET_ENCODING = "UTF-8"; @@ -52,6 +53,7 @@ public class SnippetConfigurer extends /** * Configures any documentation snippets to be written using the given * {@code encoding}. The default is UTF-8. + * * @param encoding the encoding * @return {@code this} */ @@ -70,7 +72,7 @@ public class SnippetConfigurer extends /** * Configures the documentation snippets that will be produced by default. - * + * * @param defaultSnippets the default snippets * @return {@code this} */ 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 c931ea96..b7024fd4 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 @@ -19,26 +19,30 @@ package org.springframework.restdocs.mockmvc; import org.springframework.mock.web.MockHttpServletRequest; /** - * A configurer that can be used to configure the documented URIs - * + * A configurer that can be used to configure the documented URIs. + * * @author Andy Wilkinson */ -public class UriConfigurer extends AbstractNestedConfigurer { +public class UriConfigurer extends + AbstractNestedConfigurer { /** - * The default scheme for documented URIs + * The default scheme for documented URIs. + * * @see #withScheme(String) */ public static final String DEFAULT_SCHEME = "http"; /** - * The defalt host for documented URIs + * The defalt host for documented URIs. + * * @see #withHost(String) */ public static final String DEFAULT_HOST = "localhost"; /** - * The default port for documented URIs + * The default port for documented URIs. + * * @see #withPort(int) */ public static final int DEFAULT_PORT = 8080; @@ -49,14 +53,14 @@ public class UriConfigurer extends AbstractNestedConfigurer> foo() { diff --git a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationConfigurerTests.java b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationConfigurerTests.java index 708e1fe9..d8f78dd5 100644 --- a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationConfigurerTests.java +++ b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationConfigurerTests.java @@ -16,12 +16,6 @@ package org.springframework.restdocs.mockmvc; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - import java.net.URI; import org.junit.Rule; @@ -33,6 +27,12 @@ import org.springframework.test.web.servlet.request.RequestPostProcessor; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + /** * Tests for {@link RestDocumentationMockMvcConfigurer}. * diff --git a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuildersTests.java b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuildersTests.java index b77fae0f..a5bd3159 100644 --- a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuildersTests.java +++ b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/RestDocumentationRequestBuildersTests.java @@ -16,6 +16,16 @@ package org.springframework.restdocs.mockmvc; +import java.net.URI; + +import javax.servlet.ServletContext; + +import org.junit.Test; +import org.springframework.http.HttpMethod; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockServletContext; +import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; + import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; @@ -29,20 +39,9 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuild import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.request; -import java.net.URI; - -import javax.servlet.ServletContext; - -import org.junit.Test; -import org.springframework.http.HttpMethod; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockServletContext; -import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders; -import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; - /** - * Tests for {@link RestDocumentationRequestBuilders} - * + * Tests for {@link RestDocumentationRequestBuilders}. + * * @author Andy Wilkinson * */ diff --git a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/test/StubMvcResult.java b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/test/StubMvcResult.java deleted file mode 100644 index ace52418..00000000 --- a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/test/StubMvcResult.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2014-2015 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.restdocs.mockmvc.test; - -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.mock.web.MockServletContext; -import org.springframework.restdocs.RestDocumentationContext; -import org.springframework.restdocs.snippet.RestDocumentationContextPlaceholderResolver; -import org.springframework.restdocs.snippet.StandardWriterResolver; -import org.springframework.restdocs.snippet.WriterResolver; -import org.springframework.restdocs.templates.StandardTemplateResourceResolver; -import org.springframework.restdocs.templates.TemplateEngine; -import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; -import org.springframework.test.web.servlet.MvcResult; -import org.springframework.test.web.servlet.RequestBuilder; -import org.springframework.web.servlet.FlashMap; -import org.springframework.web.servlet.HandlerInterceptor; -import org.springframework.web.servlet.ModelAndView; - -/** - * A minimal stub implementation of {@link MvcResult} - * - * @author Andy Wilkinson - * - */ -public class StubMvcResult implements MvcResult { - - private final MockHttpServletRequest request; - - private final MockHttpServletResponse response; - - public static StubMvcResult result() { - return new StubMvcResult(); - } - - public static StubMvcResult result(RequestBuilder requestBuilder) { - return new StubMvcResult(requestBuilder); - } - - public static StubMvcResult result(RequestBuilder requestBuilder, - MockHttpServletResponse response) { - return new StubMvcResult(requestBuilder, response); - } - - public static StubMvcResult result(MockHttpServletRequest request) { - return new StubMvcResult(request); - } - - public static StubMvcResult result(MockHttpServletResponse response) { - return new StubMvcResult(response); - } - - public static StubMvcResult result(MockHttpServletRequest request, - MockHttpServletResponse response) { - return new StubMvcResult(request, response); - } - - private StubMvcResult() { - this(new MockHttpServletRequest(), new MockHttpServletResponse()); - } - - private StubMvcResult(MockHttpServletRequest request) { - this(request, new MockHttpServletResponse()); - } - - private StubMvcResult(MockHttpServletResponse response) { - this(new MockHttpServletRequest(), response); - } - - private StubMvcResult(RequestBuilder requestBuilder, MockHttpServletResponse response) { - this(requestBuilder.buildRequest(new MockServletContext()), response); - } - - private StubMvcResult(MockHttpServletRequest request, MockHttpServletResponse response) { - this.request = request; - if (this.request.getAttribute(TemplateEngine.class.getName()) == null) { - this.request.setAttribute(TemplateEngine.class.getName(), - new MustacheTemplateEngine(new StandardTemplateResourceResolver())); - } - RestDocumentationContext context = new RestDocumentationContext(null, null, null); - this.request.setAttribute(RestDocumentationContext.class.getName(), context); - if (this.request.getAttribute(WriterResolver.class.getName()) == null) { - this.request.setAttribute(WriterResolver.class.getName(), - new StandardWriterResolver( - new RestDocumentationContextPlaceholderResolver(context))); - } - this.response = response; - } - - private StubMvcResult(RequestBuilder requestBuilder) { - this(requestBuilder.buildRequest(new MockServletContext())); - } - - @Override - public MockHttpServletRequest getRequest() { - return this.request; - } - - @Override - public MockHttpServletResponse getResponse() { - return this.response; - } - - @Override - public Object getHandler() { - return null; - } - - @Override - public HandlerInterceptor[] getInterceptors() { - return null; - } - - @Override - public ModelAndView getModelAndView() { - return null; - } - - @Override - public Exception getResolvedException() { - return null; - } - - @Override - public FlashMap getFlashMap() { - return null; - } - - @Override - public Object getAsyncResult() { - return null; - } - - @Override - public Object getAsyncResult(long timeToWait) { - return null; - } - -} diff --git a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/test/TestRequestBuilders.java b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/test/TestRequestBuilders.java deleted file mode 100644 index 0bbc35af..00000000 --- a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/test/TestRequestBuilders.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2014-2015 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.restdocs.mockmvc.test; - -import org.springframework.restdocs.RestDocumentationContext; -import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; - -public class TestRequestBuilders { - - private TestRequestBuilders() { - - } - - public static MockHttpServletRequestBuilder get(String urlTemplate, - Object... urlVariables) { - return org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get( - urlTemplate, urlVariables).requestAttr( - RestDocumentationContext.class.getName(), - new RestDocumentationContext(null, null, null)); - } - -}