@Override
    protected void runTask() {
        LOGGER.trace("Looking for scheduled jobs... ");
        Instant scheduledBefore = now().plus(backgroundJobServerConfiguration().getPollInterval());
        processManyJobs(previousResults -> getJobsToSchedule(scheduledBefore, previousResults),
                Job::enqueue,
                totalAmountOfEnqueuedJobs -> LOGGER.debug("Found {} scheduled jobs to enqueue.", totalAmountOfEnqueuedJobs));
    }
@Test
    void testTask() {
        final Job scheduledJob = aScheduledJob().build();

        when(storageProvider.getScheduledJobs(any(), any(AmountRequest.class))).thenReturn(singletonList(scheduledJob), emptyJobList());

        runTask(task);

        verify(storageProvider).save(jobsToSaveArgumentCaptor.capture());
        assertThat(jobsToSaveArgumentCaptor.getValue().get(0)).hasStates(SCHEDULED, ENQUEUED);
    }