DATAREST-573 - Polishing.

Removed RepositoryRestConfiguration.addCorsMapping(…) as we currently don't have any other shortcut methods for configuration like this.

Tweaked the setup of (now Repository)CorsConfigurationAccessor to be created earlier so that we avoid recreation for every lookup. Introduced a NoOpStringValueResolver to be used by default so that we don't need to deal with the case of the resolver being null at the end of the call chain. Replaced constructor of RepositoryCorsConfigurationAccessor with corresponding Lombok annotation.

Updated reference documentation accordingly.

Original pull request: #233.
This commit is contained in:
Oliver Gierke
2016-10-28 13:31:09 +02:00
parent a3870ca528
commit 40bb8e8e6c
8 changed files with 89 additions and 88 deletions

View File

@@ -26,6 +26,7 @@ import org.junit.Test;
import org.springframework.data.rest.core.config.EnumTranslationConfiguration;
import org.springframework.data.rest.core.config.MetadataConfiguration;
import org.springframework.data.rest.core.config.ProjectionDefinitionConfiguration;
import org.springframework.data.rest.core.config.RepositoryCorsRegistry;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.core.domain.Profile;
import org.springframework.data.rest.core.domain.ProfileRepository;
@@ -149,9 +150,10 @@ public class RepositoryRestConfigurationUnitTests {
@Test
public void configuresCorsProcessing() {
configuration.addCorsMapping("/hello").maxAge(1234);
RepositoryCorsRegistry registry = configuration.getCorsRegistry();
registry.addMapping("/hello").maxAge(1234);
Map<String, CorsConfiguration> corsConfigurations = configuration.getCorsRegistry().getCorsConfigurations();
Map<String, CorsConfiguration> corsConfigurations = registry.getCorsConfigurations();
assertThat(corsConfigurations, hasKey("/hello"));
CorsConfiguration corsConfiguration = corsConfigurations.get("/hello");