### Question:
BreakpointLocalCheck { public boolean isInfoRightToResume() { final int blockCount = info.getBlockCount(); if (blockCount <= 0) return false; if (info.isChunked()) return false; if (info.getFile() == null) return false; final File fileOnTask = task.getFile(); if (!info.getFile().equals(fileOnTask)) return false; if (info.getFile().length() > info.getTotalLength()) return false; if (responseInstanceLength > 0 && info.getTotalLength() != responseInstanceLength) { return false; } for (int i = 0; i < blockCount; i++) { BlockInfo blockInfo = info.getBlock(i); if (blockInfo.getContentLength() <= 0) return false; } return true; } 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 isInfoRightToResume_noBlock() { when(info.getBlockCount()).thenReturn(0); assertThat(check.isInfoRightToResume()).isFalse(); }
@Test public void isInfoRightToResume_chunked() { when(info.isChunked()).thenReturn(true); assertThat(check.isInfoRightToResume()).isFalse(); }
@Test public void isInfoRightToResume_noFile() { when(info.getFile()).thenReturn(null); assertThat(check.isInfoRightToResume()).isFalse(); }
@Test public void isInfoRightToResume_fileNotEqual() { when(task.getFile()).thenReturn(fileOnTask); assertThat(check.isInfoRightToResume()).isFalse(); }
@Test public void isInfoRightToResume_fileLengthLargerThanTotalLength() { when(fileOnInfo.length()).thenReturn(2L); when(info.getTotalLength()).thenReturn(1L); assertThat(check.isInfoRightToResume()).isFalse(); }
@Test public void isInfoRightToResume_instanceLengthEqual() { check = spy(new BreakpointLocalCheck(task, info, 2)); when(info.getBlockCount()).thenReturn(1); when(info.isChunked()).thenReturn(false); when(info.getFile()).thenReturn(fileOnInfo); when(task.getFile()).thenReturn(fileOnInfo); when(info.getBlock(0)).thenReturn(blockInfo); when(blockInfo.getContentLength()).thenReturn(1L); when(contentUri.getScheme()).thenReturn(ContentResolver.SCHEME_CONTENT); when(fileUri.getScheme()).thenReturn(ContentResolver.SCHEME_FILE); when(info.getTotalLength()).thenReturn(1L); assertThat(check.isInfoRightToResume()).isFalse(); }
@Test public void isInfoRightToResume_blockRight() { when(blockInfo.getContentLength()).thenReturn(0L); assertThat(check.isInfoRightToResume()).isFalse(); }
@Test public void isInfoRightToResume() { when(info.getBlockCount()).thenReturn(1); when(info.isChunked()).thenReturn(false); when(info.getFile()).thenReturn(fileOnInfo); when(task.getFile()).thenReturn(fileOnInfo); when(info.getBlock(0)).thenReturn(blockInfo); when(blockInfo.getContentLength()).thenReturn(1L); assertThat(check.isInfoRightToResume()).isTrue(); }