Skip to content

Commit d0a93e1

Browse files
committed
Polishing.
1 parent 471db80 commit d0a93e1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
import java.math.BigDecimal;
2828
import java.math.BigInteger;
2929
import java.net.URL;
30+
import java.time.LocalDate;
3031
import java.time.LocalDateTime;
32+
import java.time.ZoneOffset;
3133
import java.time.temporal.ChronoUnit;
3234
import java.util.*;
3335

34-
import org.assertj.core.api.DateAssert;
3536
import org.bson.types.Binary;
3637
import org.bson.types.Code;
3738
import org.bson.types.Decimal128;
@@ -2615,7 +2616,8 @@ void readsMapThatDoesNotComeAsDocument() {
26152616
@Test // GH-2860
26162617
void projectShouldReadSimpleInterfaceProjection() {
26172618

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",
26192621
"Walter");
26202622

26212623
EntityProjectionIntrospector discoverer = EntityProjectionIntrospector.create(converter.getProjectionFactory(),
@@ -2627,14 +2629,15 @@ void projectShouldReadSimpleInterfaceProjection() {
26272629
.introspect(PersonProjection.class, Person.class);
26282630
PersonProjection person = converter.project(projection, source);
26292631

2630-
assertThat(person.getBirthDate()).isEqualTo(new LocalDate(1999, 12, 1));
2632+
assertThat(person.getBirthDate()).isEqualTo(LocalDate.of(1999, 12, 1));
26312633
assertThat(person.getFirstname()).isEqualTo("Walter");
26322634
}
26332635

26342636
@Test // GH-2860
26352637
void projectShouldReadSimpleDtoProjection() {
26362638

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",
26382641
"Walter");
26392642

26402643
EntityProjectionIntrospector introspector = EntityProjectionIntrospector.create(converter.getProjectionFactory(),
@@ -2646,7 +2649,7 @@ void projectShouldReadSimpleDtoProjection() {
26462649
.introspect(PersonDto.class, Person.class);
26472650
PersonDto person = converter.project(projection, source);
26482651

2649-
assertThat(person.getBirthDate()).isEqualTo(new LocalDate(1999, 12, 1));
2652+
assertThat(person.getBirthDate()).isEqualTo(LocalDate.of(1999, 12, 1));
26502653
assertThat(person.getFirstname()).isEqualTo("Walter");
26512654
}
26522655

0 commit comments

Comments
 (0)