Merge pull request #16423 from wynnteo/BAEL-7616-HF

Bael 7616 hf
This commit is contained in:
Ulisses Lima 2024-04-16 17:51:13 -03:00 committed by GitHub
commit afe0ff1351
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -47,9 +48,8 @@ public class CompareYesterdayUnitTest {
void givenYesterdayDate_whenCompareWithDateMilliseconds_returnTrue() { void givenYesterdayDate_whenCompareWithDateMilliseconds_returnTrue() {
// Create a Date object representing yesterday // Create a Date object representing yesterday
Date expectedDate = new Date(System.currentTimeMillis() - (1000 * 60 * 60 * 24)); Date expectedDate = new Date(System.currentTimeMillis() - (1000 * 60 * 60 * 24));
long yesterdayMidnightMillis = Instant.now() ZonedDateTime yesterdayMidnight = ZonedDateTime.now().minusDays(1).truncatedTo(ChronoUnit.DAYS);
.minus(1, ChronoUnit.DAYS) long yesterdayMidnightMillis = yesterdayMidnight.toInstant().toEpochMilli();
.toEpochMilli();
boolean isEqualToYesterday = expectedDate.getTime() >= yesterdayMidnightMillis && expectedDate.getTime() < yesterdayMidnightMillis + 86_400_000; boolean isEqualToYesterday = expectedDate.getTime() >= yesterdayMidnightMillis && expectedDate.getTime() < yesterdayMidnightMillis + 86_400_000;
assertTrue(isEqualToYesterday); assertTrue(isEqualToYesterday);
@ -59,9 +59,8 @@ public class CompareYesterdayUnitTest {
void givenTodayDate_whenCompareWithDateMilliseconds_returnFalse() { void givenTodayDate_whenCompareWithDateMilliseconds_returnFalse() {
// Create a Date object representing yesterday // Create a Date object representing yesterday
Date expectedDate = new Date(); Date expectedDate = new Date();
long yesterdayMidnightMillis = Instant.now() ZonedDateTime yesterdayMidnight = ZonedDateTime.now().minusDays(1).truncatedTo(ChronoUnit.DAYS);
.minus(1, ChronoUnit.DAYS) long yesterdayMidnightMillis = yesterdayMidnight.toInstant().toEpochMilli();
.toEpochMilli();
boolean isEqualToYesterday = expectedDate.getTime() >= yesterdayMidnightMillis && expectedDate.getTime() < yesterdayMidnightMillis + 86_400_000; boolean isEqualToYesterday = expectedDate.getTime() >= yesterdayMidnightMillis && expectedDate.getTime() < yesterdayMidnightMillis + 86_400_000;
assertFalse(isEqualToYesterday); assertFalse(isEqualToYesterday);