AutoCleanupScheduler { @Scheduled(initialDelayString = PROP_AUTO_CLEANUP_INTERVAL, fixedDelayString = PROP_AUTO_CLEANUP_INTERVAL) public void run() { LOGGER.debug("Auto cleanup scheduler has been triggered."); if (!cleanupTasks.isEmpty()) { systemSecurityContext.runAsSystem(this::executeAutoCleanup); } } AutoCleanupScheduler(final SystemManagement systemManagement,
            final SystemSecurityContext systemSecurityContext, final LockRegistry lockRegistry,
            final List<CleanupTask> cleanupTasks); @Scheduled(initialDelayString = PROP_AUTO_CLEANUP_INTERVAL, fixedDelayString = PROP_AUTO_CLEANUP_INTERVAL) void run();  }
@Test @Description("Verifies that all cleanup handlers are executed regardless if one of them throws an error") public void executeHandlerChain() { new AutoCleanupScheduler(systemManagement, systemSecurityContext, lockRegistry, Arrays.asList( new SuccessfulCleanup(), new SuccessfulCleanup(), new FailingCleanup(), new SuccessfulCleanup())).run(); assertThat(counter.get()).isEqualTo(4); }