Search in sources :

Example 16 with CreateScheduledJobParams

use of com.enonic.xp.scheduler.CreateScheduledJobParams in project xp by enonic.

the class SchedulerConfigImplTest method defaultJob.

@Test
void defaultJob() {
    final Map<String, String> properties = new HashMap<>();
    schedulerConfig = new SchedulerConfigImpl(properties, propertyTreeMarshallerService, calendarService);
    final Set<CreateScheduledJobParams> jobs = schedulerConfig.jobs();
    assertEquals(1, jobs.size());
    final CreateScheduledJobParams job = jobs.stream().findAny().orElseThrow(RuntimeException::new);
    assertFalse(job.isEnabled());
    assertEquals(DescriptorKey.from("com.enonic.xp.app.system:audit-log-cleanup"), job.getDescriptor());
    assertEquals(ScheduleCalendarType.CRON, job.getCalendar().getType());
    assertEquals("0 5 * * *", ((CronCalendar) job.getCalendar()).getCronValue());
    assertEquals(1, job.getConfig().getTotalSize());
    assertEquals("PT2s", job.getConfig().getProperty("ageThreshold").getString());
    assertEquals("user:system:custom", job.getUser().toString());
}
Also used : CreateScheduledJobParams(com.enonic.xp.scheduler.CreateScheduledJobParams) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 17 with CreateScheduledJobParams

use of com.enonic.xp.scheduler.CreateScheduledJobParams in project xp by enonic.

the class CreateScheduledJobHandler method doExecute.

@Override
protected ScheduledJobMapper doExecute() {
    final CreateScheduledJobParams params = createParams();
    final ScheduledJob scheduledJob = this.schedulerService.get().create(params);
    return ScheduledJobMapper.from(scheduledJob);
}
Also used : CreateScheduledJobParams(com.enonic.xp.scheduler.CreateScheduledJobParams) ScheduledJob(com.enonic.xp.scheduler.ScheduledJob)

Aggregations

CreateScheduledJobParams (com.enonic.xp.scheduler.CreateScheduledJobParams)17 Test (org.junit.jupiter.api.Test)13 PropertyTree (com.enonic.xp.data.PropertyTree)11 ScheduledJobName (com.enonic.xp.scheduler.ScheduledJobName)7 ScheduledJob (com.enonic.xp.scheduler.ScheduledJob)6 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)5 DescriptorKey (com.enonic.xp.page.DescriptorKey)4 CronCalendar (com.enonic.xp.scheduler.CronCalendar)4 PrincipalKey (com.enonic.xp.security.PrincipalKey)4 HashMap (java.util.HashMap)4 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)3 ScheduleCalendar (com.enonic.xp.scheduler.ScheduleCalendar)3 SchedulableTask (com.enonic.xp.impl.scheduler.distributed.SchedulableTask)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 Instant (java.time.Instant)2 Map (java.util.Map)2 TimeZone (java.util.TimeZone)2 TimeUnit (java.util.concurrent.TimeUnit)2 Matcher (java.util.regex.Matcher)2 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)1