Skip to content

Commit

Permalink
. t fix flakey test
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsEckart committed Nov 20, 2023
1 parent 5c5b87f commit 96d82e0
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneOffset;
import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -58,14 +61,17 @@ private void assertStartAndEnd(StartAndEndUseCases useCase)
@Test
public void testNextAndLast()
{
int day = (new GregorianCalendar().get(Calendar.DAY_OF_WEEK) != Calendar.THURSDAY)
? Calendar.THURSDAY
: Calendar.TUESDAY;
Timestamp next = DateUtils.getNextOrCurrent(day);
Timestamp last = DateUtils.getLastOrCurrent(day);
assertEquals(day, DateUtils.asCalendar(next).get(Calendar.DAY_OF_WEEK), "next thrusday");
assertEquals(day, DateUtils.asCalendar(last).get(Calendar.DAY_OF_WEEK), "last thrusday");
assertTrue(next.after(last), "order for " + next + " after" + last);
try (WithTimeZone tz = new WithTimeZone())
{
int day = (new GregorianCalendar().get(Calendar.DAY_OF_WEEK) != Calendar.THURSDAY)
? Calendar.THURSDAY
: Calendar.TUESDAY;
Timestamp next = DateUtils.getNextOrCurrent(day);
Timestamp last = DateUtils.getLastOrCurrent(day);
assertEquals(day, DateUtils.asCalendar(next).get(Calendar.DAY_OF_WEEK), "next thursday");
assertEquals(day, DateUtils.asCalendar(last).get(Calendar.DAY_OF_WEEK), "last thursday");
assertTrue(next.after(last), "order for " + next + " after" + last);
}
}
public static class StartAndEndUseCases
{
Expand Down

0 comments on commit 96d82e0

Please sign in to comment.