27
27
import java .math .BigDecimal ;
28
28
import java .math .BigInteger ;
29
29
import java .net .URL ;
30
+ import java .time .LocalDate ;
30
31
import java .time .LocalDateTime ;
32
+ import java .time .ZoneOffset ;
31
33
import java .time .temporal .ChronoUnit ;
32
34
import java .util .*;
33
35
34
- import org .assertj .core .api .DateAssert ;
35
36
import org .bson .types .Binary ;
36
37
import org .bson .types .Code ;
37
38
import org .bson .types .Decimal128 ;
@@ -2615,7 +2616,8 @@ void readsMapThatDoesNotComeAsDocument() {
2615
2616
@ Test // GH-2860
2616
2617
void projectShouldReadSimpleInterfaceProjection () {
2617
2618
2618
- org .bson .Document source = new org .bson .Document ("birthDate" , new LocalDate (1999 , 12 , 1 ).toDate ()).append ("foo" ,
2619
+ org .bson .Document source = new org .bson .Document ("birthDate" ,
2620
+ Date .from (LocalDate .of (1999 , 12 , 1 ).atStartOfDay ().toInstant (ZoneOffset .UTC ))).append ("foo" ,
2619
2621
"Walter" );
2620
2622
2621
2623
EntityProjectionIntrospector discoverer = EntityProjectionIntrospector .create (converter .getProjectionFactory (),
@@ -2627,14 +2629,15 @@ void projectShouldReadSimpleInterfaceProjection() {
2627
2629
.introspect (PersonProjection .class , Person .class );
2628
2630
PersonProjection person = converter .project (projection , source );
2629
2631
2630
- assertThat (person .getBirthDate ()).isEqualTo (new LocalDate (1999 , 12 , 1 ));
2632
+ assertThat (person .getBirthDate ()).isEqualTo (LocalDate . of (1999 , 12 , 1 ));
2631
2633
assertThat (person .getFirstname ()).isEqualTo ("Walter" );
2632
2634
}
2633
2635
2634
2636
@ Test // GH-2860
2635
2637
void projectShouldReadSimpleDtoProjection () {
2636
2638
2637
- org .bson .Document source = new org .bson .Document ("birthDate" , new LocalDate (1999 , 12 , 1 ).toDate ()).append ("foo" ,
2639
+ org .bson .Document source = new org .bson .Document ("birthDate" ,
2640
+ Date .from (LocalDate .of (1999 , 12 , 1 ).atStartOfDay ().toInstant (ZoneOffset .UTC ))).append ("foo" ,
2638
2641
"Walter" );
2639
2642
2640
2643
EntityProjectionIntrospector introspector = EntityProjectionIntrospector .create (converter .getProjectionFactory (),
@@ -2646,7 +2649,7 @@ void projectShouldReadSimpleDtoProjection() {
2646
2649
.introspect (PersonDto .class , Person .class );
2647
2650
PersonDto person = converter .project (projection , source );
2648
2651
2649
- assertThat (person .getBirthDate ()).isEqualTo (new LocalDate (1999 , 12 , 1 ));
2652
+ assertThat (person .getBirthDate ()).isEqualTo (LocalDate . of (1999 , 12 , 1 ));
2650
2653
assertThat (person .getFirstname ()).isEqualTo ("Walter" );
2651
2654
}
2652
2655
0 commit comments