|
44 | 44 | import org.springframework.data.geo.Distance; |
45 | 45 | import org.springframework.data.geo.Point; |
46 | 46 | import org.springframework.data.rest.webmvc.RepositoryLinksResource; |
| 47 | +import org.springframework.data.rest.webmvc.RepositoryRestHandlerAdapter; |
47 | 48 | import org.springframework.data.rest.webmvc.RestMediaTypes; |
48 | 49 | import org.springframework.data.rest.webmvc.alps.AlpsJsonHttpMessageConverter; |
49 | 50 | import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module; |
|
61 | 62 | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
62 | 63 | import org.springframework.test.util.ReflectionTestUtils; |
63 | 64 | import org.springframework.util.MultiValueMap; |
| 65 | +import org.springframework.validation.Validator; |
| 66 | +import org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean; |
| 67 | +import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; |
64 | 68 | import org.springframework.web.servlet.HandlerMapping; |
65 | 69 | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; |
66 | 70 | import org.springframework.web.util.UriComponentsBuilder; |
@@ -193,6 +197,18 @@ void hasConvertersForPointAndDistance() { |
193 | 197 | assertThat(service.canConvert(Distance.class, String.class)).isTrue(); |
194 | 198 | } |
195 | 199 |
|
| 200 | + @Test // DATAREST-593 / #967 |
| 201 | + void assertValidatorSupportWorkingCorrectly() { |
| 202 | + |
| 203 | + RepositoryRestHandlerAdapter repositoryRestHandlerAdapter = context.getBean("repositoryExporterHandlerAdapter", |
| 204 | + RepositoryRestHandlerAdapter.class); |
| 205 | + |
| 206 | + ConfigurableWebBindingInitializer configurableWebBindingInitializer = (ConfigurableWebBindingInitializer) repositoryRestHandlerAdapter |
| 207 | + .getWebBindingInitializer(); |
| 208 | + |
| 209 | + assertThat(configurableWebBindingInitializer.getValidator()).isNotNull(); |
| 210 | + } |
| 211 | + |
196 | 212 | @Test // DATAREST-1198 |
197 | 213 | void hasConvertersForNamAndLdapName() { |
198 | 214 |
|
@@ -313,6 +329,11 @@ public LinkCollector customizeLinkCollector(LinkCollector collector) { |
313 | 329 | } |
314 | 330 | }; |
315 | 331 | } |
| 332 | + |
| 333 | + @Bean |
| 334 | + Validator mvcValidator() { |
| 335 | + return new OptionalValidatorFactoryBean(); |
| 336 | + } |
316 | 337 | } |
317 | 338 |
|
318 | 339 | @Configuration |
|
0 commit comments