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