### Question:
StandaloneTaskManager extends BaseTaskManager { public String createTask(String taskHandler, TaskPayload payload, long instant) { Task task = new Task(); task.setTaskId(UUID.randomUUID().toString()); task.setStatus(TaskStatus.SCHEDULED); task.setTimestamp(instant); task.setTaskExecutor(taskHandler); task.setContext(context); task.setPayload(payload); super.saveAndSchedule(task); return task.getTaskId(); } 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 createLocalTask() { testSubject.createTask("DummyHandler", new UserInfo("user", Collections.emptySet()), Duration.ofSeconds(5)); assertEquals(1, tasks.size()); scheduler.timeElapses(5, TimeUnit.SECONDS); assertEquals(0, tasks.size()); }
@Test public void createLocalTaskAfter11Minutes() { testSubject.createTask("DummyHandler", new UserInfo("user", Collections.emptySet()), Duration.ofMinutes(11)); assertEquals(1, tasks.size()); assertEquals(1, scheduler.tasks()); scheduler.timeElapses(5, TimeUnit.MINUTES); assertEquals(1, tasks.size()); assertEquals(2, scheduler.tasks()); scheduler.timeElapses(6, TimeUnit.MINUTES); assertEquals(0, tasks.size()); assertEquals(1, scheduler.tasks()); assertEquals(1, executionCounter.get()); }
@Test public void createLocalTaskTransientException() { transientException.set(true); testSubject.createTask("DummyHandler", new UserInfo("user", Collections.emptySet()), Duration.ofSeconds(5)); assertEquals(1, tasks.size()); scheduler.timeElapses(5, TimeUnit.SECONDS); assertEquals(1, executionCounter.get()); assertEquals(1, tasks.size()); transientException.set(false); scheduler.timeElapses(1, TimeUnit.SECONDS); assertEquals(2, executionCounter.get()); assertEquals(0, tasks.size()); }
@Test public void createLocalTaskNonTransientException() { nonTransientException.set(true); testSubject.createTask("DummyHandler", new UserInfo("user", Collections.emptySet()), Duration.ofSeconds(5)); assertEquals(1, tasks.size()); scheduler.timeElapses(5, TimeUnit.SECONDS); assertEquals(1, executionCounter.get()); assertEquals(1, tasks.size()); scheduler.timeElapses(1, TimeUnit.SECONDS); assertEquals(1, executionCounter.get()); assertEquals(1, tasks.size()); }