DefaultDownloaderFactory implements DownloaderFactory { @Override public Downloader createDownloader(DownloadRequest request) { switch (request.type) { case DownloadRequest.TYPE_PROGRESSIVE: return new ProgressiveDownloader( request.uri, request.customCacheKey, downloaderConstructorHelper); case DownloadRequest.TYPE_DASH: return createDownloader(request, DASH_DOWNLOADER_CONSTRUCTOR); case DownloadRequest.TYPE_HLS: return createDownloader(request, HLS_DOWNLOADER_CONSTRUCTOR); case DownloadRequest.TYPE_SS: return createDownloader(request, SS_DOWNLOADER_CONSTRUCTOR); default: throw new IllegalArgumentException("Unsupported type: " + request.type); } } DefaultDownloaderFactory(DownloaderConstructorHelper downloaderConstructorHelper); @Override Downloader createDownloader(DownloadRequest request);  }
@Test public void createProgressiveDownloader() throws Exception { DownloaderConstructorHelper constructorHelper = new DownloaderConstructorHelper(Mockito.mock(Cache.class), DummyDataSource.FACTORY); DownloaderFactory factory = new DefaultDownloaderFactory(constructorHelper); Downloader downloader = factory.createDownloader( new DownloadRequest( "id", DownloadRequest.TYPE_PROGRESSIVE, Uri.parse("https: Collections.emptyList(), null, null)); assertThat(downloader).isInstanceOf(ProgressiveDownloader.class); }