### Question:
UnifiedListenerManager { public synchronized void detachListener(int id) { realListenerMap.remove(id); } UnifiedListenerManager(); synchronized void detachListener(int id); synchronized void addAutoRemoveListenersWhenTaskEnd(int id); synchronized void removeAutoRemoveListenersWhenTaskEnd(int id); synchronized void detachListener(DownloadListener listener); synchronized boolean detachListener(@NonNull DownloadTask task,
                                               DownloadListener listener); synchronized void attachListener(@NonNull DownloadTask task,
                                            @NonNull DownloadListener listener); synchronized void attachAndEnqueueIfNotRun(@NonNull DownloadTask task,
                                                      @NonNull DownloadListener listener); synchronized void enqueueTaskWithUnifiedListener(@NonNull DownloadTask task,
                                                            @NonNull DownloadListener listener); synchronized void executeTaskWithUnifiedListener(@NonNull DownloadTask task,
                                                            @NonNull DownloadListener listener); @NonNull DownloadListener getHostListener();  }### Answer:
@Test public void detachListener() { final ArrayList<DownloadListener> list = new ArrayList<>(); list.add(listener); listenerManager.realListenerMap.put(1, list); final DownloadTask task = mockTask(1); listenerManager.detachListener(task, listener); assertThat(listenerManager.realListenerMap.size()).isZero(); list.add(listener); listenerManager.realListenerMap.put(2, list); assertThat(listenerManager.realListenerMap.size()).isEqualTo(1); listenerManager.detachListener(listener); assertThat(listenerManager.realListenerMap.size()).isZero(); }
@Test public void detachListener_taskId() { final ArrayList<DownloadListener> listenerList = new ArrayList<>(); listenerList.add(mock(DownloadListener.class)); listenerManager.realListenerMap.put(1, listenerList); listenerManager.detachListener(1); assertThat(listenerManager.realListenerMap.size()).isZero(); }