@Before @SuppressWarnings("unchecked") public void setUp() throws UnknownHostException { RepoMdGenerator repoMdGenerator = new RepoMdGenerator(context.gridFs()); MetadataService metadataService = context.metadataService(); MongoPrimaryDetector primaryDetector = new MongoPrimaryDetector(context.getMongo()); ScheduledFuture<Void> scheduledFuture = mock(ScheduledFuture.class); TaskScheduler taskScheduler = mock(TaskScheduler.class); when(taskScheduler.scheduleWithFixedDelay(any(Runnable.class), anyLong())) .thenReturn(scheduledFuture); schedulerJob = new RepoMetadataSchedulerJob( context.repoEntriesRepository(), metadataService, primaryDetector, taskScheduler, DELAY); }