20
20
import static org .mockito .Mockito .*;
21
21
22
22
import groovy .lang .MetaClass ;
23
- import lombok .AccessLevel ;
24
- import lombok .EqualsAndHashCode ;
25
- import lombok .RequiredArgsConstructor ;
26
- import lombok .Value ;
27
23
28
24
import java .time .LocalDateTime ;
29
25
import java .util .ArrayList ;
38
34
39
35
import org .junit .jupiter .api .BeforeEach ;
40
36
import org .junit .jupiter .api .Test ;
41
-
42
37
import org .springframework .aop .SpringProxy ;
43
38
import org .springframework .aop .framework .Advised ;
44
39
import org .springframework .context .ApplicationContext ;
@@ -156,8 +151,7 @@ void exposesCopyOfPersistentEntitiesToAvoidConcurrentModificationException() {
156
151
var context = new SampleMappingContext ();
157
152
context .getPersistentEntity (TypeInformation .MAP );
158
153
159
- var iterator = context .getPersistentEntities ()
160
- .iterator ();
154
+ var iterator = context .getPersistentEntities ().iterator ();
161
155
162
156
while (iterator .hasNext ()) {
163
157
context .getPersistentEntity (TypeInformation .SET );
@@ -216,8 +210,7 @@ void doesNotReturnPersistentEntityForCustomSimpleTypeProperty() {
216
210
@ Test // DATACMNS-1574
217
211
void cleansUpCacheForRuntimeException () {
218
212
219
- var context = TypeRejectingMappingContext .rejecting (() -> new RuntimeException (),
220
- Unsupported .class );
213
+ var context = TypeRejectingMappingContext .rejecting (() -> new RuntimeException (), Unsupported .class );
221
214
222
215
assertThatExceptionOfType (RuntimeException .class ) //
223
216
.isThrownBy (() -> context .getPersistentEntity (Unsupported .class ));
@@ -231,8 +224,7 @@ void cleansUpCacheForRuntimeException() {
231
224
@ Test // GH-3113
232
225
void shouldIgnoreKotlinOverrideCtorPropertyInSuperClass () {
233
226
234
- var entity = context
235
- .getPersistentEntity (TypeInformation .of (ShadowingPropertyTypeWithCtor .class ));
227
+ var entity = context .getPersistentEntity (TypeInformation .of (ShadowingPropertyTypeWithCtor .class ));
236
228
entity .doWithProperties ((PropertyHandler <SamplePersistentProperty >) property -> {
237
229
assertThat (property .getField ().getDeclaringClass ()).isIn (ShadowingPropertyTypeWithCtor .class ,
238
230
ShadowedPropertyTypeWithCtor .class );
@@ -242,8 +234,7 @@ void shouldIgnoreKotlinOverrideCtorPropertyInSuperClass() {
242
234
@ Test // GH-3113
243
235
void shouldIncludeAssignableKotlinOverridePropertyInSuperClass () {
244
236
245
- var entity = context
246
- .getPersistentEntity (TypeInformation .of (ShadowingPropertyType .class ));
237
+ var entity = context .getPersistentEntity (TypeInformation .of (ShadowingPropertyType .class ));
247
238
entity .doWithProperties ((PropertyHandler <SamplePersistentProperty >) property -> {
248
239
assertThat (property .getField ().getDeclaringClass ()).isIn (ShadowedPropertyType .class , ShadowingPropertyType .class );
249
240
});
@@ -252,8 +243,7 @@ void shouldIncludeAssignableKotlinOverridePropertyInSuperClass() {
252
243
@ Test // GH-3113
253
244
void shouldIncludeAssignableShadowedPropertyInSuperClass () {
254
245
255
- var entity = context
256
- .getPersistentEntity (TypeInformation .of (ShadowingPropertyAssignable .class ));
246
+ var entity = context .getPersistentEntity (TypeInformation .of (ShadowingPropertyAssignable .class ));
257
247
258
248
assertThat (StreamUtils .createStreamFromIterator (entity .iterator ())
259
249
.filter (it -> it .getField ().getDeclaringClass ().equals (ShadowedPropertyAssignable .class )).findFirst () //
@@ -270,8 +260,7 @@ void shouldIncludeAssignableShadowedPropertyInSuperClass() {
270
260
@ Test // GH-3113
271
261
void shouldIgnoreNonAssignableOverridePropertyInSuperClass () {
272
262
273
- var entity = context
274
- .getPersistentEntity (TypeInformation .of (ShadowingPropertyNotAssignable .class ));
263
+ var entity = context .getPersistentEntity (TypeInformation .of (ShadowingPropertyNotAssignable .class ));
275
264
entity .doWithProperties ((PropertyHandler <SamplePersistentProperty >) property -> {
276
265
assertThat (property .getField ().getDeclaringClass ()).isEqualTo (ShadowingPropertyNotAssignable .class );
277
266
});
@@ -292,8 +281,7 @@ void shouldNotCreatePersistentEntityForListButItsGenericTypeArgument() {
292
281
293
282
context .getPersistentEntity (WithNestedLists .class );
294
283
295
- assertThat (context .getPersistentEntities ()).map (it -> (Class ) it .getType ())
296
- .contains (Base .class )
284
+ assertThat (context .getPersistentEntities ()).map (it -> (Class ) it .getType ()).contains (Base .class )
297
285
.doesNotContain (List .class , ArrayList .class );
298
286
}
299
287
@@ -410,14 +398,17 @@ static class Extension extends Base {
410
398
*
411
399
* @author Oliver Drotbohm
412
400
*/
413
- @ Value
414
- @ EqualsAndHashCode (callSuper = false )
415
- @ RequiredArgsConstructor (access = AccessLevel .PRIVATE )
416
401
private static class TypeRejectingMappingContext extends SampleMappingContext {
417
402
418
403
Supplier <? extends RuntimeException > exception ;
419
404
Collection <Class <?>> rejectedTypes ;
420
405
406
+ public TypeRejectingMappingContext (Supplier <? extends RuntimeException > exception ,
407
+ Collection <Class <?>> rejectedTypes ) {
408
+ this .exception = exception ;
409
+ this .rejectedTypes = rejectedTypes ;
410
+ }
411
+
421
412
/**
422
413
* Creates a new {@link TypeRejectingMappingContext} producing the given exceptions if any of the given types is
423
414
* encountered.
0 commit comments