@Test public void shouldOnlyUseTorznabIndexersForTorrentSearches() throws Exception { indexerConfigMock.setSearchModuleType(SearchModuleType.NEWZNAB); when(searchRequest.getDownloadType()).thenReturn(org.nzbhydra.searching.dtoseventsenums.DownloadType.TORRENT); assertFalse("Only torznab indexers should be used for torrent searches", testee.checkTorznabOnlyUsedForTorrentOrInternalSearches(indexer)); indexerConfigMock.setSearchModuleType(SearchModuleType.TORZNAB); when(searchRequest.getDownloadType()).thenReturn(org.nzbhydra.searching.dtoseventsenums.DownloadType.TORRENT); assertTrue("Torznab indexers should be used for torrent searches", testee.checkTorznabOnlyUsedForTorrentOrInternalSearches(indexer)); indexerConfigMock.setSearchModuleType(SearchModuleType.TORZNAB); when(searchRequest.getSource()).thenReturn(SearchSource.INTERNAL); when(searchRequest.getDownloadType()).thenReturn(org.nzbhydra.searching.dtoseventsenums.DownloadType.NZB); assertTrue("Torznab indexers should be selected for internal NZB searches", testee.checkTorznabOnlyUsedForTorrentOrInternalSearches(indexer)); indexerConfigMock.setSearchModuleType(SearchModuleType.TORZNAB); when(searchRequest.getSource()).thenReturn(SearchSource.API); when(searchRequest.getDownloadType()).thenReturn(DownloadType.NZB); assertFalse("Torznab indexers should not be selected for API NZB searches", testee.checkTorznabOnlyUsedForTorrentOrInternalSearches(indexer)); }
protected boolean checkTorznabOnlyUsedForTorrentOrInternalSearches(Indexer indexer) { if (searchRequest.getDownloadType() == DownloadType.TORRENT && indexer.getConfig().getSearchModuleType() != SearchModuleType.TORZNAB) { String message = String.format("Not using %s because a torrent search is requested", indexer.getName()); return handleIndexerNotSelected(indexer, message, "No torrent search"); } if (searchRequest.getDownloadType() == DownloadType.NZB && indexer.getConfig().getSearchModuleType() == SearchModuleType.TORZNAB && searchRequest.getSource() == SearchSource.API) { String message = String.format("Not using %s because torznab indexers cannot be used by API NZB searches", indexer.getName()); return handleIndexerNotSelected(indexer, message, "NZB API search"); } return true; }
IndexerForSearchSelector { protected boolean checkTorznabOnlyUsedForTorrentOrInternalSearches(Indexer indexer) { if (searchRequest.getDownloadType() == DownloadType.TORRENT && indexer.getConfig().getSearchModuleType() != SearchModuleType.TORZNAB) { String message = String.format("Not using %s because a torrent search is requested", indexer.getName()); return handleIndexerNotSelected(indexer, message, "No torrent search"); } if (searchRequest.getDownloadType() == DownloadType.NZB && indexer.getConfig().getSearchModuleType() == SearchModuleType.TORZNAB && searchRequest.getSource() == SearchSource.API) { String message = String.format("Not using %s because torznab indexers cannot be used by API NZB searches", indexer.getName()); return handleIndexerNotSelected(indexer, message, "NZB API search"); } return true; } }
IndexerForSearchSelector { protected boolean checkTorznabOnlyUsedForTorrentOrInternalSearches(Indexer indexer) { if (searchRequest.getDownloadType() == DownloadType.TORRENT && indexer.getConfig().getSearchModuleType() != SearchModuleType.TORZNAB) { String message = String.format("Not using %s because a torrent search is requested", indexer.getName()); return handleIndexerNotSelected(indexer, message, "No torrent search"); } if (searchRequest.getDownloadType() == DownloadType.NZB && indexer.getConfig().getSearchModuleType() == SearchModuleType.TORZNAB && searchRequest.getSource() == SearchSource.API) { String message = String.format("Not using %s because torznab indexers cannot be used by API NZB searches", indexer.getName()); return handleIndexerNotSelected(indexer, message, "NZB API search"); } return true; }  }
IndexerForSearchSelector { protected boolean checkTorznabOnlyUsedForTorrentOrInternalSearches(Indexer indexer) { if (searchRequest.getDownloadType() == DownloadType.TORRENT && indexer.getConfig().getSearchModuleType() != SearchModuleType.TORZNAB) { String message = String.format("Not using %s because a torrent search is requested", indexer.getName()); return handleIndexerNotSelected(indexer, message, "No torrent search"); } if (searchRequest.getDownloadType() == DownloadType.NZB && indexer.getConfig().getSearchModuleType() == SearchModuleType.TORZNAB && searchRequest.getSource() == SearchSource.API) { String message = String.format("Not using %s because torznab indexers cannot be used by API NZB searches", indexer.getName()); return handleIndexerNotSelected(indexer, message, "NZB API search"); } return true; }  IndexerForSearchSelection pickIndexers(SearchRequest searchRequest); }
IndexerForSearchSelector { protected boolean checkTorznabOnlyUsedForTorrentOrInternalSearches(Indexer indexer) { if (searchRequest.getDownloadType() == DownloadType.TORRENT && indexer.getConfig().getSearchModuleType() != SearchModuleType.TORZNAB) { String message = String.format("Not using %s because a torrent search is requested", indexer.getName()); return handleIndexerNotSelected(indexer, message, "No torrent search"); } if (searchRequest.getDownloadType() == DownloadType.NZB && indexer.getConfig().getSearchModuleType() == SearchModuleType.TORZNAB && searchRequest.getSource() == SearchSource.API) { String message = String.format("Not using %s because torznab indexers cannot be used by API NZB searches", indexer.getName()); return handleIndexerNotSelected(indexer, message, "NZB API search"); } return true; }  IndexerForSearchSelection pickIndexers(SearchRequest searchRequest); static final Pattern SCHEDULER_PATTERN; }