Skip to content

Commit

Permalink
Refactored a test intended to examine different clocks. (#189)
Browse files Browse the repository at this point in the history
* Refactored a test that was essentially testing the same execution times.

Signed-off-by: AWSHurneyt <[email protected]>

* Refactored time zone test based on PR feedback.

Signed-off-by: AWSHurneyt <[email protected]>

* Refactored time zone test to use a more controlled instant.

Signed-off-by: AWSHurneyt <[email protected]>
  • Loading branch information
AWSHurneyt authored Jun 1, 2022
1 parent 7b55006 commit 7b5873c
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ public void setup() {
}

public void testDifferentClocks() {
Clock pdtClock = Clock.system(ZoneId.of("America/Los_Angeles"));
Clock utcClock = Clock.system(ZoneId.of("UTC"));
CronSchedule pdtClockCronSchedule = new CronSchedule("* * * * *", ZoneId.systemDefault());
Instant now = Instant.now();
Clock pdtClock = Clock.fixed(now, ZoneId.of("America/Los_Angeles"));
Clock utcClock = Clock.fixed(now, ZoneId.of("UTC"));
CronSchedule pdtClockCronSchedule = new CronSchedule("* * * * *", ZoneId.of("America/Los_Angeles"));
pdtClockCronSchedule.setClock(pdtClock);
CronSchedule utcClockCronSchedule = new CronSchedule("* * * * *", ZoneId.systemDefault());
CronSchedule utcClockCronSchedule = new CronSchedule("* * * * *", ZoneId.of("UTC"));
utcClockCronSchedule.setClock(utcClock);
Instant now = Instant.now();
assertEquals("Next execution time based on different clock should be same.",
pdtClockCronSchedule.getNextExecutionTime(now),
utcClockCronSchedule.getNextExecutionTime(now));
pdtClockCronSchedule.getNextExecutionTime(null),
utcClockCronSchedule.getNextExecutionTime(null));
}

public void testNextTimeToExecute() {
Expand Down

0 comments on commit 7b5873c

Please sign in to comment.