ReleaseDownloaderFactory { public static ReleaseDownloader create(Context context, ReleaseDetails releaseDetails, ReleaseDownloader.Listener listener) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return new HttpConnectionReleaseDownloader(context, releaseDetails, listener); } return new DownloadManagerReleaseDownloader(context, releaseDetails, listener); }  static ReleaseDownloader create(Context context, ReleaseDetails releaseDetails, ReleaseDownloader.Listener listener);  }
@Test public void createOnLollipop() throws Exception { TestUtils.setInternalState(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.LOLLIPOP); ReleaseDownloader releaseDownloader = ReleaseDownloaderFactory.create(mockContext, mockReleaseDetails, mockReleaseDownloaderListener); assertThat(releaseDownloader, instanceOf(DownloadManagerReleaseDownloader.class)); }
@Test public void createOnJellyBean() throws Exception { TestUtils.setInternalState(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.JELLY_BEAN); ReleaseDownloader releaseDownloader = ReleaseDownloaderFactory.create(mockContext, mockReleaseDetails, mockReleaseDownloaderListener); assertThat(releaseDownloader, instanceOf(HttpConnectionReleaseDownloader.class)); }