@Test void testSchedule() throws InterruptedException { Thread.sleep(10); service.purgeProjectAndRepository(manager.executor(), metadataService); verify(manager.executor()).execute(isA(PurgeProjectCommand.class)); verify(manager.executor()).execute(isA(PurgeRepositoryCommand.class)); }
@VisibleForTesting void purgeProjectAndRepository(CommandExecutor commandExecutor, MetadataService metadataService) { final long minAllowedTimestamp = System.currentTimeMillis() - maxRemovedRepositoryAgeMillis; final Predicate<Instant> olderThanMinAllowed = removedAt -> removedAt.toEpochMilli() < minAllowedTimestamp; purgeProject(commandExecutor, olderThanMinAllowed); purgeRepository(commandExecutor, metadataService, olderThanMinAllowed); }
PurgeSchedulingService { @VisibleForTesting void purgeProjectAndRepository(CommandExecutor commandExecutor, MetadataService metadataService) { final long minAllowedTimestamp = System.currentTimeMillis() - maxRemovedRepositoryAgeMillis; final Predicate<Instant> olderThanMinAllowed = removedAt -> removedAt.toEpochMilli() < minAllowedTimestamp; purgeProject(commandExecutor, olderThanMinAllowed); purgeRepository(commandExecutor, metadataService, olderThanMinAllowed); } }
PurgeSchedulingService { @VisibleForTesting void purgeProjectAndRepository(CommandExecutor commandExecutor, MetadataService metadataService) { final long minAllowedTimestamp = System.currentTimeMillis() - maxRemovedRepositoryAgeMillis; final Predicate<Instant> olderThanMinAllowed = removedAt -> removedAt.toEpochMilli() < minAllowedTimestamp; purgeProject(commandExecutor, olderThanMinAllowed); purgeRepository(commandExecutor, metadataService, olderThanMinAllowed); } PurgeSchedulingService(ProjectManager projectManager, ScheduledExecutorService purgeWorker,
                                  long maxRemovedRepositoryAgeMillis); }
PurgeSchedulingService { @VisibleForTesting void purgeProjectAndRepository(CommandExecutor commandExecutor, MetadataService metadataService) { final long minAllowedTimestamp = System.currentTimeMillis() - maxRemovedRepositoryAgeMillis; final Predicate<Instant> olderThanMinAllowed = removedAt -> removedAt.toEpochMilli() < minAllowedTimestamp; purgeProject(commandExecutor, olderThanMinAllowed); purgeRepository(commandExecutor, metadataService, olderThanMinAllowed); } PurgeSchedulingService(ProjectManager projectManager, ScheduledExecutorService purgeWorker,
                                  long maxRemovedRepositoryAgeMillis); void start(CommandExecutor commandExecutor,
                      MetadataService metadataService); boolean isStarted(); void stop(); }
PurgeSchedulingService { @VisibleForTesting void purgeProjectAndRepository(CommandExecutor commandExecutor, MetadataService metadataService) { final long minAllowedTimestamp = System.currentTimeMillis() - maxRemovedRepositoryAgeMillis; final Predicate<Instant> olderThanMinAllowed = removedAt -> removedAt.toEpochMilli() < minAllowedTimestamp; purgeProject(commandExecutor, olderThanMinAllowed); purgeRepository(commandExecutor, metadataService, olderThanMinAllowed); } PurgeSchedulingService(ProjectManager projectManager, ScheduledExecutorService purgeWorker,
                                  long maxRemovedRepositoryAgeMillis); void start(CommandExecutor commandExecutor,
                      MetadataService metadataService); boolean isStarted(); void stop();  }