Search in sources :

Example 11 with QuartzTriggerGroupSummary

use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary in project spring-boot by spring-projects.

the class QuartzEndpointTests method quartzTriggerGroupSummaryWithCalendarIntervalTriggerDetails.

@Test
void quartzTriggerGroupSummaryWithCalendarIntervalTriggerDetails() throws SchedulerException {
    TimeZone timeZone = TimeZone.getTimeZone("Europe/Paris");
    Date previousFireTime = Date.from(Instant.parse("2020-11-30T03:00:00Z"));
    Date nextFireTime = Date.from(Instant.parse("2020-12-01T03:00:00Z"));
    CalendarIntervalTrigger trigger = TriggerBuilder.newTrigger().withIdentity("once-a-week", "samples").withPriority(8).withSchedule(CalendarIntervalScheduleBuilder.calendarIntervalSchedule().withIntervalInWeeks(1).inTimeZone(timeZone)).build();
    ((OperableTrigger) trigger).setPreviousFireTime(previousFireTime);
    ((OperableTrigger) trigger).setNextFireTime(nextFireTime);
    mockTriggers(trigger);
    QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
    Map<String, Object> triggers = summary.getTriggers().getCalendarInterval();
    assertThat(triggers).containsOnlyKeys("once-a-week");
    assertThat(triggers).extractingByKey("once-a-week", nestedMap()).containsOnly(entry("previousFireTime", previousFireTime), entry("nextFireTime", nextFireTime), entry("priority", 8), entry("interval", 604800000L), entry("timeZone", timeZone));
}
Also used : OperableTrigger(org.quartz.spi.OperableTrigger) TimeZone(java.util.TimeZone) QuartzTriggerGroupSummary(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary) Date(java.util.Date) CalendarIntervalTrigger(org.quartz.CalendarIntervalTrigger) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with QuartzTriggerGroupSummary

use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary in project spring-boot by spring-projects.

the class QuartzEndpointTests method quartzTriggerGroupSummaryWithCronTriggerDetails.

@Test
void quartzTriggerGroupSummaryWithCronTriggerDetails() throws SchedulerException {
    Date previousFireTime = Date.from(Instant.parse("2020-11-30T03:00:00Z"));
    Date nextFireTime = Date.from(Instant.parse("2020-12-01T03:00:00Z"));
    TimeZone timeZone = TimeZone.getTimeZone("Europe/Paris");
    CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity("3am-every-day", "samples").withPriority(3).withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(3, 0).inTimeZone(timeZone)).build();
    ((OperableTrigger) cronTrigger).setPreviousFireTime(previousFireTime);
    ((OperableTrigger) cronTrigger).setNextFireTime(nextFireTime);
    mockTriggers(cronTrigger);
    QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
    Map<String, Object> triggers = summary.getTriggers().getCron();
    assertThat(triggers).containsOnlyKeys("3am-every-day");
    assertThat(triggers).extractingByKey("3am-every-day", nestedMap()).containsOnly(entry("previousFireTime", previousFireTime), entry("nextFireTime", nextFireTime), entry("priority", 3), entry("expression", "0 0 3 ? * *"), entry("timeZone", timeZone));
}
Also used : OperableTrigger(org.quartz.spi.OperableTrigger) TimeZone(java.util.TimeZone) CronTrigger(org.quartz.CronTrigger) QuartzTriggerGroupSummary(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary) Date(java.util.Date) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Test (org.junit.jupiter.api.Test)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 QuartzTriggerGroupSummary (org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary)12 OperableTrigger (org.quartz.spi.OperableTrigger)6 Date (java.util.Date)5 CalendarIntervalTrigger (org.quartz.CalendarIntervalTrigger)4 CronTrigger (org.quartz.CronTrigger)4 DailyTimeIntervalTrigger (org.quartz.DailyTimeIntervalTrigger)4 SimpleTrigger (org.quartz.SimpleTrigger)4 TimeZone (java.util.TimeZone)2 Trigger (org.quartz.Trigger)2 LinkedHashSet (java.util.LinkedHashSet)1