Skip to content

Commit

Permalink
fix test for DateCOdec
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminiaScarciofolo committed Oct 23, 2024
1 parent 8b660c1 commit 54c8528
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ class DateCodecTest {

@Test
void decode_withValidDateTime_shouldReturnOffsetDateTime() {
LocalDateTime localDateTime = LocalDateTime.of(2021, 12, 1, 0, 0, 0);
LocalDateTime localDateTime = LocalDateTime.of(2021, 11, 1, 0, 0, 0);
String epoch = String.valueOf(localDateTime.toInstant(ZoneOffset.UTC).toEpochMilli());
BsonReader reader = new JsonReader("{\"date\": {\"$date\":" + epoch + "}}");
reader.readStartDocument();
reader.readName("date");

OffsetDateTime result = dateCodec.decode(reader, DecoderContext.builder().build());

OffsetDateTime expected = OffsetDateTime.of(2021, 12, 1, 0, 0, 0, 0, ZoneOffset.UTC);
OffsetDateTime expected = OffsetDateTime.of(2021, 11, 1, 0, 0, 0, 0, ZoneOffset.UTC);
OffsetDateTime desiredOffsetDateTime = expected.withOffsetSameInstant(ZoneOffset.of("+01:00"));

assertEquals(desiredOffsetDateTime, result);
Expand Down

0 comments on commit 54c8528

Please sign in to comment.