use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzTriggerGroupSummaryWithDailyIntervalTrigger.
@Test
void quartzTriggerGroupSummaryWithDailyIntervalTrigger() throws SchedulerException {
DailyTimeIntervalTrigger trigger = TriggerBuilder.newTrigger().withIdentity("every-hour-9am", "samples").withSchedule(DailyTimeIntervalScheduleBuilder.dailyTimeIntervalSchedule().startingDailyAt(TimeOfDay.hourAndMinuteOfDay(9, 0)).withInterval(1, IntervalUnit.HOUR)).build();
mockTriggers(trigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
assertThat(summary.getGroup()).isEqualTo("samples");
assertThat(summary.isPaused()).isFalse();
assertThat(summary.getTriggers().getCron()).isEmpty();
assertThat(summary.getTriggers().getSimple()).isEmpty();
assertThat(summary.getTriggers().getDailyTimeInterval()).containsOnlyKeys("every-hour-9am");
assertThat(summary.getTriggers().getCalendarInterval()).isEmpty();
assertThat(summary.getTriggers().getCustom()).isEmpty();
}
use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzTriggerGroupSummaryWithDailyIntervalTriggerDetails.
@Test
void quartzTriggerGroupSummaryWithDailyIntervalTriggerDetails() throws SchedulerException {
Date previousFireTime = Date.from(Instant.parse("2020-11-30T03:00:00Z"));
Date nextFireTime = Date.from(Instant.parse("2020-12-01T03:00:00Z"));
DailyTimeIntervalTrigger trigger = TriggerBuilder.newTrigger().withIdentity("every-hour-tue-thu", "samples").withPriority(4).withSchedule(DailyTimeIntervalScheduleBuilder.dailyTimeIntervalSchedule().onDaysOfTheWeek(Calendar.TUESDAY, Calendar.THURSDAY).startingDailyAt(TimeOfDay.hourAndMinuteOfDay(9, 0)).endingDailyAt(TimeOfDay.hourAndMinuteOfDay(18, 0)).withInterval(1, IntervalUnit.HOUR)).build();
((OperableTrigger) trigger).setPreviousFireTime(previousFireTime);
((OperableTrigger) trigger).setNextFireTime(nextFireTime);
mockTriggers(trigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
Map<String, Object> triggers = summary.getTriggers().getDailyTimeInterval();
assertThat(triggers).containsOnlyKeys("every-hour-tue-thu");
assertThat(triggers).extractingByKey("every-hour-tue-thu", nestedMap()).containsOnly(entry("previousFireTime", previousFireTime), entry("nextFireTime", nextFireTime), entry("priority", 4), entry("interval", 3600000L), entry("startTimeOfDay", LocalTime.of(9, 0)), entry("endTimeOfDay", LocalTime.of(18, 0)), entry("daysOfWeek", new LinkedHashSet<>(Arrays.asList(3, 5))));
}
use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzTriggerGroupSummaryWithInvalidGroup.
@Test
void quartzTriggerGroupSummaryWithInvalidGroup() throws SchedulerException {
given(this.scheduler.getTriggerGroupNames()).willReturn(Collections.singletonList("DEFAULT"));
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("unknown");
assertThat(summary).isNull();
}
use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzTriggerGroupSummaryWithSimpleTriggerDetails.
@Test
void quartzTriggerGroupSummaryWithSimpleTriggerDetails() throws SchedulerException {
Date previousFireTime = Date.from(Instant.parse("2020-11-30T03:00:00Z"));
Date nextFireTime = Date.from(Instant.parse("2020-12-01T03:00:00Z"));
SimpleTrigger simpleTrigger = TriggerBuilder.newTrigger().withIdentity("every-hour", "samples").withPriority(7).withSchedule(SimpleScheduleBuilder.repeatHourlyForever(1)).build();
((OperableTrigger) simpleTrigger).setPreviousFireTime(previousFireTime);
((OperableTrigger) simpleTrigger).setNextFireTime(nextFireTime);
mockTriggers(simpleTrigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
Map<String, Object> triggers = summary.getTriggers().getSimple();
assertThat(triggers).containsOnlyKeys("every-hour");
assertThat(triggers).extractingByKey("every-hour", nestedMap()).containsOnly(entry("previousFireTime", previousFireTime), entry("nextFireTime", nextFireTime), entry("priority", 7), entry("interval", 3600000L));
}
use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzTriggerGroupSummaryWithEmptyGroup.
@Test
void quartzTriggerGroupSummaryWithEmptyGroup() throws SchedulerException {
given(this.scheduler.getTriggerGroupNames()).willReturn(Collections.singletonList("samples"));
given(this.scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals("samples"))).willReturn(Collections.emptySet());
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
assertThat(summary).isNotNull();
assertThat(summary.getGroup()).isEqualTo("samples");
assertThat(summary.isPaused()).isFalse();
assertThat(summary.getTriggers().getCron()).isEmpty();
assertThat(summary.getTriggers().getSimple()).isEmpty();
assertThat(summary.getTriggers().getDailyTimeInterval()).isEmpty();
assertThat(summary.getTriggers().getCalendarInterval()).isEmpty();
assertThat(summary.getTriggers().getCustom()).isEmpty();
}
Aggregations