### Question:
Listener4Assist implements ListenerAssist { public synchronized void taskEnd(DownloadTask task, EndCause cause, @Nullable Exception realCause) { Listener4Model model = modelHandler.removeOrCreate(task, task.getInfo()); if (assistExtend != null && assistExtend.dispatchTaskEnd(task, cause, realCause, model)) { return; } if (callback != null) callback.taskEnd(task, cause, realCause, model); } Listener4Assist(ListenerModelHandler<T> handler);  Listener4Assist(ListenerModelHandler.ModelCreator<T> creator); void setCallback(@NonNull Listener4Callback callback); void setAssistExtend(@NonNull AssistExtend assistExtend); AssistExtend getAssistExtend(); void infoReady(DownloadTask task, BreakpointInfo info, boolean fromBreakpoint); void fetchProgress(DownloadTask task, int blockIndex, long increaseBytes); void fetchEnd(DownloadTask task, int blockIndex); synchronized void taskEnd(DownloadTask task, EndCause cause,
                                     @Nullable Exception realCause); @Override boolean isAlwaysRecoverAssistModel(); @Override void setAlwaysRecoverAssistModel(boolean isAlwaysRecoverAssistModel); @Override void setAlwaysRecoverAssistModelIfNotSet(boolean isAlwaysRecoverAssistModel);  }### Answer:
@Test public void taskEnd_dispatch() { when(handler.removeOrCreate(task, info)).thenReturn(model); when(assistExtend.dispatchTaskEnd(eq(task), any(EndCause.class), nullable(Exception.class), any(Listener4Assist.Listener4Model.class))) .thenReturn(true); assist.taskEnd(task, EndCause.COMPLETED, null); verify(callback, never()) .taskEnd(eq(task), eq(EndCause.COMPLETED), nullable(Exception.class), any(Listener4Assist.Listener4Model.class)); }
@Test public void taskEnd_noModel() { when(handler.removeOrCreate(task, info)).thenReturn(model); assist.taskEnd(task, EndCause.COMPLETED, null); verify(callback).taskEnd(eq(task), eq(EndCause.COMPLETED), nullable(Exception.class), any(Listener4Assist.Listener4Model.class)); }