### Question:
TaskManager extends NacosDelayTaskExecuteEngine implements TaskManagerMBean { @Override public void addTask(Object key, AbstractDelayTask newTask) { super.addTask(key, newTask); MetricsMonitor.getDumpTaskMonitor().set(tasks.size()); } TaskManager();  TaskManager(String name); void close(); void await(); boolean await(long timeout, TimeUnit unit); @Override void addTask(Object key, AbstractDelayTask newTask); @Override AbstractDelayTask removeTask(Object key); @Override String getTaskInfos(); void init();  }### Answer:
@Test public void testAddProcessor() throws InterruptedException { when(testTaskProcessor.process(abstractTask)).thenReturn(true); taskManager.addProcessor("test", testTaskProcessor); taskManager.addTask("test", abstractTask); TimeUnit.MILLISECONDS.sleep(200); verify(testTaskProcessor).process(abstractTask); verify(taskProcessor, never()).process(abstractTask); }
@Test public void testRemoveProcessor() throws InterruptedException { when(taskProcessor.process(abstractTask)).thenReturn(true); taskManager.addProcessor("test", testTaskProcessor); taskManager.removeProcessor("test"); taskManager.addTask("test", abstractTask); TimeUnit.MILLISECONDS.sleep(200); verify(testTaskProcessor, never()).process(abstractTask); verify(taskProcessor).process(abstractTask); }
@Test public void testRetryTaskAfterFail() throws InterruptedException { when(taskProcessor.process(abstractTask)).thenReturn(false, true); taskManager.addTask("test", abstractTask); TimeUnit.MILLISECONDS.sleep(300); verify(taskProcessor, new Times(2)).process(abstractTask); }