use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzJobOrdersTriggersAccordingNextFireTimeAndPriority.
@Test
void quartzJobOrdersTriggersAccordingNextFireTimeAndPriority() throws SchedulerException {
JobDetail job = JobBuilder.newJob(Job.class).withIdentity("hello", "samples").build();
mockJobs(job);
Date nextFireTime = Date.from(Instant.parse("2020-12-01T03:00:00Z"));
CronTrigger triggerOne = TriggerBuilder.newTrigger().withIdentity("one", "samples").withPriority(3).withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(3, 0)).build();
((OperableTrigger) triggerOne).setNextFireTime(nextFireTime);
CronTrigger triggerTwo = TriggerBuilder.newTrigger().withIdentity("two", "samples").withPriority(7).withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(3, 0)).build();
((OperableTrigger) triggerTwo).setNextFireTime(nextFireTime);
mockTriggers(triggerOne, triggerTwo);
given(this.scheduler.getTriggersOfJob(JobKey.jobKey("hello", "samples"))).willAnswer((invocation) -> Arrays.asList(triggerOne, triggerTwo));
QuartzJobDetails jobDetails = this.endpoint.quartzJob("samples", "hello");
assertThat(jobDetails.getTriggers()).hasSize(2);
assertThat(jobDetails.getTriggers().get(0)).containsEntry("name", "two");
assertThat(jobDetails.getTriggers().get(1)).containsEntry("name", "one");
}
use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzJobWithSensitiveDataMap.
@Test
void quartzJobWithSensitiveDataMap() throws SchedulerException {
JobDetail job = JobBuilder.newJob(Job.class).withIdentity("hello", "samples").usingJobData("user", "user").usingJobData("password", "secret").usingJobData("url", "https://user:secret@example.com").build();
mockJobs(job);
QuartzJobDetails jobDetails = this.endpoint.quartzJob("samples", "hello");
assertThat(jobDetails.getData()).containsOnly(entry("user", "user"), entry("password", "******"), entry("url", "https://user:******@example.com"));
}
use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzJobWithoutTrigger.
@Test
void quartzJobWithoutTrigger() throws SchedulerException {
JobDetail job = JobBuilder.newJob(Job.class).withIdentity("hello", "samples").withDescription("A sample job").storeDurably().requestRecovery(false).build();
mockJobs(job);
QuartzJobDetails jobDetails = this.endpoint.quartzJob("samples", "hello");
assertThat(jobDetails.getGroup()).isEqualTo("samples");
assertThat(jobDetails.getName()).isEqualTo("hello");
assertThat(jobDetails.getDescription()).isEqualTo("A sample job");
assertThat(jobDetails.getClassName()).isEqualTo(Job.class.getName());
assertThat(jobDetails.isDurable()).isTrue();
assertThat(jobDetails.isRequestRecovery()).isFalse();
assertThat(jobDetails.getData()).isEmpty();
assertThat(jobDetails.getTriggers()).isEmpty();
}
use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzJobWithSensitiveDataMapAndCustomSanitizier.
@Test
void quartzJobWithSensitiveDataMapAndCustomSanitizier() throws SchedulerException {
JobDetail job = JobBuilder.newJob(Job.class).withIdentity("hello", "samples").usingJobData("test", "value").usingJobData("secret", "value").build();
mockJobs(job);
Sanitizer sanitizer = mock(Sanitizer.class);
given(sanitizer.sanitize("test", "value")).willReturn("value");
given(sanitizer.sanitize("secret", "value")).willReturn("----");
QuartzJobDetails jobDetails = new QuartzEndpoint(this.scheduler, sanitizer).quartzJob("samples", "hello");
assertThat(jobDetails.getData()).containsOnly(entry("test", "value"), entry("secret", "----"));
then(sanitizer).should().sanitize("test", "value");
then(sanitizer).should().sanitize("secret", "value");
then(sanitizer).shouldHaveNoMoreInteractions();
}
use of org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzJobWithTrigger.
@Test
void quartzJobWithTrigger() throws SchedulerException {
Date previousFireTime = Date.from(Instant.parse("2020-11-30T03:00:00Z"));
Date nextFireTime = Date.from(Instant.parse("2020-12-01T03:00:00Z"));
JobDetail job = JobBuilder.newJob(Job.class).withIdentity("hello", "samples").build();
TimeZone timeZone = TimeZone.getTimeZone("Europe/Paris");
Trigger trigger = TriggerBuilder.newTrigger().withIdentity("3am-every-day", "samples").withPriority(4).withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(3, 0).inTimeZone(timeZone)).build();
((OperableTrigger) trigger).setPreviousFireTime(previousFireTime);
((OperableTrigger) trigger).setNextFireTime(nextFireTime);
mockJobs(job);
mockTriggers(trigger);
given(this.scheduler.getTriggersOfJob(JobKey.jobKey("hello", "samples"))).willAnswer((invocation) -> Collections.singletonList(trigger));
QuartzJobDetails jobDetails = this.endpoint.quartzJob("samples", "hello");
assertThat(jobDetails.getTriggers()).hasSize(1);
Map<String, Object> triggerDetails = jobDetails.getTriggers().get(0);
assertThat(triggerDetails).containsOnly(entry("group", "samples"), entry("name", "3am-every-day"), entry("previousFireTime", previousFireTime), entry("nextFireTime", nextFireTime), entry("priority", 4));
}
Aggregations