### Question:
BreakpointLocalCheck { public boolean isFileExistToResume() { final Uri uri = task.getUri(); if (Util.isUriContentScheme(uri)) { return Util.getSizeFromContentUri(uri) > 0; } else { final File file = task.getFile(); return file != null && file.exists(); } } BreakpointLocalCheck(@NonNull DownloadTask task, @NonNull BreakpointInfo info,
                                long responseInstanceLength); boolean isDirty(); @NonNull ResumeFailedCause getCauseOrThrow(); boolean isInfoRightToResume(); boolean isOutputStreamSupportResume(); boolean isFileExistToResume(); void check(); @Override String toString();  }### Answer:
@Test public void isFileExistToResume_contentUri() throws IOException { mockOkDownload(); final OkDownload okDownload = OkDownload.with(); final Context context = mock(Context.class); when(okDownload.context()).thenReturn(context); final ContentResolver resolver = mock(ContentResolver.class); when(context.getContentResolver()).thenReturn(resolver); when(task.getUri()).thenReturn(contentUri); assertThat(check.isFileExistToResume()).isFalse(); final Cursor cursor = mock(Cursor.class); when(resolver.query(contentUri, null, null, null, null)).thenReturn(cursor); doReturn(1L).when(cursor).getLong(anyInt()); assertThat(check.isFileExistToResume()).isTrue(); }
@Test public void isFileExistToResume_fileUri() { when(task.getUri()).thenReturn(fileUri); when(task.getFile()).thenReturn(null); assertThat(check.isFileExistToResume()).isFalse(); final File file = mock(File.class); when(task.getFile()).thenReturn(file); when(file.exists()).thenReturn(false); assertThat(check.isFileExistToResume()).isFalse(); when(file.exists()).thenReturn(true); assertThat(check.isFileExistToResume()).isTrue(); }