use of org.springframework.data.rest.core.config.RepositoryRestConfiguration in project spring-cloud-microservice-example by kbastani.
the class Application method main.
public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);
RepositoryRestConfiguration restConfiguration = ctx.getBean("config", RepositoryRestConfiguration.class);
restConfiguration.exposeIdsFor(User.class);
}
use of org.springframework.data.rest.core.config.RepositoryRestConfiguration in project spring-boot by spring-projects.
the class RepositoryRestMvcAutoConfigurationTests method testWithCustomConfigurer.
@Test
public void testWithCustomConfigurer() {
load(TestConfigurationWithConfigurer.class, "spring.data.rest.detection-strategy=visibility", "spring.data.rest.default-media-type:application/my-json");
assertThat(this.context.getBean(RepositoryRestMvcConfiguration.class)).isNotNull();
RepositoryRestConfiguration bean = this.context.getBean(RepositoryRestConfiguration.class);
assertThat(bean.getRepositoryDetectionStrategy()).isEqualTo(RepositoryDetectionStrategies.ALL);
assertThat(bean.getDefaultMediaType()).isEqualTo(MediaType.parseMediaType("application/my-custom-json"));
assertThat(bean.getMaxPageSize()).isEqualTo(78);
}
use of org.springframework.data.rest.core.config.RepositoryRestConfiguration in project spring-boot by spring-projects.
the class RepositoryRestMvcAutoConfigurationTests method testWithCustomSettings.
@Test
public void testWithCustomSettings() throws Exception {
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", "spring.data.rest.sort-param-name:_sort", "spring.data.rest.detection-strategy=visibility", "spring.data.rest.default-media-type:application/my-json", "spring.data.rest.return-body-on-create:false", "spring.data.rest.return-body-on-update:false", "spring.data.rest.enable-enum-translation:true");
assertThat(this.context.getBean(RepositoryRestMvcConfiguration.class)).isNotNull();
RepositoryRestConfiguration bean = this.context.getBean(RepositoryRestConfiguration.class);
assertThat(bean.getDefaultPageSize()).isEqualTo(42);
assertThat(bean.getMaxPageSize()).isEqualTo(78);
assertThat(bean.getPageParamName()).isEqualTo("_page");
assertThat(bean.getLimitParamName()).isEqualTo("_limit");
assertThat(bean.getSortParamName()).isEqualTo("_sort");
assertThat(bean.getRepositoryDetectionStrategy()).isEqualTo(RepositoryDetectionStrategies.VISIBILITY);
assertThat(bean.getDefaultMediaType()).isEqualTo(MediaType.parseMediaType("application/my-json"));
assertThat(bean.returnBodyOnCreate(null)).isFalse();
assertThat(bean.returnBodyOnUpdate(null)).isFalse();
assertThat(bean.isEnableEnumTranslation()).isTrue();
}
use of org.springframework.data.rest.core.config.RepositoryRestConfiguration in project spring-boot by spring-projects.
the class RepositoryRestMvcAutoConfigurationTests method backOffWithCustomConfiguration.
@Test
public void backOffWithCustomConfiguration() {
load(TestConfigurationWithRestMvcConfig.class, "spring.data.rest.base-path:foo");
assertThat(this.context.getBean(RepositoryRestMvcConfiguration.class)).isNotNull();
RepositoryRestConfiguration bean = this.context.getBean(RepositoryRestConfiguration.class);
assertThat(bean.getBaseUri()).isEqualTo(URI.create(""));
}
use of org.springframework.data.rest.core.config.RepositoryRestConfiguration in project spring-boot by spring-projects.
the class RepositoryRestMvcAutoConfigurationTests method testWithCustomBasePath.
@Test
public void testWithCustomBasePath() throws Exception {
load(TestConfiguration.class, "spring.data.rest.base-path:foo");
assertThat(this.context.getBean(RepositoryRestMvcConfiguration.class)).isNotNull();
RepositoryRestConfiguration bean = this.context.getBean(RepositoryRestConfiguration.class);
URI expectedUri = URI.create("/foo");
assertThat(bean.getBaseUri()).as("Custom basePath not set").isEqualTo(expectedUri);
BaseUri baseUri = this.context.getBean(BaseUri.class);
assertThat(expectedUri).as("Custom basePath has not been applied to BaseUri bean").isEqualTo(baseUri.getUri());
}
Aggregations