Search in sources :

Example 6 with QuartzTriggerGroupSummary

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();
}
Also used : QuartzTriggerGroupSummary(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary) DailyTimeIntervalTrigger(org.quartz.DailyTimeIntervalTrigger) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with QuartzTriggerGroupSummary

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))));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OperableTrigger(org.quartz.spi.OperableTrigger) QuartzTriggerGroupSummary(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary) DailyTimeIntervalTrigger(org.quartz.DailyTimeIntervalTrigger) Date(java.util.Date) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with QuartzTriggerGroupSummary

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();
}
Also used : QuartzTriggerGroupSummary(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with QuartzTriggerGroupSummary

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));
}
Also used : OperableTrigger(org.quartz.spi.OperableTrigger) QuartzTriggerGroupSummary(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary) SimpleTrigger(org.quartz.SimpleTrigger) Date(java.util.Date) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with QuartzTriggerGroupSummary

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();
}
Also used : QuartzTriggerGroupSummary(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary) 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