@@ -2411,7 +2411,6 @@ void shouldUseMostConcreteCustomConversionTargetOnRead() {
2411
2411
verify (subTypeOfGenericTypeConverter ).convert (eq (source ));
2412
2412
}
2413
2413
2414
-
2415
2414
@ Test // GH-3660
2416
2415
void usesCustomConverterForMapTypesOnWrite () {
2417
2416
@@ -2455,9 +2454,8 @@ void usesCustomConverterForTypesImplementingMapOnRead() {
2455
2454
}));
2456
2455
converter .afterPropertiesSet ();
2457
2456
2458
- org .bson .Document source = new org .bson .Document ("1st" , "one" )
2459
- .append ("2nd" , 2 )
2460
- .append ("_class" , TypeImplementingMap .class .getName ());
2457
+ org .bson .Document source = new org .bson .Document ("1st" , "one" ).append ("2nd" , 2 ).append ("_class" ,
2458
+ TypeImplementingMap .class .getName ());
2461
2459
2462
2460
TypeImplementingMap target = converter .read (TypeImplementingMap .class , source );
2463
2461
@@ -2492,9 +2490,8 @@ void usesCustomConverterForPropertiesUsingTypesImplementingMapOnRead() {
2492
2490
converter .afterPropertiesSet ();
2493
2491
2494
2492
org .bson .Document source = new org .bson .Document ("typeImplementingMap" ,
2495
- new org .bson .Document ("1st" , "one" )
2496
- .append ("2nd" , 2 ))
2497
- .append ("_class" , TypeWrappingTypeImplementingMap .class .getName ());
2493
+ new org .bson .Document ("1st" , "one" ).append ("2nd" , 2 )).append ("_class" ,
2494
+ TypeWrappingTypeImplementingMap .class .getName ());
2498
2495
2499
2496
TypeWrappingTypeImplementingMap target = converter .read (TypeWrappingTypeImplementingMap .class , source );
2500
2497
@@ -2516,13 +2513,12 @@ void shouldWriteNullPropertyCorrectly() {
2516
2513
@ Test // GH-3686
2517
2514
void readsCollectionContainingNullValue () {
2518
2515
2519
- org .bson .Document source = new org .bson .Document ("items" , Arrays .asList (new org .bson .Document ("itemKey" , "i1" ), null , new org .bson .Document ("itemKey" , "i3" )));
2516
+ org .bson .Document source = new org .bson .Document ("items" ,
2517
+ Arrays .asList (new org .bson .Document ("itemKey" , "i1" ), null , new org .bson .Document ("itemKey" , "i3" )));
2520
2518
2521
2519
Order target = converter .read (Order .class , source );
2522
2520
2523
- assertThat (target .items )
2524
- .map (it -> it != null ? it .itemKey : null )
2525
- .containsExactly ("i1" , null , "i3" );
2521
+ assertThat (target .items ).map (it -> it != null ? it .itemKey : null ).containsExactly ("i1" , null , "i3" );
2526
2522
}
2527
2523
2528
2524
@ Test // GH-3686
@@ -2538,14 +2534,13 @@ void readsArrayContainingNullValue() {
2538
2534
@ Test // GH-3686
2539
2535
void readsMapContainingNullValue () {
2540
2536
2541
- org .bson .Document source = new org .bson .Document ("mapOfObjects" , new org .bson .Document ("item1" , "i1" ).append ("item2" , null ).append ("item3" , "i3" ));
2537
+ org .bson .Document source = new org .bson .Document ("mapOfObjects" ,
2538
+ new org .bson .Document ("item1" , "i1" ).append ("item2" , null ).append ("item3" , "i3" ));
2542
2539
2543
2540
ClassWithMapProperty target = converter .read (ClassWithMapProperty .class , source );
2544
2541
2545
- assertThat (target .mapOfObjects )
2546
- .containsEntry ("item1" , "i1" )
2547
- .containsEntry ("item2" , null )
2548
- .containsEntry ("item3" , "i3" );
2542
+ assertThat (target .mapOfObjects ).containsEntry ("item1" , "i1" ).containsEntry ("item2" , null ).containsEntry ("item3" ,
2543
+ "i3" );
2549
2544
}
2550
2545
2551
2546
@ Test // GH-3670
@@ -2557,7 +2552,7 @@ void appliesCustomConverterEvenToSimpleTypes() {
2557
2552
}));
2558
2553
converter .afterPropertiesSet ();
2559
2554
2560
- org .bson .Document source = new org .bson .Document ("content" , new Binary (new byte [] {0x00 , 0x42 }));
2555
+ org .bson .Document source = new org .bson .Document ("content" , new Binary (new byte [] { 0x00 , 0x42 }));
2561
2556
2562
2557
GenericType <Object > target = converter .read (GenericType .class , source );
2563
2558
assertThat (target .content ).isInstanceOf (byte [].class );
@@ -2566,17 +2561,20 @@ void appliesCustomConverterEvenToSimpleTypes() {
2566
2561
@ Test // GH-3702
2567
2562
void readsRawDocument () {
2568
2563
2569
- org .bson .Document source = new org .bson .Document ("_id" , "id-1" ).append ("raw" , new org .bson .Document ("simple" , 1 ).append ("document" , new org .bson .Document ("inner-doc" , 1 )));
2564
+ org .bson .Document source = new org .bson .Document ("_id" , "id-1" ).append ("raw" ,
2565
+ new org .bson .Document ("simple" , 1 ).append ("document" , new org .bson .Document ("inner-doc" , 1 )));
2570
2566
2571
2567
WithRawDocumentProperties target = converter .read (WithRawDocumentProperties .class , source );
2572
2568
2573
- assertThat (target .raw ).isInstanceOf (org .bson .Document .class ).isEqualTo ( new org .bson .Document ("simple" , 1 ).append ("document" , new org .bson .Document ("inner-doc" , 1 )));
2569
+ assertThat (target .raw ).isInstanceOf (org .bson .Document .class )
2570
+ .isEqualTo (new org .bson .Document ("simple" , 1 ).append ("document" , new org .bson .Document ("inner-doc" , 1 )));
2574
2571
}
2575
2572
2576
2573
@ Test // GH-3702
2577
2574
void readsListOfRawDocument () {
2578
2575
2579
- org .bson .Document source = new org .bson .Document ("_id" , "id-1" ).append ("listOfRaw" , Arrays .asList (new org .bson .Document ("simple" , 1 ).append ("document" , new org .bson .Document ("inner-doc" , 1 ))));
2576
+ org .bson .Document source = new org .bson .Document ("_id" , "id-1" ).append ("listOfRaw" ,
2577
+ Arrays .asList (new org .bson .Document ("simple" , 1 ).append ("document" , new org .bson .Document ("inner-doc" , 1 ))));
2580
2578
2581
2579
WithRawDocumentProperties target = converter .read (WithRawDocumentProperties .class , source );
2582
2580
@@ -2587,11 +2585,12 @@ void readsListOfRawDocument() {
2587
2585
@ Test // GH-3692
2588
2586
void readsMapThatDoesNotComeAsDocument () {
2589
2587
2590
- org .bson .Document source = new org .bson .Document ("_id" , "id-1" ).append ("mapOfObjects" , Collections .singletonMap ("simple" , 1 ));
2588
+ org .bson .Document source = new org .bson .Document ("_id" , "id-1" ).append ("mapOfObjects" ,
2589
+ Collections .singletonMap ("simple" , 1 ));
2591
2590
2592
2591
ClassWithMapProperty target = converter .read (ClassWithMapProperty .class , source );
2593
2592
2594
- assertThat (target .mapOfObjects ).containsEntry ("simple" ,1 );
2593
+ assertThat (target .mapOfObjects ).containsEntry ("simple" , 1 );
2595
2594
}
2596
2595
2597
2596
@ Test // GH-3851
@@ -2611,23 +2610,22 @@ void readsMapThatDoesNotComeAsDocument() {
2611
2610
2612
2611
converter .writePropertyInternal (sourceValue , accessor , persistentProperty );
2613
2612
2614
- assertThat (accessor .getDocument ()).isEqualTo (new org .bson .Document ("pName" , new org .bson .Document ("_id" , id .toString ())));
2613
+ assertThat (accessor .getDocument ())
2614
+ .isEqualTo (new org .bson .Document ("pName" , new org .bson .Document ("_id" , id .toString ())));
2615
2615
}
2616
2616
2617
2617
@ Test // GH-2860
2618
2618
void projectShouldReadSimpleInterfaceProjection () {
2619
2619
2620
2620
org .bson .Document source = new org .bson .Document ("birthDate" ,
2621
- Date .from (LocalDate .of (1999 , 12 , 1 ).atStartOfDay ().toInstant (ZoneOffset .UTC ))).append ("foo" ,
2622
- "Walter" );
2621
+ Date .from (LocalDate .of (1999 , 12 , 1 ).atStartOfDay ().toInstant (ZoneOffset .UTC ))).append ("foo" , "Walter" );
2623
2622
2624
2623
EntityProjectionIntrospector discoverer = EntityProjectionIntrospector .create (converter .getProjectionFactory (),
2625
2624
EntityProjectionIntrospector .ProjectionPredicate .typeHierarchy ()
2626
2625
.and ((target , underlyingType ) -> !converter .conversions .isSimpleType (target )),
2627
2626
mappingContext );
2628
2627
2629
- EntityProjection <PersonProjection , Person > projection = discoverer
2630
- .introspect (PersonProjection .class , Person .class );
2628
+ EntityProjection <PersonProjection , Person > projection = discoverer .introspect (PersonProjection .class , Person .class );
2631
2629
PersonProjection person = converter .project (projection , source );
2632
2630
2633
2631
assertThat (person .getBirthDate ()).isEqualTo (LocalDate .of (1999 , 12 , 1 ));
@@ -2638,16 +2636,14 @@ void projectShouldReadSimpleInterfaceProjection() {
2638
2636
void projectShouldReadSimpleDtoProjection () {
2639
2637
2640
2638
org .bson .Document source = new org .bson .Document ("birthDate" ,
2641
- Date .from (LocalDate .of (1999 , 12 , 1 ).atStartOfDay ().toInstant (ZoneOffset .UTC ))).append ("foo" ,
2642
- "Walter" );
2639
+ Date .from (LocalDate .of (1999 , 12 , 1 ).atStartOfDay ().toInstant (ZoneOffset .UTC ))).append ("foo" , "Walter" );
2643
2640
2644
2641
EntityProjectionIntrospector introspector = EntityProjectionIntrospector .create (converter .getProjectionFactory (),
2645
2642
EntityProjectionIntrospector .ProjectionPredicate .typeHierarchy ()
2646
2643
.and ((target , underlyingType ) -> !converter .conversions .isSimpleType (target )),
2647
2644
mappingContext );
2648
2645
2649
- EntityProjection <PersonDto , Person > projection = introspector
2650
- .introspect (PersonDto .class , Person .class );
2646
+ EntityProjection <PersonDto , Person > projection = introspector .introspect (PersonDto .class , Person .class );
2651
2647
PersonDto person = converter .project (projection , source );
2652
2648
2653
2649
assertThat (person .getBirthDate ()).isEqualTo (LocalDate .of (1999 , 12 , 1 ));
@@ -2738,8 +2734,7 @@ interface InterfaceType {
2738
2734
@ EqualsAndHashCode
2739
2735
@ Getter
2740
2736
static class Address implements InterfaceType {
2741
- @ Field ("s" )
2742
- String street ;
2737
+ @ Field ("s" ) String street ;
2743
2738
String city ;
2744
2739
}
2745
2740
@@ -3340,7 +3335,7 @@ static class TypeWrappingTypeImplementingMap {
3340
3335
}
3341
3336
3342
3337
@ EqualsAndHashCode
3343
- static class TypeImplementingMap implements Map <String ,String > {
3338
+ static class TypeImplementingMap implements Map <String , String > {
3344
3339
3345
3340
String val1 ;
3346
3341
int val2 ;
@@ -3455,15 +3450,9 @@ static class Book {
3455
3450
3456
3451
Author author = new Author ();
3457
3452
3458
- public Book () {}
3459
-
3460
- public Book (String id , String name , Author author ) {
3461
- this .id = id ;
3462
- this .name = name ;
3463
- this .author = author ;
3464
- }
3465
3453
}
3466
3454
3455
+ @ Data
3467
3456
static class Author {
3468
3457
3469
3458
@ Id String id ;
@@ -3472,14 +3461,6 @@ static class Author {
3472
3461
3473
3462
String lastName ;
3474
3463
3475
- public Author () {}
3476
-
3477
- public Author (String id , String firstName , String lastName ) {
3478
- this .id = id ;
3479
- this .firstName = firstName ;
3480
- this .lastName = lastName ;
3481
- }
3482
-
3483
3464
}
3484
3465
3485
3466
}
0 commit comments