RetriableFileCopyCommand extends RetriableCommand { @VisibleForTesting long getNumBytesToRead(long fileLength, long position, long bufLength) { if (position + bufLength < fileLength) { return bufLength; } else { return fileLength - position; } } RetriableFileCopyCommand(String description, FileAction action);  RetriableFileCopyCommand(boolean skipCrc, String description,
      FileAction action);  RetriableFileCopyCommand(boolean skipCrc, String description,
          FileAction action, boolean directWrite);   }
@Test(timeout = 40000) public void testGetNumBytesToRead() { long pos = 100; long buffLength = 1024; long fileLength = 2058; RetriableFileCopyCommand retriableFileCopyCommand = new RetriableFileCopyCommand("Testing NumBytesToRead ", FileAction.OVERWRITE); long numBytes = retriableFileCopyCommand .getNumBytesToRead(fileLength, pos, buffLength); Assert.assertEquals(1024, numBytes); pos += numBytes; numBytes = retriableFileCopyCommand .getNumBytesToRead(fileLength, pos, buffLength); Assert.assertEquals(934, numBytes); pos += numBytes; numBytes = retriableFileCopyCommand .getNumBytesToRead(fileLength, pos, buffLength); Assert.assertEquals(0, numBytes); }