Polish
This commit is contained in:
@@ -50,12 +50,14 @@ public class RepositoryRestProperties {
|
||||
private String pageParamName;
|
||||
|
||||
/**
|
||||
* Name of the URL query string parameter that indicates how many results to return at once.
|
||||
* Name of the URL query string parameter that indicates how many results to return at
|
||||
* once.
|
||||
*/
|
||||
private String limitParamName;
|
||||
|
||||
/**
|
||||
* Name of the URL query string parameter that indicates what direction to sort results.
|
||||
* Name of the URL query string parameter that indicates what direction to sort
|
||||
* results.
|
||||
*/
|
||||
private String sortParamName;
|
||||
|
||||
@@ -75,44 +77,11 @@ public class RepositoryRestProperties {
|
||||
private Boolean returnBodyOnUpdate;
|
||||
|
||||
/**
|
||||
* Enable enum value translation via the Spring Data REST default resource bundle. Will use
|
||||
* the fully qualified enum name as key.
|
||||
* Enable enum value translation via the Spring Data REST default resource bundle.
|
||||
* Will use the fully qualified enum name as key.
|
||||
*/
|
||||
private Boolean enableEnumTranslation;
|
||||
|
||||
public void applyTo(RepositoryRestConfiguration configuration) {
|
||||
if (this.basePath != null) {
|
||||
configuration.setBasePath(this.basePath);
|
||||
}
|
||||
if (this.defaultPageSize != null) {
|
||||
configuration.setDefaultPageSize(this.defaultPageSize);
|
||||
}
|
||||
if (this.maxPageSize != null) {
|
||||
configuration.setMaxPageSize(this.maxPageSize);
|
||||
}
|
||||
if (this.pageParamName != null) {
|
||||
configuration.setPageParamName(this.pageParamName);
|
||||
}
|
||||
if (this.limitParamName != null) {
|
||||
configuration.setLimitParamName(this.limitParamName);
|
||||
}
|
||||
if (this.sortParamName != null) {
|
||||
configuration.setSortParamName(this.sortParamName);
|
||||
}
|
||||
if (this.defaultMediaType != null) {
|
||||
configuration.setDefaultMediaType(this.defaultMediaType);
|
||||
}
|
||||
if (this.returnBodyOnCreate != null) {
|
||||
configuration.setReturnBodyOnCreate(this.returnBodyOnCreate);
|
||||
}
|
||||
if (this.returnBodyOnUpdate != null) {
|
||||
configuration.setReturnBodyOnUpdate(this.returnBodyOnUpdate);
|
||||
}
|
||||
if (this.enableEnumTranslation != null) {
|
||||
configuration.setEnableEnumTranslation(this.enableEnumTranslation);
|
||||
}
|
||||
}
|
||||
|
||||
public String getBasePath() {
|
||||
return this.basePath;
|
||||
}
|
||||
@@ -193,4 +162,37 @@ public class RepositoryRestProperties {
|
||||
this.enableEnumTranslation = enableEnumTranslation;
|
||||
}
|
||||
|
||||
public void applyTo(RepositoryRestConfiguration configuration) {
|
||||
if (this.basePath != null) {
|
||||
configuration.setBasePath(this.basePath);
|
||||
}
|
||||
if (this.defaultPageSize != null) {
|
||||
configuration.setDefaultPageSize(this.defaultPageSize);
|
||||
}
|
||||
if (this.maxPageSize != null) {
|
||||
configuration.setMaxPageSize(this.maxPageSize);
|
||||
}
|
||||
if (this.pageParamName != null) {
|
||||
configuration.setPageParamName(this.pageParamName);
|
||||
}
|
||||
if (this.limitParamName != null) {
|
||||
configuration.setLimitParamName(this.limitParamName);
|
||||
}
|
||||
if (this.sortParamName != null) {
|
||||
configuration.setSortParamName(this.sortParamName);
|
||||
}
|
||||
if (this.defaultMediaType != null) {
|
||||
configuration.setDefaultMediaType(this.defaultMediaType);
|
||||
}
|
||||
if (this.returnBodyOnCreate != null) {
|
||||
configuration.setReturnBodyOnCreate(this.returnBodyOnCreate);
|
||||
}
|
||||
if (this.returnBodyOnUpdate != null) {
|
||||
configuration.setReturnBodyOnUpdate(this.returnBodyOnUpdate);
|
||||
}
|
||||
if (this.enableEnumTranslation != null) {
|
||||
configuration.setEnableEnumTranslation(this.enableEnumTranslation);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -90,8 +90,7 @@ public class RepositoryRestMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testWithCustomSettings() throws Exception {
|
||||
load(TestConfiguration.class,
|
||||
"spring.data.rest.default-page-size:42",
|
||||
load(TestConfiguration.class, "spring.data.rest.default-page-size:42",
|
||||
"spring.data.rest.max-page-size:78",
|
||||
"spring.data.rest.page-param-name:_page",
|
||||
"spring.data.rest.limit-param-name:_limit",
|
||||
@@ -106,13 +105,18 @@ public class RepositoryRestMvcAutoConfigurationTests {
|
||||
assertEquals("Custom default page size not set", 42, bean.getDefaultPageSize());
|
||||
assertEquals("Custom max page size not set", 78, bean.getMaxPageSize());
|
||||
assertEquals("Custom page param name not set", "_page", bean.getPageParamName());
|
||||
assertEquals("Custom limit param name not set", "_limit", bean.getLimitParamName());
|
||||
assertEquals("Custom limit param name not set", "_limit",
|
||||
bean.getLimitParamName());
|
||||
assertEquals("Custom sort param name not set", "_sort", bean.getSortParamName());
|
||||
assertEquals("Custom default media type not set",
|
||||
MediaType.parseMediaType("application/my-json"), bean.getDefaultMediaType());
|
||||
assertEquals("Custom return body on create flag not set", false, bean.returnBodyOnCreate(null));
|
||||
assertEquals("Custom return body on update flag not set", false, bean.returnBodyOnUpdate(null));
|
||||
assertEquals("Custom enable enum translation flag not set", true, bean.isEnableEnumTranslation());
|
||||
MediaType.parseMediaType("application/my-json"),
|
||||
bean.getDefaultMediaType());
|
||||
assertEquals("Custom return body on create flag not set", false,
|
||||
bean.returnBodyOnCreate(null));
|
||||
assertEquals("Custom return body on update flag not set", false,
|
||||
bean.returnBodyOnUpdate(null));
|
||||
assertEquals("Custom enable enum translation flag not set", true,
|
||||
bean.isEnableEnumTranslation());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user