use of org.nzbhydra.config.Category in project nzbhydra2 by theotherp.
the class CategoryProviderTest method setUp.
@Before
public void setUp() throws Exception {
List<Category> categories = new ArrayList<>();
Category category = new Category();
category.setName("all");
category.setNewznabCategories(Collections.emptyList());
categories.add(category);
category = new Category();
category.setName("n/a");
category.setNewznabCategories(Collections.emptyList());
categories.add(category);
category = new Category();
category.setName("3000,3030");
category.setNewznabCategories(Arrays.asList(3000, 3030));
categories.add(category);
category = new Category();
category.setName("4000");
category.setNewznabCategories(Arrays.asList(4000));
categories.add(category);
category = new Category();
category.setName("4030");
category.setNewznabCategories(Arrays.asList(4030));
categories.add(category);
category = new Category();
category.setName("4090");
category.setSubtype(Subtype.COMIC);
category.setNewznabCategories(Arrays.asList(4090));
categories.add(category);
category = new Category();
category.setName("7020,8010");
category.setSubtype(Subtype.ANIME);
category.setNewznabCategories(Arrays.asList(7020, 8010));
categories.add(category);
BaseConfig baseConfig = new BaseConfig();
CategoriesConfig categoriesConfig = new CategoriesConfig();
categoriesConfig.setCategories(categories);
baseConfig.setCategoriesConfig(categoriesConfig);
testee.baseConfig = baseConfig;
testee.initialize();
}
use of org.nzbhydra.config.Category in project nzbhydra2 by theotherp.
the class SearcherUnitTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(searchResultEntityMock.getIndexer()).thenReturn(indexerEntity);
searcher.duplicateDetector = duplicateDetector;
when(indexer1.getName()).thenReturn("indexer1");
when(indexer2.getName()).thenReturn("indexer2");
when(indexer1.getConfig()).thenReturn(indexerConfigMock);
when(indexer2.getConfig()).thenReturn(indexerConfigMock);
when(indexer1.getIndexerEntity()).thenReturn(indexerEntity);
Category category = new Category();
category.setName("cat");
when(searchRequestMock.getCategory()).thenReturn(category);
when(searchRequestMock.getInternalData()).thenReturn(new InternalData());
when(indexerPicker.pickIndexers(any())).thenReturn(pickingResultMock);
when(indexerSearchRepository.findByIndexerEntityAndSearchEntity(any(), any())).thenReturn(indexerSearchEntityMock);
when(pickingResultMock.getSelectedIndexers()).thenReturn(Arrays.asList(indexer1));
when(duplicateDetector.detectDuplicates(any())).thenAnswer(new Answer<DuplicateDetectionResult>() {
@Override
public DuplicateDetectionResult answer(InvocationOnMock invocation) throws Throwable {
List<SearchResultItem> items = invocation.getArgument(0);
List<LinkedHashSet<SearchResultItem>> sets = items.stream().map(x -> {
return Sets.newLinkedHashSet(Arrays.asList(x));
}).collect(Collectors.toList());
return new DuplicateDetectionResult(sets, HashMultiset.create());
}
});
}
use of org.nzbhydra.config.Category in project nzbhydra2 by theotherp.
the class CategoryConverterTest method convertToEntityAttribute.
@Test
public void convertToEntityAttribute() throws Exception {
Category category = new Category();
when(categoryProviderMock.getByInternalName("name")).thenReturn(category);
assertThat(testee.convertToEntityAttribute("name"), is(category));
}
use of org.nzbhydra.config.Category in project nzbhydra2 by theotherp.
the class CategoryConverterTest method convertToDatabaseColumn.
@Test
public void convertToDatabaseColumn() throws Exception {
Category category = new Category();
category.setName("name");
assertThat(testee.convertToDatabaseColumn(category), is("name"));
}
use of org.nzbhydra.config.Category in project nzbhydra2 by theotherp.
the class SearchWeb method createSearchRequest.
private SearchRequest createSearchRequest(@RequestBody SearchRequestParameters parameters) {
Category category = categoryProvider.getByInternalName(parameters.getCategory());
SearchType searchType = category.getSearchType() == null ? SearchType.SEARCH : category.getSearchType();
SearchRequest searchRequest = searchRequestFactory.getSearchRequest(searchType, SearchSource.INTERNAL, category, parameters.getSearchRequestId(), parameters.getOffset(), parameters.getLimit());
searchRequest.setLoadAll(parameters.isLoadAll());
searchRequest.setIndexers(parameters.getIndexers());
searchRequest.setQuery(parameters.getQuery());
searchRequest.setMinage(parameters.getMinage());
searchRequest.setMaxage(parameters.getMaxage());
searchRequest.setMinsize(parameters.getMinsize());
searchRequest.setMaxsize(parameters.getMaxsize());
if (!Strings.isNullOrEmpty(parameters.getTitle())) {
searchRequest.setTitle(parameters.getTitle());
}
if (!Strings.isNullOrEmpty(parameters.getImdbId())) {
searchRequest.getIdentifiers().put(IdType.IMDB, parameters.getImdbId());
}
if (!Strings.isNullOrEmpty(parameters.getTmdbId())) {
searchRequest.getIdentifiers().put(IdType.TMDB, parameters.getTmdbId());
}
if (!Strings.isNullOrEmpty(parameters.getTvrageId())) {
searchRequest.getIdentifiers().put(IdType.TVRAGE, parameters.getTvrageId());
}
if (!Strings.isNullOrEmpty(parameters.getTvdbId())) {
searchRequest.getIdentifiers().put(IdType.TVDB, parameters.getTvdbId());
}
if (!Strings.isNullOrEmpty(parameters.getTvmazeId())) {
searchRequest.getIdentifiers().put(IdType.TVMAZE, parameters.getTvmazeId());
}
if (parameters.getSeason() != null) {
searchRequest.setSeason(parameters.getSeason());
}
if (!Strings.isNullOrEmpty(parameters.getEpisode())) {
searchRequest.setEpisode(parameters.getEpisode());
}
if (!searchRequest.getIdentifiers().isEmpty() && searchRequest.getQuery().isPresent()) {
// Add additional restrictions to required words
logger.debug("Adding additional search terms '{}' to required words", searchRequest.getQuery().get());
searchRequest.getInternalData().getRequiredWords().addAll(Splitter.on(" ").splitToList(searchRequest.getQuery().get()));
// Remove query, would be ignored by most indexers anyway
searchRequest.setQuery(null);
}
searchRequest = searchRequestFactory.extendWithSavedIdentifiers(searchRequest);
// Initialize messages for this search request
searchStates.put(searchRequest.getSearchRequestId(), new SearchState());
return searchRequest;
}
Aggregations