Search in sources :

Example 1 with InternalData

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());
        }
    });
}
Also used : Category(org.nzbhydra.config.Category) InvocationOnMock(org.mockito.invocation.InvocationOnMock) InternalData(org.nzbhydra.searching.searchrequests.InternalData) ArrayList(java.util.ArrayList) List(java.util.List) Before(org.junit.Before)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Category (org.nzbhydra.config.Category)1 InternalData (org.nzbhydra.searching.searchrequests.InternalData)1