### Question:
UnifiedListenerManager { public synchronized void attachListener(@NonNull DownloadTask task, @NonNull DownloadListener listener) { final int id = task.getId(); ArrayList<DownloadListener> listenerList = realListenerMap.get(id); if (listenerList == null) { listenerList = new ArrayList<>(); realListenerMap.put(id, listenerList); } if (!listenerList.contains(listener)) { listenerList.add(listener); if (listener instanceof ListenerAssist) { ((ListenerAssist) listener).setAlwaysRecoverAssistModelIfNotSet(true); } } } 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 attachListener() { final DownloadTask task = mockTask(2); listenerManager.attachListener(task, listener); assertThat(listenerManager.realListenerMap.size()).isEqualTo(1); assertThat(listenerManager.realListenerMap.get(2)).containsExactly(listener); final DownloadListener1 listener1 = mock(DownloadListener1.class); listenerManager.attachListener(task, listener1); verify(listener1).setAlwaysRecoverAssistModelIfNotSet(eq(true)); }