DropService { @Pollable(async = true, message = "Start canceling drop") public PollableFuture<Drop> cancelDrop(Long dropId, @InjectCurrentTask PollableTask currentTask) throws DropExporterException, CancelDropException { logger.debug("Canceling Drop: {}", dropId); Drop drop = dropRepository.findById(dropId).orElse(null); if (isDropBeingProcessed(drop)) { throw new CancelDropException("A Drop [" + dropId + "] cannot be canceled while it is not at rest"); } drop.setCanceled(true); dropRepository.save(drop); PollableFutureTaskResult<Drop> pollableFutureTaskResult = new PollableFutureTaskResult<>(); DropExporter dropExporter = dropExporterService.recreateDropExporter(drop); logger.debug("Deleting Drop using exporter"); dropExporter.deleteDrop(); pollableFutureTaskResult.setResult(drop); return pollableFutureTaskResult; }  Drop createDrop(Repository repository); @Pollable(expectedSubTaskNumber = 1, message = "Start the Drop export process") PollableFuture<Drop> startDropExportProcess(
            ExportDropConfig exportDropConfig,
            @InjectCurrentTask PollableTask currentTask); @Pollable(async = true, message = "Start importing drop", expectedSubTaskNumber = 1) PollableFuture importDrop(
            Long dropId,
            TMTextUnitVariant.Status importStatus,
            @InjectCurrentTask PollableTask currentTask); @Pollable(async = true, message = "Start canceling drop") PollableFuture<Drop> cancelDrop(Long dropId, @InjectCurrentTask PollableTask currentTask); @Transactional void completeDrop(Drop drop);  }
@Test public void testCancelDrop() throws DropExporterException, InterruptedException, ExecutionException, CancelDropException { TMTestData tmTestData = new TMTestData(testIdWatcher); Repository repository = tmTestData.repository; List<String> bcp47Tags = new ArrayList<>(); bcp47Tags.add("fr-FR"); ExportDropConfig exportDropConfig = new ExportDropConfig(); exportDropConfig.setRepositoryId(repository.getId()); exportDropConfig.setBcp47Tags(bcp47Tags); logger.debug("Check inital number of untranslated units"); checkNumberOfUntranslatedTextUnit(repository, bcp47Tags, 1); logger.debug("Create an initial drop for the repository"); PollableFuture<Drop> startExportProcess = dropService.startDropExportProcess(exportDropConfig, PollableTask.INJECT_CURRENT_TASK); PollableTask pollableTask = startExportProcess.getPollableTask(); logger.debug("Wait for export to finish"); pollableTaskService.waitForPollableTask(pollableTask.getId(), 600000L); logger.debug("Drop export finished, localize files in Box"); Drop drop = startExportProcess.get(); PollableFuture<Drop> dropPollableFuture = dropService.cancelDrop(drop.getId(), PollableTask.INJECT_CURRENT_TASK); PollableTask cancelDropPollableTask = dropPollableFuture.getPollableTask(); logger.debug("Wait for cancellation to finish"); pollableTaskService.waitForPollableTask(cancelDropPollableTask.getId(), 600000L); Drop canceledDrop = dropPollableFuture.get(); Assert.assertTrue("Drop should be canceled", canceledDrop.getCanceled()); }