DownloadEndBroadcast { public static Intent createIntent(String torrentFile, int downloadState) { return new DownloadEndBroadcast() .setTorrentFile(torrentFile) .setDownloadState(downloadState) .createIntent(); } DownloadEndBroadcast(); static Intent createIntent(String torrentFile, int downloadState); DownloadEndBroadcast setTorrentFile(String torrentFile); DownloadEndBroadcast setDownloadState(int downloadState); Intent createIntent();  }
@Test public void testBroadcastWithOutData() { DownloadEndBroadcast downloadEndBroadcast = new DownloadEndBroadcast(); try { downloadEndBroadcast.createIntent(); failBecauseExceptionWasNotThrown(IllegalStateException.class); } catch (IllegalStateException expectedException) { } }
@Test public void testCreateIntent() { final String torrentFile = "file"; final int downloadState = 42; DownloadEndBroadcast downloadEndBroadcast = new DownloadEndBroadcast(); downloadEndBroadcast.setTorrentFile(torrentFile); downloadEndBroadcast.setDownloadState(downloadState); Intent intent = downloadEndBroadcast.createIntent(); assertThat(intent.getAction()).isEqualTo(BitTorrentIntentConstants.ACTION_BROADCAST_END); assertThat(intent.getStringExtra(BitTorrentIntentConstants.EXTRA_TORRENT_FILE)) .isEqualToIgnoringCase(torrentFile); assertThat(intent.getIntExtra(BitTorrentIntentConstants.EXTRA_DOWNLOAD_STATE, -1)) .isEqualTo(downloadState); }