### Question:
StandaloneTaskManager extends BaseTaskManager { public void cancel(String taskId) { new TransactionTemplate(platformTransactionManager).execute(s -> { taskRepository.findById(taskId).ifPresent(taskRepository::delete); return null; }); unschedule(context, taskId); } StandaloneTaskManager(String context,
                                 ScheduledTaskExecutor taskExecutor,
                                 TaskRepository taskRepository,
                                 TaskPayloadSerializer taskPayloadSerializer,
                                 PlatformTransactionManager platformTransactionManager,
                                 @Qualifier("taskScheduler") ScheduledExecutorService scheduler,
                                 Clock clock); String createTask(String taskHandler, TaskPayload payload, long instant); void createTask(String taskHandler, Object payload, Duration delay); void cancel(String taskId);  }### Answer:
@Test public void cancel() { String taskId = testSubject.createTask("DummyHandler", new TaskPayload("Dummy", "DummyPayload".getBytes()), scheduler.clock().millis() + TimeUnit.MINUTES.toMillis(1)); assertEquals(1, tasks.size()); assertEquals(2, scheduler.tasks()); scheduler.timeElapses(5, TimeUnit.SECONDS); assertEquals(1, tasks.size()); testSubject.cancel(taskId); assertEquals(0, tasks.size()); }