HttpConnectionReleaseDownloader extends AbstractReleaseDownloader { @Nullable @WorkerThread File getTargetFile() { if (mTargetFile == null) { File downloadsDirectory = mContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS); if (downloadsDirectory != null) { mTargetFile = new File(downloadsDirectory, mReleaseDetails.getReleaseHash() + ".apk"); } } return mTargetFile; } HttpConnectionReleaseDownloader(@NonNull Context context, @NonNull ReleaseDetails releaseDetails, @NonNull Listener listener); @Override synchronized boolean isDownloading(); @AnyThread @Override synchronized void resume(); @Override synchronized void cancel();  }
@Test public void getTargetFile() { assertNotNull(mReleaseDownloader.getTargetFile()); assertNotNull(mReleaseDownloader.getTargetFile()); verify(mContext).getExternalFilesDir(anyString()); }
@Test public void downloadDirectoryNotAvailable() { when(mContext.getExternalFilesDir(anyString())).thenReturn(null); assertNull(mReleaseDownloader.getTargetFile()); }