### Question:
TaskQueueImpl implements
      TaskQueue,
      ApplicationListener,
      ApplicationEventPublisherAware,
      DisposableBean { @Nullable @Override public synchronized TaskState abortTask(long taskId) { AppFactoryTask task = taskRecorder.getTaskFromId(taskId); if (null != task) { task.abort(); Future<?> future = task.getFuture(); if (null != future) { future.cancel(true); } else { log.warn("Could not cancel future for task with id {}", taskId); } } else { log.warn("Could not abort task with id {}", taskId); } return (null != task) ? task.getCurrentTaskState() : null; } TaskQueueImpl(String name,
                 int expectedTasksPerId,
                 Supplier<Integer> maxPoolSizeSupplier,
                 Supplier<Integer> maxFinishedSizeSupplier); @Override synchronized void addTask(@Nonnull AppFactoryTask task); @Nonnull @Override synchronized Iterable<TaskState> getAllTasks(); @Nonnull @Override Iterable<TaskState> getTasks(Predicate<? super TaskState> predicate); @Override int countActiveTasksByDatastoreId(Long datastoreId); @Override @Nullable synchronized TaskState findTaskById(long id); @Nonnull @Override synchronized Iterable<? extends AbstractCaptureState> findActiveTasksForApp(
         final long appId); @Nonnull @Override synchronized Iterable<? extends TaskState> findActiveTasksForFeed(
         final long feedId); @Nullable @Override synchronized TaskState abortTask(long taskId); @Override synchronized boolean moveToHead(long taskIdToMove); @Override synchronized boolean moveToTail(long taskIdToMove); @Override synchronized boolean moveBefore(long taskIdToMove, long taskIdToFollow); @Override synchronized void cleanup(); @Override synchronized boolean cleanup(long taskId); @Nullable @Override synchronized TaskState unstallConversion(long taskId); @Override @Nonnull @VisibleForTesting List<Runnable> gracefulShutdown(boolean abortUnfinishedTasks); @Override synchronized void abortAllTasks(); @Override void destroy(); @Override void onApplicationEvent(ApplicationEvent applicationEvent); @Override void setApplicationEventPublisher(@Nullable ApplicationEventPublisher applicationEventPublisher);  }### Answer:
@SuppressWarnings("ConstantConditions") @Test(timeout = 500) public void testAbortTask() throws Exception { SleepyTask sleepyTask = newSleepyTask(60); long id = sleepyTask.getCurrentTaskState().getId(); queue.addTask(sleepyTask); while (!TaskQueue.MetaStatus.RUNNING.equals(queue.findTaskById(id).getQueueStatus())) { Thread.sleep(20); } assertTrue(TaskQueue.MetaStatus.RUNNING.equals(queue.findTaskById(id).getQueueStatus())); queue.abortTask(id); while (TaskQueue.MetaStatus.RUNNING.equals(queue.findTaskById(id).getQueueStatus())) { Thread.sleep(20); } TaskState taskState = queue.findTaskById(id); assertNotNull(taskState); assertEquals(TaskQueue.MetaStatus.FINISHED, taskState.getQueueStatus()); assertTrue(taskState.isAborted()); assertTrue(sleepyTask.isInterrupted()); if (-1 == taskState.getStarted()) { assertFalse(sleepyTask.isRun()); assertEquals(TestState.TestStatus.testing, taskState.getStatus()); } else { assertTrue(sleepyTask.isRun()); assertEquals(TestState.TestStatus.swearing, taskState.getStatus()); } assertEquals(-1, taskState.getProgress()); queue.abortTask(-123L); assertTrue(factory.resetNumEventsFired() > 0); }