Search in sources :

Example 1 with QuartzTriggerGroupSummary

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

the class QuartzEndpointTests method quartzTriggerGroupSummaryWithSimpleTrigger.

@Test
void quartzTriggerGroupSummaryWithSimpleTrigger() throws SchedulerException {
    SimpleTrigger simpleTrigger = TriggerBuilder.newTrigger().withIdentity("every-hour", "samples").withSchedule(SimpleScheduleBuilder.repeatHourlyForever(1)).build();
    mockTriggers(simpleTrigger);
    QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
    assertThat(summary.getGroup()).isEqualTo("samples");
    assertThat(summary.isPaused()).isFalse();
    assertThat(summary.getTriggers().getCron()).isEmpty();
    assertThat(summary.getTriggers().getSimple()).containsOnlyKeys("every-hour");
    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) SimpleTrigger(org.quartz.SimpleTrigger) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with QuartzTriggerGroupSummary

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

the class QuartzEndpointTests method quartzTriggerGroupSummaryWithCalendarIntervalTrigger.

@Test
void quartzTriggerGroupSummaryWithCalendarIntervalTrigger() throws SchedulerException {
    CalendarIntervalTrigger trigger = TriggerBuilder.newTrigger().withIdentity("once-a-week", "samples").withSchedule(CalendarIntervalScheduleBuilder.calendarIntervalSchedule().withIntervalInWeeks(1)).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()).isEmpty();
    assertThat(summary.getTriggers().getCalendarInterval()).containsOnlyKeys("once-a-week");
    assertThat(summary.getTriggers().getCustom()).isEmpty();
}
Also used : QuartzTriggerGroupSummary(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary) CalendarIntervalTrigger(org.quartz.CalendarIntervalTrigger) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with QuartzTriggerGroupSummary

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

the class QuartzEndpointTests method quartzTriggerGroupSummaryWithCronTrigger.

@Test
void quartzTriggerGroupSummaryWithCronTrigger() throws SchedulerException {
    CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity("3am-every-day", "samples").withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(3, 0)).build();
    mockTriggers(cronTrigger);
    QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
    assertThat(summary.getGroup()).isEqualTo("samples");
    assertThat(summary.isPaused()).isFalse();
    assertThat(summary.getTriggers().getCron()).containsOnlyKeys("3am-every-day");
    assertThat(summary.getTriggers().getSimple()).isEmpty();
    assertThat(summary.getTriggers().getDailyTimeInterval()).isEmpty();
    assertThat(summary.getTriggers().getCalendarInterval()).isEmpty();
    assertThat(summary.getTriggers().getCustom()).isEmpty();
}
Also used : CronTrigger(org.quartz.CronTrigger) QuartzTriggerGroupSummary(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with QuartzTriggerGroupSummary

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

the class QuartzEndpointTests method quartzTriggerGroupSummaryWithCustomTrigger.

@Test
void quartzTriggerGroupSummaryWithCustomTrigger() throws SchedulerException {
    Trigger trigger = mock(Trigger.class);
    given(trigger.getKey()).willReturn(TriggerKey.triggerKey("custom", "samples"));
    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()).isEmpty();
    assertThat(summary.getTriggers().getCalendarInterval()).isEmpty();
    assertThat(summary.getTriggers().getCustom()).containsOnlyKeys("custom");
}
Also used : CalendarIntervalTrigger(org.quartz.CalendarIntervalTrigger) CronTrigger(org.quartz.CronTrigger) DailyTimeIntervalTrigger(org.quartz.DailyTimeIntervalTrigger) OperableTrigger(org.quartz.spi.OperableTrigger) Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) QuartzTriggerGroupSummary(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with QuartzTriggerGroupSummary

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

the class QuartzEndpointTests method quartzTriggerGroupSummaryWithCustomTriggerDetails.

@Test
void quartzTriggerGroupSummaryWithCustomTriggerDetails() throws SchedulerException {
    Date previousFireTime = Date.from(Instant.parse("2020-11-30T03:00:00Z"));
    Date nextFireTime = Date.from(Instant.parse("2020-12-01T03:00:00Z"));
    Trigger trigger = mock(Trigger.class);
    given(trigger.getKey()).willReturn(TriggerKey.triggerKey("custom", "samples"));
    given(trigger.getPreviousFireTime()).willReturn(previousFireTime);
    given(trigger.getNextFireTime()).willReturn(nextFireTime);
    given(trigger.getPriority()).willReturn(9);
    mockTriggers(trigger);
    QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
    Map<String, Object> triggers = summary.getTriggers().getCustom();
    assertThat(triggers).containsOnlyKeys("custom");
    assertThat(triggers).extractingByKey("custom", nestedMap()).containsOnly(entry("previousFireTime", previousFireTime), entry("nextFireTime", nextFireTime), entry("priority", 9), entry("trigger", trigger.toString()));
}
Also used : CalendarIntervalTrigger(org.quartz.CalendarIntervalTrigger) CronTrigger(org.quartz.CronTrigger) DailyTimeIntervalTrigger(org.quartz.DailyTimeIntervalTrigger) OperableTrigger(org.quartz.spi.OperableTrigger) Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) 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