From 33c156dae0c889096a420327fb6a6a24994ea2fa Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Thu, 18 Oct 2018 15:58:31 +0200 Subject: [PATCH] DATAREST-1294 - Polishing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aligned with general request attribute naming conventions and prefixed the one we now use with the class' name. Altered the local attribute name to EFFECTIVE_REPOSITORY_RESOURCE_LOOKUP_PATH. Renamed the constant holding the name from …_KEY to …_ATTRIBUTE. --- .../rest/webmvc/RepositoryRestHandlerMapping.java | 11 +++++++---- .../webmvc/RepositoryRestHandlerMappingUnitTests.java | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerMapping.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerMapping.java index 58c6873a7..13b8d3030 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerMapping.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerMapping.java @@ -65,7 +65,8 @@ import org.springframework.web.util.pattern.PathPatternParser; public class RepositoryRestHandlerMapping extends BasePathAwareHandlerMapping { private static final PathPatternParser PARSER = new PathPatternParser(); - static final String EFFECTIVE_LOOKUP_PATH_KEY = "EFFECTIVE_REPOSITORY_LOOKUP_PATH"; + static final String EFFECTIVE_LOOKUP_PATH_ATTRIBUTE = RepositoryRestHandlerMapping.class.getName() + + ".EFFECTIVE_REPOSITORY_RESOURCE_LOOKUP_PATH"; private final ResourceMappings mappings; private final RepositoryRestConfiguration configuration; @@ -248,8 +249,9 @@ public class RepositoryRestHandlerMapping extends BasePathAwareHandlerMapping { } /** - * Exposes the effective repository resource lookup path as request attribute via {@link #EFFECTIVE_LOOKUP_PATH_KEY}, - * i.e. {@code /people/search/\{search\}} instead of {@code /\{repository\}/search/\{search\}}. + * Exposes the effective repository resource lookup path as request attribute via + * {@link #EFFECTIVE_LOOKUP_PATH_ATTRIBUTE}, i.e. {@code /people/search/\{search\}} instead of + * {@code /\{repository\}/search/\{search\}}. * * @param method must not be {@literal null}. * @param request must not be {@literal null}. @@ -264,7 +266,8 @@ public class RepositoryRestHandlerMapping extends BasePathAwareHandlerMapping { .getPatterns() // .iterator().next(); - request.setAttribute(EFFECTIVE_LOOKUP_PATH_KEY, PARSER.parse(pattern.replace("/{repository}", repositoryBasePath))); + request.setAttribute(EFFECTIVE_LOOKUP_PATH_ATTRIBUTE, + PARSER.parse(pattern.replace("/{repository}", repositoryBasePath))); } /** diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerMappingUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerMappingUnitTests.java index 2dfbfc616..7efe64d5e 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerMappingUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerMappingUnitTests.java @@ -281,7 +281,7 @@ public class RepositoryRestHandlerMappingUnitTests { handlerMapping.afterPropertiesSet(); handlerMapping.lookupHandlerMethod("/people/search/findByLastnameLike", mockRequest); - assertThat(mockRequest.getAttribute(RepositoryRestHandlerMapping.EFFECTIVE_LOOKUP_PATH_KEY)) // + assertThat(mockRequest.getAttribute(RepositoryRestHandlerMapping.EFFECTIVE_LOOKUP_PATH_ATTRIBUTE)) // .isInstanceOfSatisfying(PathPattern.class, it -> { assertThat(it.getPatternString()).isEqualTo("/people/search/{search}"); });