use of org.nzbhydra.searching.searchrequests.InternalData 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());
}
});
}
Aggregations