### Question:
DownloadTask extends IdentifiedTask implements Comparable<DownloadTask> { public Builder toBuilder(String anotherUrl, Uri anotherUri) { final Builder builder = new Builder(anotherUrl, anotherUri) .setPriority(priority) .setReadBufferSize(readBufferSize) .setFlushBufferSize(flushBufferSize) .setSyncBufferSize(syncBufferSize) .setSyncBufferIntervalMillis(syncBufferIntervalMills) .setAutoCallbackToUIThread(autoCallbackToUIThread) .setMinIntervalMillisCallbackProcess(minIntervalMillisCallbackProcess) .setHeaderMapFields(headerMapFields) .setPassIfAlreadyCompleted(passIfAlreadyCompleted); if (Util.isUriFileScheme(anotherUri) && !new File(anotherUri.getPath()).isFile() && Util.isUriFileScheme(uri) && filenameHolder.get() != null && !new File(uri.getPath()).getName().equals(filenameHolder.get()) ) { builder.setFilename(filenameHolder.get()); } return builder; } DownloadTask(String url, Uri uri, int priority, int readBufferSize, int flushBufferSize,
                        int syncBufferSize, int syncBufferIntervalMills,
                        boolean autoCallbackToUIThread, int minIntervalMillisCallbackProcess,
                        Map<String, List<String>> headerMapFields, @Nullable String filename,
                        boolean passIfAlreadyCompleted, boolean wifiRequired,
                        Boolean filenameFromResponse, @Nullable Integer connectionCount,
                        @Nullable Boolean isPreAllocateLength); boolean isFilenameFromResponse(); @Nullable Map<String, List<String>> getHeaderMapFields(); @Override int getId(); @Nullable String getFilename(); boolean isPassIfAlreadyCompleted(); boolean isWifiRequired(); DownloadStrategy.FilenameHolder getFilenameHolder(); Uri getUri(); @NonNull String getUrl(); void setRedirectLocation(@Nullable String redirectUrl); @Nullable String getRedirectLocation(); @Override @NonNull File getParentFile(); @Nullable File getFile(); int getReadBufferSize(); int getFlushBufferSize(); int getSyncBufferSize(); int getSyncBufferIntervalMills(); boolean isAutoCallbackToUIThread(); int getMinIntervalMillisCallbackProcess(); @Nullable Integer getSetConnectionCount(); @Nullable Boolean getSetPreAllocateLength(); int getConnectionCount(); Object getTag(int key); Object getTag(); @Nullable BreakpointInfo getInfo(); synchronized DownloadTask addTag(int key, Object value); synchronized void removeTag(int key); synchronized void removeTag(); void setTag(Object tag); void replaceListener(@NonNull DownloadListener listener); static void enqueue(DownloadTask[] tasks, DownloadListener listener); void enqueue(DownloadListener listener); void execute(DownloadListener listener); void cancel(); static void cancel(DownloadTask[] tasks); DownloadListener getListener(); int getPriority(); Builder toBuilder(String anotherUrl, Uri anotherUri); Builder toBuilder(); void setTags(DownloadTask oldTask); @Override int compareTo(@NonNull DownloadTask o); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static MockTaskForCompare mockTaskForCompare(int id); @NonNull MockTaskForCompare mock(int id);  }### Answer:
@Test public void toBuilder() { final Uri uri = mock(Uri.class); when(uri.getPath()).thenReturn(parentPath); when(uri.getScheme()).thenReturn(ContentResolver.SCHEME_FILE); DownloadTask task = new DownloadTask .Builder("url", uri) .setFilename("filename1") .build(); DownloadTask buildTask = task.toBuilder().build(); assertThat(buildTask.getUrl()).isEqualTo("url"); assertThat(buildTask.getUri()).isEqualTo(uri); assertThat(buildTask.getFilename()).isEqualTo("filename1"); final Uri anotherUri = mock(Uri.class); when(anotherUri.getScheme()).thenReturn(ContentResolver.SCHEME_FILE); when(anotherUri.getPath()).thenReturn(parentPath + filename); buildTask = task.toBuilder("anotherUrl", anotherUri).build(); assertThat(buildTask.getUrl()).isEqualTo("anotherUrl"); assertThat(buildTask.getUri()).isEqualTo(anotherUri); assertThat(buildTask.getFilename()).isEqualTo(filename); when(uri.getPath()).thenReturn(parentPath + filename); task = new DownloadTask .Builder("url", uri) .build(); buildTask = task.toBuilder("anotherUrl", uri).build(); assertFile(buildTask.getFile()).isEqualTo(task.getFile()); }