22
22
import java .util .Arrays ;
23
23
import java .util .List ;
24
24
25
- import com .fasterxml .jackson .databind .Module ;
26
25
import org .junit .jupiter .api .Test ;
26
+
27
27
import org .springframework .beans .factory .annotation .Autowired ;
28
28
import org .springframework .context .ApplicationContext ;
29
29
import org .springframework .context .annotation .Bean ;
30
30
import org .springframework .context .annotation .Configuration ;
31
- import org .springframework .context .annotation .Primary ;
32
31
import org .springframework .core .convert .ConversionService ;
33
32
import org .springframework .data .classloadersupport .HidingClassLoader ;
34
33
import org .springframework .data .geo .Distance ;
54
53
import org .springframework .web .servlet .mvc .method .annotation .RequestMappingHandlerAdapter ;
55
54
import org .springframework .web .util .UriComponentsBuilder ;
56
55
56
+ import com .fasterxml .jackson .databind .Module ;
57
57
import com .fasterxml .jackson .databind .ObjectMapper ;
58
58
59
59
/**
@@ -125,8 +125,7 @@ SimpleEntityPathResolver entityPathResolver() {
125
125
@ Configuration
126
126
static class PageSampleConfig extends WebMvcConfigurationSupport {
127
127
128
- @ Autowired
129
- private List <Module > modules ;
128
+ @ Autowired private List <Module > modules ;
130
129
131
130
@ Bean
132
131
PageSampleController controller () {
@@ -140,27 +139,14 @@ protected void configureMessageConverters(List<HttpMessageConverter<?>> converte
140
139
}
141
140
}
142
141
143
-
144
142
@ EnableSpringDataWebSupport
145
- static class PageSampleConfigWithDirect extends PageSampleConfig {
146
- }
143
+ static class PageSampleConfigWithDirect extends PageSampleConfig {}
147
144
148
145
@ EnableSpringDataWebSupport (pageSerializationMode = EnableSpringDataWebSupport .PageSerializationMode .VIA_DTO )
149
- static class PageSampleConfigWithViaDto extends PageSampleConfig {
150
- }
151
-
152
- @ EnableSpringDataWebSupport
153
- static class PageSampleConfigWithSpringDataWebSettings extends PageSampleConfig {
154
-
155
- @ Primary
156
- @ Bean
157
- SpringDataWebSettings SpringDataWebSettings () {
158
- return new SpringDataWebSettings (EnableSpringDataWebSupport .PageSerializationMode .VIA_DTO );
159
- }
160
- }
146
+ static class PageSampleConfigWithViaDto extends PageSampleConfig {}
161
147
162
148
@ Test // DATACMNS-330
163
- void registersBasicBeanDefinitions () throws Exception {
149
+ void registersBasicBeanDefinitions () {
164
150
165
151
ApplicationContext context = WebTestUtils .createApplicationContext (SampleConfig .class );
166
152
var names = Arrays .asList (context .getBeanDefinitionNames ());
@@ -172,7 +158,7 @@ void registersBasicBeanDefinitions() throws Exception {
172
158
}
173
159
174
160
@ Test // DATACMNS-330
175
- void registersHateoasSpecificBeanDefinitions () throws Exception {
161
+ void registersHateoasSpecificBeanDefinitions () {
176
162
177
163
ApplicationContext context = WebTestUtils .createApplicationContext (SampleConfig .class );
178
164
var names = Arrays .asList (context .getBeanDefinitionNames ());
@@ -182,7 +168,7 @@ void registersHateoasSpecificBeanDefinitions() throws Exception {
182
168
}
183
169
184
170
@ Test // DATACMNS-330
185
- void doesNotRegisterHateoasSpecificComponentsIfHateoasNotPresent () throws Exception {
171
+ void doesNotRegisterHateoasSpecificComponentsIfHateoasNotPresent () {
186
172
187
173
var classLoader = HidingClassLoader .hide (Link .class );
188
174
@@ -195,7 +181,7 @@ void doesNotRegisterHateoasSpecificComponentsIfHateoasNotPresent() throws Except
195
181
}
196
182
197
183
@ Test // DATACMNS-475
198
- void registersJacksonSpecificBeanDefinitions () throws Exception {
184
+ void registersJacksonSpecificBeanDefinitions () {
199
185
200
186
ApplicationContext context = WebTestUtils .createApplicationContext (SampleConfig .class );
201
187
var names = Arrays .asList (context .getBeanDefinitionNames ());
@@ -204,7 +190,7 @@ void registersJacksonSpecificBeanDefinitions() throws Exception {
204
190
}
205
191
206
192
@ Test // DATACMNS-475
207
- void doesNotRegisterJacksonSpecificComponentsIfJacksonNotPresent () throws Exception {
193
+ void doesNotRegisterJacksonSpecificComponentsIfJacksonNotPresent () {
208
194
209
195
ApplicationContext context = WebTestUtils .createApplicationContext (HidingClassLoader .hide (ObjectMapper .class ),
210
196
SampleConfig .class );
@@ -312,10 +298,8 @@ void registersSpringDataWebSettingsBean() {
312
298
313
299
ApplicationContext context = WebTestUtils .createApplicationContext (SampleConfig .class );
314
300
315
- assertThatNoException ().isThrownBy (() -> {
316
- assertThat (context .getBean (SpringDataWebSettings .class ));
317
- assertThat (context .getBean (PageModule .class ));
318
- });
301
+ assertThatNoException ().isThrownBy (() -> context .getBean (SpringDataWebSettings .class ));
302
+ assertThatNoException ().isThrownBy (() -> context .getBean (PageModule .class ));
319
303
}
320
304
321
305
@ Test // GH-3024
@@ -324,9 +308,9 @@ void usesDirectPageSerializationMode() throws Exception {
324
308
var applicationContext = WebTestUtils .createApplicationContext (PageSampleConfigWithDirect .class );
325
309
var mvc = MockMvcBuilders .webAppContextSetup (applicationContext ).build ();
326
310
327
- mvc .perform (post ("/page" )). //
328
- andExpect (status ().isOk ()). //
329
- andExpect (jsonPath ("$.pageable" ).exists ());
311
+ mvc .perform (post ("/page" ))//
312
+ . andExpect (status ().isOk ()) //
313
+ . andExpect (jsonPath ("$.pageable" ).exists ());
330
314
}
331
315
332
316
@ Test // GH-3024
@@ -335,20 +319,9 @@ void usesViaDtoPageSerializationMode() throws Exception {
335
319
var applicationContext = WebTestUtils .createApplicationContext (PageSampleConfigWithViaDto .class );
336
320
var mvc = MockMvcBuilders .webAppContextSetup (applicationContext ).build ();
337
321
338
- mvc .perform (post ("/page" )).//
339
- andExpect (status ().isOk ()).//
340
- andExpect (jsonPath ("$.page" ).exists ());
341
- }
342
-
343
- @ Test // GH-3024
344
- void overridesPageSerializationModeByCustomizingSpringDataWebSettings () throws Exception {
345
-
346
- var applicationContext = WebTestUtils .createApplicationContext (PageSampleConfigWithSpringDataWebSettings .class );
347
- var mvc = MockMvcBuilders .webAppContextSetup (applicationContext ).build ();
348
-
349
- mvc .perform (post ("/page" )).//
350
- andExpect (status ().isOk ()).//
351
- andExpect (jsonPath ("$.page" ).exists ());
322
+ mvc .perform (post ("/page" )) //
323
+ .andExpect (status ().isOk ()) //
324
+ .andExpect (jsonPath ("$.page" ).exists ());
352
325
}
353
326
354
327
private static void assertResolversRegistered (ApplicationContext context , Class <?>... resolverTypes ) {
0 commit comments