formatting changes only

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@885316 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2009-11-30 02:43:00 +00:00
parent 9f389a48a0
commit 0caebfc6b6
2 changed files with 351 additions and 302 deletions

View File

@ -80,7 +80,7 @@ public class SearchServiceImpl
this.search = search; this.search = search;
} }
@SuppressWarnings( "unchecked" ) @SuppressWarnings("unchecked")
public List<Artifact> quickSearch( String queryString ) public List<Artifact> quickSearch( String queryString )
throws Exception throws Exception
{ {
@ -94,9 +94,8 @@ public class SearchServiceImpl
for ( SearchResultHit resultHit : results.getHits() ) for ( SearchResultHit resultHit : results.getHits() )
{ {
// double-check all versions as done in SearchAction // double-check all versions as done in SearchAction
final List<String> versions = final List<String> versions = (List<String>) archivaDAO.query(
(List<String>) archivaDAO.query( new UniqueVersionConstraint( observableRepos, resultHit.getGroupId(), new UniqueVersionConstraint( observableRepos, resultHit.getGroupId(), resultHit.getArtifactId() ) );
resultHit.getArtifactId() ) );
if ( versions != null && !versions.isEmpty() ) if ( versions != null && !versions.isEmpty() )
{ {
resultHit.setVersion( null ); resultHit.setVersion( null );
@ -104,32 +103,37 @@ public class SearchServiceImpl
} }
List<String> resultHitVersions = resultHit.getVersions(); List<String> resultHitVersions = resultHit.getVersions();
if( resultHitVersions != null ) if ( resultHitVersions != null )
{ {
for( String version : resultHitVersions ) for ( String version : resultHitVersions )
{ {
try try
{ {
ArchivaProjectModel model = repoBrowsing.selectVersion( "", observableRepos, resultHit.getGroupId(), resultHit.getArtifactId(), version ); ArchivaProjectModel model =
repoBrowsing.selectVersion( "", observableRepos, resultHit.getGroupId(),
resultHit.getArtifactId(), version );
String repoId = repoBrowsing.getRepositoryId( "", observableRepos, resultHit.getGroupId(), resultHit.getArtifactId(), version ); String repoId = repoBrowsing.getRepositoryId( "", observableRepos, resultHit.getGroupId(),
resultHit.getArtifactId(), version );
Artifact artifact = null; Artifact artifact = null;
if( model == null ) if ( model == null )
{ {
artifact = new Artifact( repoId, resultHit.getGroupId(), resultHit.getArtifactId(), version, "jar" ); artifact = new Artifact( repoId, resultHit.getGroupId(), resultHit.getArtifactId(), version,
"jar" );
} }
else else
{ {
artifact = new Artifact( repoId, model.getGroupId(), model.getArtifactId(), version, model.getPackaging() ); artifact = new Artifact( repoId, model.getGroupId(), model.getArtifactId(), version,
model.getPackaging() );
} }
artifacts.add( artifact ); artifacts.add( artifact );
} }
catch( ObjectNotFoundException e ) catch ( ObjectNotFoundException e )
{ {
log.debug( "Unable to find pom artifact : " + e.getMessage() ); log.debug( "Unable to find pom artifact : " + e.getMessage() );
} }
catch( ArchivaDatabaseException e ) catch ( ArchivaDatabaseException e )
{ {
log.debug( "Error occurred while getting pom artifact from database : " + e.getMessage() ); log.debug( "Error occurred while getting pom artifact from database : " + e.getMessage() );
} }
@ -143,15 +147,15 @@ public class SearchServiceImpl
/** /**
* Remove timestamped snapshots from versions * Remove timestamped snapshots from versions
*/ */
private static List<String> filterTimestampedSnapshots(List<String> versions) private static List<String> filterTimestampedSnapshots( List<String> versions )
{ {
final List<String> filtered = new ArrayList<String>(); final List<String> filtered = new ArrayList<String>();
for (final String version : versions) for ( final String version : versions )
{ {
final String baseVersion = VersionUtil.getBaseVersion(version); final String baseVersion = VersionUtil.getBaseVersion( version );
if (!filtered.contains(baseVersion)) if ( !filtered.contains( baseVersion ) )
{ {
filtered.add(baseVersion); filtered.add( baseVersion );
} }
} }
return filtered; return filtered;
@ -171,11 +175,13 @@ public class SearchServiceImpl
ArtifactsByChecksumConstraint constraint = new ArtifactsByChecksumConstraint( checksum ); ArtifactsByChecksumConstraint constraint = new ArtifactsByChecksumConstraint( checksum );
List<ArchivaArtifact> artifacts = artifactDAO.queryArtifacts( constraint ); List<ArchivaArtifact> artifacts = artifactDAO.queryArtifacts( constraint );
for( ArchivaArtifact archivaArtifact : artifacts ) for ( ArchivaArtifact archivaArtifact : artifacts )
{ {
Artifact artifact = new Artifact( archivaArtifact.getModel().getRepositoryId(), archivaArtifact.getModel().getGroupId(), Artifact artifact =
archivaArtifact.getModel().getArtifactId(), archivaArtifact.getModel().getVersion(), archivaArtifact.getType() ); new Artifact( archivaArtifact.getModel().getRepositoryId(), archivaArtifact.getModel().getGroupId(),
//archivaArtifact.getModel().getWhenGathered() ); archivaArtifact.getModel().getArtifactId(), archivaArtifact.getModel().getVersion(),
archivaArtifact.getType() );
//archivaArtifact.getModel().getWhenGathered() );
results.add( artifact ); results.add( artifact );
} }
@ -190,12 +196,12 @@ public class SearchServiceImpl
final BrowsingResults results = repoBrowsing.selectArtifactId( "", observableRepos, groupId, artifactId ); final BrowsingResults results = repoBrowsing.selectArtifactId( "", observableRepos, groupId, artifactId );
for( final String version : results.getVersions() ) for ( final String version : results.getVersions() )
{ {
final Artifact artifact = new Artifact( "", groupId, artifactId, version, "pom" ); final Artifact artifact = new Artifact( "", groupId, artifactId, version, "pom" );
//ArchivaArtifact pomArtifact = artifactDAO.getArtifact( groupId, artifactId, version, "", "pom", ); //ArchivaArtifact pomArtifact = artifactDAO.getArtifact( groupId, artifactId, version, "", "pom", );
//Artifact artifact = new Artifact( "", groupId, artifactId, version, pomArtifact.getType() ); //Artifact artifact = new Artifact( "", groupId, artifactId, version, pomArtifact.getType() );
//pomArtifact.getModel().getWhenGathered() ); //pomArtifact.getModel().getWhenGathered() );
artifacts.add( artifact ); artifacts.add( artifact );
} }
@ -226,10 +232,11 @@ public class SearchServiceImpl
{ {
ArchivaProjectModel model = repoBrowsing.selectVersion( "", observableRepos, groupId, artifactId, version ); ArchivaProjectModel model = repoBrowsing.selectVersion( "", observableRepos, groupId, artifactId, version );
List<org.apache.maven.archiva.model.Dependency> modelDeps = model.getDependencies(); List<org.apache.maven.archiva.model.Dependency> modelDeps = model.getDependencies();
for( org.apache.maven.archiva.model.Dependency dep : modelDeps ) for ( org.apache.maven.archiva.model.Dependency dep : modelDeps )
{ {
Dependency dependency = new Dependency( Dependency dependency =
dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier(), dep.getType(), dep.getScope() ); new Dependency( dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier(),
dep.getType(), dep.getScope() );
dependencies.add( dependency ); dependencies.add( dependency );
} }
} }
@ -249,19 +256,19 @@ public class SearchServiceImpl
return a; return a;
} }
//get artifacts that depend on a given artifact //get artifacts that depend on a given artifact
public List<Artifact> getDependees( String groupId, String artifactId, String version ) public List<Artifact> getDependees( String groupId, String artifactId, String version )
throws Exception throws Exception
{ {
List<Artifact> artifacts = new ArrayList<Artifact>(); List<Artifact> artifacts = new ArrayList<Artifact>();
List<String> observableRepos = xmlRpcUserRepositories.getObservableRepositories(); List<String> observableRepos = xmlRpcUserRepositories.getObservableRepositories();
List<ArchivaProjectModel> dependees = repoBrowsing.getUsedBy( "", observableRepos, groupId, artifactId, version ); List<ArchivaProjectModel> dependees =
for( ArchivaProjectModel model : dependees ) repoBrowsing.getUsedBy( "", observableRepos, groupId, artifactId, version );
for ( ArchivaProjectModel model : dependees )
{ {
Artifact artifact = Artifact artifact = new Artifact( "", model.getGroupId(), model.getArtifactId(), model.getVersion(), "" );
new Artifact( "", model.getGroupId(), model.getArtifactId(), model.getVersion(), "" ); //model.getWhenIndexed() );
//model.getWhenIndexed() );
artifacts.add( artifact ); artifacts.add( artifact );
} }

View File

@ -85,23 +85,23 @@ public class SearchServiceImplTest
throws Exception throws Exception
{ {
userReposControl = MockClassControl.createControl( XmlRpcUserRepositories.class ); userReposControl = MockClassControl.createControl( XmlRpcUserRepositories.class );
userRepos = ( XmlRpcUserRepositories ) userReposControl.getMock(); userRepos = (XmlRpcUserRepositories) userReposControl.getMock();
archivaDAOControl = MockControl.createControl( ArchivaDAO.class ); archivaDAOControl = MockControl.createControl( ArchivaDAO.class );
archivaDAOControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER ); archivaDAOControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
archivaDAO = ( ArchivaDAO ) archivaDAOControl.getMock(); archivaDAO = (ArchivaDAO) archivaDAOControl.getMock();
repoBrowsingControl = MockControl.createControl( RepositoryBrowsing.class ); repoBrowsingControl = MockControl.createControl( RepositoryBrowsing.class );
repoBrowsing = ( RepositoryBrowsing ) repoBrowsingControl.getMock(); repoBrowsing = (RepositoryBrowsing) repoBrowsingControl.getMock();
searchControl = MockControl.createControl( RepositorySearch.class ); searchControl = MockControl.createControl( RepositorySearch.class );
searchControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER ); searchControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
search = ( RepositorySearch ) searchControl.getMock(); search = (RepositorySearch) searchControl.getMock();
searchService = new SearchServiceImpl( userRepos, archivaDAO, repoBrowsing, search ); searchService = new SearchServiceImpl( userRepos, archivaDAO, repoBrowsing, search );
artifactDAOControl = MockControl.createControl( ArtifactDAO.class ); artifactDAOControl = MockControl.createControl( ArtifactDAO.class );
artifactDAO = ( ArtifactDAO ) artifactDAOControl.getMock(); artifactDAO = (ArtifactDAO) artifactDAOControl.getMock();
} }
// MRM-1230 // MRM-1230
@ -128,10 +128,12 @@ public class SearchServiceImplTest
SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES ); SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ), results ); searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ),
results );
archivaDAOControl.expectAndReturn( archivaDAO.query( new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(), archivaDAOControl.expectAndReturn( archivaDAO.query(
resultHit.getArtifactId() ) ), null ); new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(), resultHit.getArtifactId() ) ),
null );
ArchivaProjectModel model = new ArchivaProjectModel(); ArchivaProjectModel model = new ArchivaProjectModel();
model.setGroupId( ARCHIVA_TEST_GROUP_ID ); model.setGroupId( ARCHIVA_TEST_GROUP_ID );
@ -139,9 +141,13 @@ public class SearchServiceImplTest
model.setVersion( "1.0" ); model.setVersion( "1.0" );
model.setPackaging( "war" ); model.setPackaging( "war" );
repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, "archiva-webapp", "1.0" ), model ); repoBrowsingControl.expectAndReturn(
repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, "archiva-webapp", "1.0" ),
model );
repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, "archiva-webapp", "1.0" ), "repo1.mirror" ); repoBrowsingControl.expectAndReturn(
repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, "archiva-webapp", "1.0" ),
"repo1.mirror" );
userReposControl.replay(); userReposControl.replay();
searchControl.replay(); searchControl.replay();
@ -191,16 +197,20 @@ public class SearchServiceImplTest
SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES ); SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ), results ); searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ),
results );
archivaDAOControl.expectAndReturn( archivaDAO.query( new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(), archivaDAOControl.expectAndReturn( archivaDAO.query(
resultHit.getArtifactId() ) ), null ); new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(), resultHit.getArtifactId() ) ),
null );
repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, repoBrowsingControl.expectAndReturn(
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), null ); repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
null );
repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, repoBrowsingControl.expectAndReturn(
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), null ); repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID,
"1.0" ), null );
userReposControl.replay(); userReposControl.replay();
searchControl.replay(); searchControl.replay();
@ -222,20 +232,21 @@ public class SearchServiceImplTest
assertEquals( ARCHIVA_TEST_ARTIFACT_ID, artifact.getArtifactId() ); assertEquals( ARCHIVA_TEST_ARTIFACT_ID, artifact.getArtifactId() );
assertEquals( "1.0", artifact.getVersion() ); assertEquals( "1.0", artifact.getVersion() );
assertEquals( "jar", artifact.getType() ); assertEquals( "jar", artifact.getType() );
assertNull( "Repository should be null since the model was not found in the database!", artifact.getRepositoryId() ); assertNull( "Repository should be null since the model was not found in the database!",
artifact.getRepositoryId() );
} }
/* /*
* quick/general text search which returns a list of artifacts * quick/general text search which returns a list of artifacts
* query for an artifact based on a checksum * query for an artifact based on a checksum
* query for all available versions of an artifact, sorted in version significance order * query for all available versions of an artifact, sorted in version significance order
* query for all available versions of an artifact since a given date * query for all available versions of an artifact since a given date
* query for an artifact's direct dependencies * query for an artifact's direct dependencies
* query for an artifact's dependency tree (as with mvn dependency:tree - no duplicates should be included) * query for an artifact's dependency tree (as with mvn dependency:tree - no duplicates should be included)
* query for all artifacts that depend on a given artifact * query for all artifacts that depend on a given artifact
*/ */
/* quick search */ /* quick search */
// public void testQuickSearchArtifactBytecodeSearch() // public void testQuickSearchArtifactBytecodeSearch()
// throws Exception // throws Exception
@ -305,12 +316,14 @@ public class SearchServiceImplTest
results.addHit( SearchUtil.getHitId( resultHit.getGroupId(), resultHit.getArtifactId() ), resultHit ); results.addHit( SearchUtil.getHitId( resultHit.getGroupId(), resultHit.getArtifactId() ), resultHit );
archivaDAOControl.expectAndReturn( archivaDAO.query( new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(), archivaDAOControl.expectAndReturn( archivaDAO.query(
resultHit.getArtifactId() ) ), null ); new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(), resultHit.getArtifactId() ) ),
null );
SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES ); SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ), results ); searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ),
results );
ArchivaProjectModel model = new ArchivaProjectModel(); ArchivaProjectModel model = new ArchivaProjectModel();
model.setGroupId( ARCHIVA_TEST_GROUP_ID ); model.setGroupId( ARCHIVA_TEST_GROUP_ID );
@ -318,11 +331,13 @@ public class SearchServiceImplTest
model.setVersion( "1.0" ); model.setVersion( "1.0" );
model.setPackaging( "jar" ); model.setPackaging( "jar" );
repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, repoBrowsingControl.expectAndReturn(
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), model ); repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
model );
repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, repoBrowsingControl.expectAndReturn(
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), "repo1.mirror" ); repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID,
"1.0" ), "repo1.mirror" );
userReposControl.replay(); userReposControl.replay();
searchControl.replay(); searchControl.replay();
@ -348,7 +363,7 @@ public class SearchServiceImplTest
assertEquals( "repo1.mirror", artifact.getRepositoryId() ); assertEquals( "repo1.mirror", artifact.getRepositoryId() );
} }
public void testQuickSearchNoResults( ) public void testQuickSearchNoResults()
throws Exception throws Exception
{ {
List<String> observableRepoIds = new ArrayList<String>(); List<String> observableRepoIds = new ArrayList<String>();
@ -360,7 +375,8 @@ public class SearchServiceImplTest
SearchResults results = new SearchResults(); SearchResults results = new SearchResults();
SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES ); SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "non-existent", limits, null ), results ); searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "non-existent", limits, null ),
results );
userReposControl.replay(); userReposControl.replay();
searchControl.replay(); searchControl.replay();
@ -382,7 +398,8 @@ public class SearchServiceImplTest
ArtifactsByChecksumConstraint constraint = new ArtifactsByChecksumConstraint( "a1b2c3aksjhdasfkdasasd" ); ArtifactsByChecksumConstraint constraint = new ArtifactsByChecksumConstraint( "a1b2c3aksjhdasfkdasasd" );
List<ArchivaArtifact> artifacts = new ArrayList<ArchivaArtifact>(); List<ArchivaArtifact> artifacts = new ArrayList<ArchivaArtifact>();
ArchivaArtifact artifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0", "", "jar", "test-repo" ); ArchivaArtifact artifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0", "", "jar", "test-repo" );
artifact.getModel().setWhenGathered( whenGathered ); artifact.getModel().setWhenGathered( whenGathered );
artifacts.add( artifact ); artifacts.add( artifact );
@ -427,47 +444,66 @@ public class SearchServiceImplTest
results.setVersions( versions ); results.setVersions( versions );
List<ArchivaArtifact> archivaArtifacts = new ArrayList<ArchivaArtifact>(); List<ArchivaArtifact> archivaArtifacts = new ArrayList<ArchivaArtifact>();
ArchivaArtifact archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 0 ), "", "pom", "repo1.mirror" ); ArchivaArtifact archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 0 ), "", "pom",
"repo1.mirror" );
archivaArtifact.getModel().setWhenGathered( whenGathered ); archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact ); archivaArtifacts.add( archivaArtifact );
archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 1 ), "", "pom", "public.releases" ); archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 1 ), "", "pom",
"public.releases" );
archivaArtifact.getModel().setWhenGathered( whenGathered ); archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact ); archivaArtifacts.add( archivaArtifact );
archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 2 ), "", "pom", "repo1.mirror" ); archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 2 ), "", "pom",
"repo1.mirror" );
archivaArtifact.getModel().setWhenGathered( whenGathered ); archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact ); archivaArtifacts.add( archivaArtifact );
archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 3 ), "", "pom", "public.releases" ); archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 3 ), "", "pom",
"public.releases" );
archivaArtifact.getModel().setWhenGathered( whenGathered ); archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact ); archivaArtifacts.add( archivaArtifact );
archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 4 ), "", "pom", "repo1.mirror" ); archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 4 ), "", "pom",
"repo1.mirror" );
archivaArtifact.getModel().setWhenGathered( whenGathered ); archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact ); archivaArtifacts.add( archivaArtifact );
archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 5 ), "", "pom", "public.releases" ); archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 5 ), "", "pom",
"public.releases" );
archivaArtifact.getModel().setWhenGathered( whenGathered ); archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact ); archivaArtifacts.add( archivaArtifact );
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
repoBrowsingControl.expectAndReturn( repoBrowsing.selectArtifactId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, repoBrowsingControl.expectAndReturn(
ARCHIVA_TEST_ARTIFACT_ID ), results ); repoBrowsing.selectArtifactId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID ),
results );
archivaDAOControl.expectAndReturn( archivaDAO.getArtifactDAO(), artifactDAO ); archivaDAOControl.expectAndReturn( archivaDAO.getArtifactDAO(), artifactDAO );
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, artifactDAOControl.expectAndDefaultReturn(
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 0 ), "", "pom", "repo1.mirror" ), archivaArtifacts.get( 0 ) ); artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 0 ), "", "pom",
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, "repo1.mirror" ), archivaArtifacts.get( 0 ) );
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 1 ), "", "pom", "public.releases" ), archivaArtifacts.get( 1 ) ); artifactDAOControl.expectAndDefaultReturn(
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 1 ), "", "pom",
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 2 ), "", "pom", "repo1.mirror" ), archivaArtifacts.get( 2 ) ); "public.releases" ), archivaArtifacts.get( 1 ) );
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, artifactDAOControl.expectAndDefaultReturn(
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 3 ), "", "pom", "public.releases" ), archivaArtifacts.get( 3 ) ); artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 2 ), "", "pom",
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, "repo1.mirror" ), archivaArtifacts.get( 2 ) );
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 4 ), "", "pom", "repo1.mirror" ), archivaArtifacts.get( 4 ) ); artifactDAOControl.expectAndDefaultReturn(
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 3 ), "", "pom",
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 5 ), "", "pom", "public.releases" ), archivaArtifacts.get( 5 ) ); "public.releases" ), archivaArtifacts.get( 3 ) );
artifactDAOControl.expectAndDefaultReturn(
artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 4 ), "", "pom",
"repo1.mirror" ), archivaArtifacts.get( 4 ) );
artifactDAOControl.expectAndDefaultReturn(
artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 5 ), "", "pom",
"public.releases" ), archivaArtifacts.get( 5 ) );
userReposControl.replay(); userReposControl.replay();
repoBrowsingControl.replay(); repoBrowsingControl.replay();
@ -528,12 +564,14 @@ public class SearchServiceImplTest
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
repoBrowsingControl.expectAndReturn( repoBrowsingControl.expectAndReturn(
repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), model ); repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
model );
repoBrowsingControl.replay(); repoBrowsingControl.replay();
userReposControl.replay(); userReposControl.replay();
List<Dependency> dependencies = searchService.getDependencies( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ); List<Dependency> dependencies =
searchService.getDependencies( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" );
repoBrowsingControl.verify(); repoBrowsingControl.verify();
userReposControl.verify(); userReposControl.verify();
@ -551,7 +589,8 @@ public class SearchServiceImplTest
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
repoBrowsingControl.expectAndThrow( repoBrowsingControl.expectAndThrow(
repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), new ObjectNotFoundException( "Artifact does not exist." ) ); repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
new ObjectNotFoundException( "Artifact does not exist." ) );
userReposControl.replay(); userReposControl.replay();
repoBrowsingControl.replay(); repoBrowsingControl.replay();
@ -606,8 +645,9 @@ public class SearchServiceImplTest
dependeeModels.add( dependeeModel ); dependeeModels.add( dependeeModel );
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
repoBrowsingControl.expectAndReturn( repoBrowsing.getUsedBy( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, repoBrowsingControl.expectAndReturn(
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), dependeeModels ); repoBrowsing.getUsedBy( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
dependeeModels );
repoBrowsingControl.replay(); repoBrowsingControl.replay();
userReposControl.replay(); userReposControl.replay();
@ -645,15 +685,17 @@ public class SearchServiceImplTest
dependeeModels.add( dependeeModel ); dependeeModels.add( dependeeModel );
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
repoBrowsingControl.expectAndReturn( repoBrowsing.getUsedBy( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, repoBrowsingControl.expectAndReturn(
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), null ); repoBrowsing.getUsedBy( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
null );
repoBrowsingControl.replay(); repoBrowsingControl.replay();
userReposControl.replay(); userReposControl.replay();
try try
{ {
List<Artifact> dependees = searchService.getDependees( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ); List<Artifact> dependees =
searchService.getDependees( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" );
fail( "An exception should have been thrown." ); fail( "An exception should have been thrown." );
} }
catch ( Exception e ) catch ( Exception e )