CleanupTask extends TaskSupport { @Override protected Object execute() { log.info("Starting cleanup"); cleanupService.cleanup(() -> isCanceled()); if (isCanceled()) { log.info("Cleanup was cancelled before it could finish"); } else { log.info("Cleanup finished"); } return null; } @Inject  CleanupTask(final CleanupService cleanupService); @Override String getMessage();  }
@Test public void runCleanup() throws Exception { underTest.execute(); verify(cleanupService).cleanup(any(BooleanSupplier.class)); }