Search in sources :

Example 1 with SchedulerExecutorService

use of com.enonic.xp.impl.scheduler.SchedulerExecutorService in project xp by enonic.

the class SchedulerServiceImplTest method modifyWithDispose.

@Test
void modifyWithDispose() {
    final ScheduledJobName name = ScheduledJobName.from("test");
    adminContext().callWith(() -> schedulerService.create(CreateScheduledJobParams.create().name(name).descriptor(DescriptorKey.from(ApplicationKey.from("com.enonic.app.test"), "task1")).calendar(calendarService.oneTime(Instant.parse("2021-02-25T10:44:33.170079900Z"))).config(new PropertyTree()).enabled(true).build()));
    adminContext().callWith(() -> schedulerService.modify(ModifyScheduledJobParams.create().name(name).editor(edit -> edit.enabled = false).build()));
    verify(schedulerExecutorService, times(1)).dispose(eq("test"));
}
Also used : SchedulerExecutorService(com.enonic.xp.impl.scheduler.SchedulerExecutorService) BeforeEach(org.junit.jupiter.api.BeforeEach) IdProviderKey(com.enonic.xp.security.IdProviderKey) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) OneTimeCalendar(com.enonic.xp.scheduler.OneTimeCalendar) SchedulerConstants(com.enonic.xp.scheduler.SchedulerConstants) UpdateLastRunCommand(com.enonic.xp.impl.scheduler.UpdateLastRunCommand) ScheduledJob(com.enonic.xp.scheduler.ScheduledJob) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ContextAccessor(com.enonic.xp.context.ContextAccessor) SchedulerServiceImpl(com.enonic.xp.impl.scheduler.SchedulerServiceImpl) ScheduledTaskHandler(com.hazelcast.scheduledexecutor.ScheduledTaskHandler) ContextBuilder(com.enonic.xp.context.ContextBuilder) User(com.enonic.xp.security.User) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) TimeZone(java.util.TimeZone) Set(java.util.Set) SchedulerConfig(com.enonic.xp.impl.scheduler.SchedulerConfig) Instant(java.time.Instant) ScheduleAuditLogSupportImpl(com.enonic.xp.impl.scheduler.ScheduleAuditLogSupportImpl) TaskId(com.enonic.xp.task.TaskId) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest) CronCalendar(com.enonic.xp.scheduler.CronCalendar) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) RoleKeys(com.enonic.xp.security.RoleKeys) Context(com.enonic.xp.context.Context) CreateScheduledJobParams(com.enonic.xp.scheduler.CreateScheduledJobParams) IScheduledFuture(com.hazelcast.scheduledexecutor.IScheduledFuture) ScheduleCalendar(com.enonic.xp.scheduler.ScheduleCalendar) Mockito.mock(org.mockito.Mockito.mock) Strictness(org.mockito.quality.Strictness) ScheduleAuditLogExecutorImpl(com.enonic.xp.impl.scheduler.ScheduleAuditLogExecutorImpl) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) MockitoSettings(org.mockito.junit.jupiter.MockitoSettings) ModifyScheduledJobParams(com.enonic.xp.scheduler.ModifyScheduledJobParams) Mock(org.mockito.Mock) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) ScheduleCalendarType(com.enonic.xp.scheduler.ScheduleCalendarType) AuditLogService(com.enonic.xp.audit.AuditLogService) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PropertyTree(com.enonic.xp.data.PropertyTree) NodeAlreadyExistAtPathException(com.enonic.xp.node.NodeAlreadyExistAtPathException) CalendarServiceImpl(com.enonic.xp.impl.scheduler.CalendarServiceImpl) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) ApplicationKey(com.enonic.xp.app.ApplicationKey) Mockito.verify(org.mockito.Mockito.verify) Mockito(org.mockito.Mockito) PrincipalKey(com.enonic.xp.security.PrincipalKey) DescriptorKey(com.enonic.xp.page.DescriptorKey) NodeAccessException(com.enonic.xp.node.NodeAccessException) ScheduledJobName(com.enonic.xp.scheduler.ScheduledJobName) ScheduledJobName(com.enonic.xp.scheduler.ScheduledJobName) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

ApplicationKey (com.enonic.xp.app.ApplicationKey)1 AuditLogService (com.enonic.xp.audit.AuditLogService)1 Context (com.enonic.xp.context.Context)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 ContextBuilder (com.enonic.xp.context.ContextBuilder)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 CalendarServiceImpl (com.enonic.xp.impl.scheduler.CalendarServiceImpl)1 ScheduleAuditLogExecutorImpl (com.enonic.xp.impl.scheduler.ScheduleAuditLogExecutorImpl)1 ScheduleAuditLogSupportImpl (com.enonic.xp.impl.scheduler.ScheduleAuditLogSupportImpl)1 SchedulerConfig (com.enonic.xp.impl.scheduler.SchedulerConfig)1 SchedulerExecutorService (com.enonic.xp.impl.scheduler.SchedulerExecutorService)1 SchedulerServiceImpl (com.enonic.xp.impl.scheduler.SchedulerServiceImpl)1 UpdateLastRunCommand (com.enonic.xp.impl.scheduler.UpdateLastRunCommand)1 NodeAccessException (com.enonic.xp.node.NodeAccessException)1 NodeAlreadyExistAtPathException (com.enonic.xp.node.NodeAlreadyExistAtPathException)1 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)1 DescriptorKey (com.enonic.xp.page.DescriptorKey)1 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)1 CreateScheduledJobParams (com.enonic.xp.scheduler.CreateScheduledJobParams)1 CronCalendar (com.enonic.xp.scheduler.CronCalendar)1