import org.apache.maven.archiva.database.constraints.UniqueVersionConstraint;
import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.security.UserRepositories;
-import org.codehaus.plexus.redback.users.UserManager;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
import org.easymock.MockControl;
private UserRepositories userRepos;
- private MockControl archivaXworkUserControl;
-
private MockControl searchControl;
private RepositorySearch search;
versions.add( "1.0" );
versions.add( "1.1" );
- archivaXworkUserControl.expectAndReturn( UserManager.GUEST_USERNAME, "user", 3 );
-
userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos, 2 );
searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, null ), results );
daoControl.expectAndReturn( dao.query( new UniqueVersionConstraint( selectedRepos, hit.getGroupId(), hit.getArtifactId() ) ), versions );
- archivaXworkUserControl.replay();
userReposControl.replay();
searchControl.replay();
daoControl.replay();
assertEquals( 1, action.getTotalPages() );
assertEquals( 1, action.getResults().getTotalHits() );
- archivaXworkUserControl.verify();
userReposControl.verify();
searchControl.verify();
daoControl.verify();
versions.add( "1.0" );
versions.add( "1.1" );
- archivaXworkUserControl.expectAndReturn( UserManager.GUEST_USERNAME, "user", 3 );
-
userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos, 2 );
searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, parsed ), results );
daoControl.expectAndReturn( dao.query( new UniqueVersionConstraint( selectedRepos, hit.getGroupId(), hit.getArtifactId() ) ), versions );
- archivaXworkUserControl.replay();
userReposControl.replay();
searchControl.replay();
daoControl.replay();
assertEquals( 1, action.getTotalPages() );
assertEquals( 1, action.getResults().getTotalHits() );
- archivaXworkUserControl.verify();
userReposControl.verify();
searchControl.verify();
daoControl.verify();
List<String> selectedRepos = new ArrayList<String>();
- archivaXworkUserControl.expectAndReturn( UserManager.GUEST_USERNAME, "user" );
-
userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
- archivaXworkUserControl.replay();
userReposControl.replay();
String result = action.quickSearch();
assertEquals( GlobalResults.ACCESS_TO_NO_REPOS, result );
- archivaXworkUserControl.verify();
userReposControl.verify();
}
SearchResults results = new SearchResults();
- archivaXworkUserControl.expectAndReturn( UserManager.GUEST_USERNAME, "user", 2 );
-
userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, null ), results );
- archivaXworkUserControl.replay();
userReposControl.replay();
searchControl.replay();
assertEquals( Action.INPUT, result );
- archivaXworkUserControl.verify();
userReposControl.verify();
searchControl.verify();
}
SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
- archivaXworkUserControl.expectAndReturn( UserManager.GUEST_USERNAME, "user" );
-
searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
- archivaXworkUserControl.replay();
searchControl.replay();
String result = action.filteredSearch();
assertEquals( 1, action.getTotalPages() );
assertEquals( 1, action.getResults().getTotalHits() );
- archivaXworkUserControl.verify();
searchControl.verify();
}
SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
- archivaXworkUserControl.expectAndReturn( UserManager.GUEST_USERNAME, "user", 2 );
-
userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
- archivaXworkUserControl.replay();
searchControl.replay();
userReposControl.replay();
assertEquals( 1, action.getTotalPages() );
assertEquals( 1, action.getResults().getTotalHits() );
- archivaXworkUserControl.verify();
searchControl.verify();
userReposControl.verify();
}
SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
- archivaXworkUserControl.expectAndReturn( UserManager.GUEST_USERNAME, "user" );
-
searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
- archivaXworkUserControl.replay();
searchControl.replay();
String result = action.filteredSearch();
assertFalse( action.getActionErrors().isEmpty() );
assertEquals( "No results found",( String ) action.getActionErrors().iterator().next() );
- archivaXworkUserControl.verify();
searchControl.verify();
}