### Question:
MultiPointOutputStream { void inspectAndPersist() throws IOException { if (syncException != null) throw syncException; if (syncFuture == null) { synchronized (syncRunnable) { if (syncFuture == null) { syncFuture = executeSyncRunnableAsync(); } } } } MultiPointOutputStream(@NonNull final DownloadTask task,
                           @NonNull BreakpointInfo info,
                           @NonNull DownloadStore store,
                           @Nullable Runnable syncRunnable);  MultiPointOutputStream(@NonNull DownloadTask task,
                                  @NonNull BreakpointInfo info,
                                  @NonNull DownloadStore store); synchronized void write(int blockIndex, byte[] bytes, int length); void cancelAsync(); synchronized void cancel(); void done(int blockIndex); void inspectComplete(int blockIndex); void setRequireStreamBlocks(List<Integer> requireStreamBlocks); void catchBlockConnectException(int blockIndex);  }### Answer:
@Test public void inspectAndPersist() throws IOException { final Future newFuture = mock(Future.class); doReturn(newFuture).when(multiPointOutputStream).executeSyncRunnableAsync(); multiPointOutputStream.syncFuture = syncFuture; multiPointOutputStream.inspectAndPersist(); assertThat(multiPointOutputStream.syncFuture).isEqualTo(syncFuture); multiPointOutputStream.syncFuture = null; multiPointOutputStream.inspectAndPersist(); assertThat(multiPointOutputStream.syncFuture).isEqualTo(newFuture); }
@Test(expected = IOException.class) public void inspectAndPersist_syncException() throws IOException { multiPointOutputStream.syncException = new IOException(); multiPointOutputStream.inspectAndPersist(); }
@Test(expected = IOException.class) public void inspectComplete_syncException() throws IOException { multiPointOutputStream.syncException = new IOException(); multiPointOutputStream.inspectAndPersist(); }