use of org.apache.maven.index.FlatSearchRequest in project archiva by apache.
the class DownloadRemoteIndexTaskTest method downloadAndMergeRemoteIndexInEmptyIndex.
@Test
public void downloadAndMergeRemoteIndexInEmptyIndex() throws Exception {
RemoteRepository remoteRepository = getRemoteRepository();
remoteRepositoryAdmin.addRemoteRepository(remoteRepository, null);
downloadRemoteIndexScheduler.startup();
downloadRemoteIndexScheduler.scheduleDownloadRemote("test-repo-re", true, true);
((ThreadPoolTaskScheduler) downloadRemoteIndexScheduler.getTaskScheduler()).getScheduledExecutor().awaitTermination(10, TimeUnit.SECONDS);
remoteRepositoryAdmin.deleteRemoteRepository("test-repo-re", null);
// search
BooleanQuery.Builder iQuery = new BooleanQuery.Builder();
iQuery.add(indexer.constructQuery(MAVEN.GROUP_ID, new StringSearchExpression("commons-logging")), BooleanClause.Occur.SHOULD);
remoteRepositoryAdmin.addRemoteRepository(remoteRepository, null);
FlatSearchRequest rq = new FlatSearchRequest(iQuery.build());
rq.setContexts(Arrays.asList(repositoryRegistry.getRemoteRepository(remoteRepository.getId()).getIndexingContext().getBaseContext(IndexingContext.class)));
FlatSearchResponse response = indexer.searchFlat(rq);
log.info("returned hit count:{}", response.getReturnedHitsCount());
assertThat(response.getReturnedHitsCount()).isEqualTo(8);
}
Aggregations