List<String> indexingContextIds = addIndexingContexts(searchFields.getRepositories());
+ // if no index found in the specified one return an empty search result instead of doing a search on all index
+ // olamy: IMHO doesn't make sense
+ if (indexingContextIds == null || indexingContextIds.isEmpty() )
+ {
+ return new SearchResults();
+ }
+
BooleanQuery q = new BooleanQuery();
if ( StringUtils.isNotBlank(searchFields.getGroupId()) )
{
assertTrue( groupIds.contains( "org.apache.felix") );
assertTrue( groupIds.contains( "org.apache.archiva" ) );
}
+
+ @Test
+ public void testSearchWithUnknownRepo()
+ throws Exception
+ {
+ createIndexContainingMoreArtifacts( true );
+
+ List<String> selectedRepos = Arrays.asList( "foo" );
+
+ SearchFields searchFields = new SearchFields();
+ searchFields.setClassName( "SomeClass" );
+ searchFields.setRepositories( selectedRepos );
+
+ archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 );
+
+ archivaConfigControl.replay();
+
+ SearchResults results = search.search( "user", searchFields, null );
+
+ archivaConfigControl.verify();
+
+ assertNotNull( results );
+ assertEquals( 0, results.getHits().size() );
+ }
}