### Question:
Listener4SpeedAssistExtend implements Listener4Assist.AssistExtend,
        ListenerModelHandler.ModelCreator<Listener4SpeedAssistExtend.Listener4SpeedModel> { @Override public boolean dispatchTaskEnd(DownloadTask task, EndCause cause, @Nullable Exception realCause, @NonNull Listener4Assist.Listener4Model model) { final Listener4SpeedModel speedModel = (Listener4SpeedModel) model; final SpeedCalculator speedCalculator; if (speedModel.taskSpeed != null) { speedCalculator = speedModel.taskSpeed; speedCalculator.endTask(); } else { speedCalculator = new SpeedCalculator(); } if (callback != null) { callback.taskEnd(task, cause, realCause, speedCalculator); } return true; }  void setCallback(Listener4SpeedCallback callback); @Override boolean dispatchInfoReady(DownloadTask task, @NonNull BreakpointInfo info,
                                               boolean fromBreakpoint,
                                               @NonNull Listener4Assist.Listener4Model model); @Override boolean dispatchFetchProgress(@NonNull DownloadTask task, int blockIndex,
                                                   long increaseBytes,
                                                   @NonNull Listener4Assist.Listener4Model model); @Override boolean dispatchBlockEnd(DownloadTask task, int blockIndex,
                                              Listener4Assist.Listener4Model model); @Override boolean dispatchTaskEnd(DownloadTask task, EndCause cause, @Nullable Exception realCause,
                                   @NonNull Listener4Assist.Listener4Model model); @Override Listener4SpeedModel create(int id);  }### Answer:
@Test public void dispatchTaskEnd() { final boolean result = assistExtend.dispatchTaskEnd(task, EndCause.COMPLETED, null, model); assertThat(result).isTrue(); verify(model.taskSpeed).endTask(); verify(callback).taskEnd(eq(task), eq(EndCause.COMPLETED), nullable(Exception.class), eq(model.taskSpeed)); }
@Test public void dispatchTaskEnd_withUnValidModel() { final Listener4SpeedAssistExtend.Listener4SpeedModel invalidModel = new Listener4SpeedAssistExtend.Listener4SpeedModel(1); assertThat(invalidModel.blockSpeeds).isEqualTo(null); assertThat(invalidModel.taskSpeed).isEqualTo(null); final boolean result = assistExtend.dispatchTaskEnd( task, EndCause.CANCELED, null, invalidModel); assertThat(result).isTrue(); verify(callback).taskEnd(eq(task), eq(EndCause.CANCELED), nullable(Exception.class), (SpeedCalculator) notNull()); }