diff --git a/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.ui.prefs b/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.ui.prefs index 0fc7e2d2..6518db6a 100644 --- a/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.ui.prefs +++ b/rest-notes-spring-data-rest/.settings/org.eclipse.jdt.ui.prefs @@ -50,7 +50,7 @@ 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=true 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 diff --git a/rest-notes-spring-hateoas/.settings/org.eclipse.jdt.ui.prefs b/rest-notes-spring-hateoas/.settings/org.eclipse.jdt.ui.prefs index 0fc7e2d2..6518db6a 100644 --- a/rest-notes-spring-hateoas/.settings/org.eclipse.jdt.ui.prefs +++ b/rest-notes-spring-hateoas/.settings/org.eclipse.jdt.ui.prefs @@ -50,7 +50,7 @@ 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=true 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 diff --git a/spring-restdocs-core/.settings/org.eclipse.jdt.core.prefs b/spring-restdocs-core/.settings/org.eclipse.jdt.core.prefs index 83412a90..f9627361 100644 --- a/spring-restdocs-core/.settings/org.eclipse.jdt.core.prefs +++ b/spring-restdocs-core/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,14 @@ 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 diff --git a/spring-restdocs-core/.settings/org.eclipse.jdt.ui.prefs b/spring-restdocs-core/.settings/org.eclipse.jdt.ui.prefs index 0abc6562..ca171a90 100644 --- a/spring-restdocs-core/.settings/org.eclipse.jdt.ui.prefs +++ b/spring-restdocs-core/.settings/org.eclipse.jdt.ui.prefs @@ -50,7 +50,7 @@ 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=true 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 @@ -61,6 +61,10 @@ 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=true +org.eclipse.jdt.ui.keywordthis=true +org.eclipse.jdt.ui.overrideannotation=true sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true @@ -72,8 +76,8 @@ 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_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false +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.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false @@ -87,12 +91,12 @@ 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.on_save_use_additional_actions=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=false +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 @@ -114,8 +118,8 @@ sp_cleanup.use_blocks=false 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=false -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=false -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +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=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=false sp_cleanup.use_type_arguments=false diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/Link.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/Link.java index 135a51e4..ef153487 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/Link.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/Link.java @@ -20,7 +20,7 @@ import org.springframework.core.style.ToStringCreator; /** * Representation of a link used in a Hypermedia-based API - * + * * @author Andy Wilkinson */ public class Link { @@ -31,7 +31,7 @@ public class Link { /** * Creates a new {@code Link} with the given {@code rel} and {@code href} - * + * * @param rel The link's rel * @param href The link's href */ @@ -45,7 +45,7 @@ public class Link { * @return the link's {@code rel} */ public String getRel() { - return rel; + return this.rel; } /** @@ -53,15 +53,15 @@ public class Link { * @return the link's {@code href} */ public String getHref() { - return href; + return this.href; } @Override public int hashCode() { int prime = 31; int result = 1; - result = prime * result + href.hashCode(); - result = prime * result + rel.hashCode(); + result = prime * result + this.href.hashCode(); + result = prime * result + this.rel.hashCode(); return result; } @@ -77,15 +77,16 @@ public class Link { return false; } Link other = (Link) obj; - if (!href.equals(other.href)) { + if (!this.href.equals(other.href)) { return false; } - if (!rel.equals(other.rel)) { + if (!this.rel.equals(other.rel)) { return false; } return true; } + @Override public String toString() { return new ToStringCreator(this).append("rel", this.rel) .append("href", this.href).toString(); diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkDescriptor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkDescriptor.java index b6c117f0..e28a8af4 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkDescriptor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkDescriptor.java @@ -32,10 +32,10 @@ public class LinkDescriptor { } String getRel() { - return rel; + return this.rel; } String getDescription() { - return description; + return this.description; } } diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkExtractor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkExtractor.java index bb65fd8e..f63d2c4f 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkExtractor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkExtractor.java @@ -25,7 +25,7 @@ import org.springframework.mock.web.MockHttpServletResponse; /** * A {@code LinkExtractor} is used to extract {@link Link links} from a JSON response. The * expected format of the links in the response is determined by the implementation. - * + * * @author Andy Wilkinson * */ @@ -34,7 +34,7 @@ public interface LinkExtractor { /** * Extract the links from the given response, returning a {@code Map} of links where * the keys are the link rels. - * + * * @param response The response from which the links are to be extracted * @return The extracted links, keyed by rel * @throws IOException if link extraction fails diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkExtractors.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkExtractors.java index e6c28d53..f736e07d 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkExtractors.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/LinkExtractors.java @@ -31,7 +31,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; /** * Static factory methods provided a selection of {@link LinkExtractor link extractors} * for use when documentating a hypermedia-based API. - * + * * @author Andy Wilkinson * */ @@ -41,7 +41,7 @@ public class LinkExtractors { * Returns a {@code LinkExtractor} capable of extracting links in Hypermedia * Application Language (HAL) format where the links are found in a map named * {@code _links}. - * + * * @return The extract for HAL-style links */ public static LinkExtractor halLinks() { @@ -51,7 +51,7 @@ public class LinkExtractors { /** * Returns a {@code LinkExtractor} capable of extracting links in Atom format where * the links are found in an array named {@code links}. - * + * * @return The extractor for Atom-style links */ public static LinkExtractor atomLinks() { @@ -62,6 +62,7 @@ public class LinkExtractors { private final ObjectMapper objectMapper = new ObjectMapper(); + @Override @SuppressWarnings("unchecked") public Map> extractLinks(MockHttpServletResponse response) throws IOException { @@ -83,7 +84,7 @@ public class LinkExtractors { if (possibleLinks instanceof Map) { Map links = (Map) possibleLinks; for (Entry entry : links.entrySet()) { - String rel = (String) entry.getKey(); + String rel = entry.getKey(); extractedLinks.put(rel, convertToLinks(entry.getValue(), rel)); } } diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationConfiguration.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationConfiguration.java index 1fdd1d44..70a7c70e 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationConfiguration.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationConfiguration.java @@ -53,10 +53,10 @@ public class RestDocumentationConfiguration extends MockMvcConfigurerAdapter { @Override public MockHttpServletRequest postProcessRequest( MockHttpServletRequest request) { - request.setScheme(scheme); - request.setRemotePort(port); - request.setServerPort(port); - request.setRemoteHost(host); + request.setScheme(RestDocumentationConfiguration.this.scheme); + request.setRemotePort(RestDocumentationConfiguration.this.port); + request.setServerPort(RestDocumentationConfiguration.this.port); + request.setRemoteHost(RestDocumentationConfiguration.this.host); return request; } }; diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationResultHandler.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationResultHandler.java index e1b96b84..71eca294 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationResultHandler.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationResultHandler.java @@ -38,18 +38,20 @@ public class RestDocumentationResultHandler implements ResultHandler { @Override public void handle(MvcResult result) throws Exception { - documentCurlRequest(outputDir).includeResponseHeaders().handle(result); - documentCurlResponse(outputDir).includeResponseHeaders().handle(result); - documentCurlRequestAndResponse(outputDir).includeResponseHeaders().handle(result); - if (linkDocumentingResultHandler != null) { - linkDocumentingResultHandler.handle(result); + documentCurlRequest(this.outputDir).includeResponseHeaders().handle(result); + documentCurlResponse(this.outputDir).includeResponseHeaders().handle(result); + documentCurlRequestAndResponse(this.outputDir).includeResponseHeaders().handle( + result); + if (this.linkDocumentingResultHandler != null) { + this.linkDocumentingResultHandler.handle(result); } } public RestDocumentationResultHandler withLinks(LinkExtractor linkExtractor, LinkDescriptor... descriptors) { - linkDocumentingResultHandler = new LinkDocumentingResultHandler(outputDir, - linkExtractor, Arrays.asList(descriptors)); + this.linkDocumentingResultHandler = new LinkDocumentingResultHandler( + this.outputDir, linkExtractor, Arrays.asList(descriptors)); return this; } + } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/core/LinkExtractorsTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/core/LinkExtractorsTests.java index 2e94fead..1794b7d1 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/core/LinkExtractorsTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/core/LinkExtractorsTests.java @@ -38,7 +38,7 @@ import org.springframework.util.FileCopyUtils; /** * Tests for {@link LinkExtractors}. - * + * * @author Andy Wilkinson */ @RunWith(Parameterized.class) @@ -118,7 +118,7 @@ public class LinkExtractorsTests { } private File getPayloadFile(String name) { - return new File("src/test/resources/link-payloads/" + linkType + "/" + name + return new File("src/test/resources/link-payloads/" + this.linkType + "/" + name + ".json"); } }