MaintenanceScheduler { @PostConstruct public void launchOnceTask() { taskExecutor.execute(() -> runMaintenanceTask(ONCE)); }  @PostConstruct void launchOnceTask(); @Scheduled(cron = "${maintenance.scheduled.cron}") void launchNightlyTask(); @Scheduled(fixedDelayString = "${maintenance.scheduled.fixed-delay}", initialDelayString = "${maintenance.scheduled.initial-delay}") void launchRepeatlyTask();  }
@Test public void testScheduleOnce() { scheduler.launchOnceTask(); verify(listTask.get(0), times(1)).performTask(); verify(listTask.get(1), times(0)).performTask(); listTask .stream() .filter(task -> !(task instanceof MockScheduledOnceTask)) .forEach(task -> { verify(task, times(0)).performTask(); verify(task, times(0)).condition(); verify(task, times(0)).execute(); }); }