DATACMNS-822 - Polishing.
Replaced optional dependencies with Optional and explicit null checks with calls to ifPresent. Used Lambda style instead of anonymous classes where applicable. Converted Hamcrest matchers to AssertJ. Minor improvements to formatting. Original pull request: #208.
This commit is contained in:
committed by
Oliver Gierke
parent
c1036b2204
commit
364ed9ab2e
@@ -72,16 +72,8 @@ public class EnableSpringDataWebSupportIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public PageableHandlerMethodArgumentResolverCustomizer testPageableResolverCustomizer() {
|
||||
return new PageableHandlerMethodArgumentResolverCustomizer() {
|
||||
|
||||
@Override
|
||||
public void customize(PageableHandlerMethodArgumentResolver pageableResolver) {
|
||||
pageableResolver.setMaxPageSize(100);
|
||||
}
|
||||
|
||||
};
|
||||
return pageableResolver -> pageableResolver.setMaxPageSize(100);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -91,16 +83,8 @@ public class EnableSpringDataWebSupportIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public SortHandlerMethodArgumentResolverCustomizer testSortResolverCustomizer() {
|
||||
return new SortHandlerMethodArgumentResolverCustomizer() {
|
||||
|
||||
@Override
|
||||
public void customize(SortHandlerMethodArgumentResolver sortResolver) {
|
||||
sortResolver.setSortParameter("foo");
|
||||
}
|
||||
|
||||
};
|
||||
return sortResolver -> sortResolver.setSortParameter("foo");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test // DATACMNS-330
|
||||
@@ -126,7 +110,6 @@ public class EnableSpringDataWebSupportIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-330
|
||||
// @ClassLoaderConfiguration(hidePackage = Link.class)
|
||||
public void doesNotRegisterHateoasSpecificComponentsIfHateoasNotPresent() throws Exception {
|
||||
|
||||
HidingClassLoader classLoader = HidingClassLoader.hide(Link.class);
|
||||
@@ -201,22 +184,24 @@ public class EnableSpringDataWebSupportIntegrationTests {
|
||||
|
||||
@Test // DATACMNS-822
|
||||
public void picksUpPageableResolverCustomizer() {
|
||||
|
||||
ApplicationContext context = WebTestUtils.createApplicationContext(PageableResolverCustomizerConfig.class);
|
||||
List<String> names = Arrays.asList(context.getBeanDefinitionNames());
|
||||
PageableHandlerMethodArgumentResolver resolver = context.getBean(PageableHandlerMethodArgumentResolver.class);
|
||||
|
||||
assertThat(names, hasItem("testPageableResolverCustomizer"));
|
||||
assertThat((Integer) ReflectionTestUtils.getField(resolver, "maxPageSize"), equalTo(100));
|
||||
assertThat(names).contains("testPageableResolverCustomizer");
|
||||
assertThat((Integer) ReflectionTestUtils.getField(resolver, "maxPageSize")).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-822
|
||||
public void picksUpSortResolverCustomizer() {
|
||||
|
||||
ApplicationContext context = WebTestUtils.createApplicationContext(SortResolverCustomizerConfig.class);
|
||||
List<String> names = Arrays.asList(context.getBeanDefinitionNames());
|
||||
SortHandlerMethodArgumentResolver resolver = context.getBean(SortHandlerMethodArgumentResolver.class);
|
||||
|
||||
assertThat(names, hasItem("testSortResolverCustomizer"));
|
||||
assertThat((String) ReflectionTestUtils.getField(resolver, "sortParameter"), equalTo("foo"));
|
||||
assertThat(names).contains("testSortResolverCustomizer");
|
||||
assertThat((String) ReflectionTestUtils.getField(resolver, "sortParameter")).isEqualTo("foo");
|
||||
}
|
||||
|
||||
private static void assertResolversRegistered(ApplicationContext context, Class<?>... resolverTypes) {
|
||||
|
||||
Reference in New Issue
Block a user