BitTorrentDownloadManager { public void registerDownloadListener(DownloadListener listener) { requireNonNull(listener, "listener must not be null"); if (downloadListener != null) { throw new IllegalStateException("download listener is already registered"); } downloadListener = listener; registerBroadcastReceivers(); } BitTorrentDownloadManager(Context context); void registerDownloadListener(DownloadListener listener); void unregisterDownloadListener(DownloadListener listener); void enqueue(DownloadRequest downloadRequest); void abort();  }
@Test public void testRegisterDownloadListenerWithNull() { BitTorrentDownloadManager manager = new BitTorrentDownloadManager(RuntimeEnvironment.application); try { manager.registerDownloadListener(null); failBecauseExceptionWasNotThrown(NullPointerException.class); } catch (NullPointerException expectedException) { } }
@Test public void testRegisterDownloadListenerTwice() { BitTorrentDownloadManager manager = new BitTorrentDownloadManager(RuntimeEnvironment.application); DownloadListener downloadListener = Mockito.mock(DownloadListener.class); manager.registerDownloadListener(downloadListener); try { manager.registerDownloadListener(downloadListener); failBecauseExceptionWasNotThrown(IllegalStateException.class); } catch (IllegalStateException expectedException) { } }