]> source.dussan.org Git - archiva.git/commitdiff
fix unit tests in webapp
authorOlivier Lamy <olamy@apache.org>
Fri, 7 Oct 2011 10:41:33 +0000 (10:41 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 7 Oct 2011 10:41:33 +0000 (10:41 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1179994 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/SearchActionTest.java

index d46e880f1345e929bf62d1ac034feafcd1cb3ab6..66ff41598be41db0fe5090ae250ea9ec7e0c44eb 100644 (file)
@@ -21,6 +21,7 @@ package org.apache.archiva.web.action;
 
 import com.opensymphony.xwork2.Action;
 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.indexer.search.RepositorySearch;
 import org.apache.archiva.indexer.search.SearchFields;
 import org.apache.archiva.indexer.search.SearchResultHit;
@@ -30,9 +31,8 @@ import org.apache.archiva.indexer.util.SearchUtil;
 import org.apache.archiva.metadata.model.ArtifactMetadata;
 import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.webtest.memory.TestRepositorySessionFactory;
 import org.apache.archiva.security.UserRepositories;
-import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.webtest.memory.TestRepositorySessionFactory;
 import org.easymock.MockControl;
 
 import java.util.ArrayList;
@@ -79,30 +79,30 @@ public class SearchActionTest
 
         action = new SearchAction();
 
-        session = mock( RepositorySession.class );
+        session = mock(RepositorySession.class);
         //TestRepositorySessionFactory factory = (TestRepositorySessionFactory) lookup( RepositorySessionFactory.class );
         TestRepositorySessionFactory factory = new TestRepositorySessionFactory();
-        factory.setRepositorySession( session );
-        action.setRepositorySessionFactory( factory );
+        factory.setRepositorySession(session);
+        action.setRepositorySessionFactory(factory);
 
-        MockControl archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
+        MockControl archivaConfigControl = MockControl.createControl(ArchivaConfiguration.class);
         ArchivaConfiguration archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
 
-        userReposControl = MockControl.createControl( UserRepositories.class );
+        userReposControl = MockControl.createControl(UserRepositories.class);
         userRepos = (UserRepositories) userReposControl.getMock();
 
-        searchControl = MockControl.createControl( RepositorySearch.class );
-        searchControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+        searchControl = MockControl.createControl(RepositorySearch.class);
+        searchControl.setDefaultMatcher(MockControl.ALWAYS_MATCHER);
         search = (RepositorySearch) searchControl.getMock();
 
-        repoAdminControl = MockControl.createControl( ManagedRepositoryAdmin.class );
+        repoAdminControl = MockControl.createControl(ManagedRepositoryAdmin.class);
         managedRepositoryAdmin = (ManagedRepositoryAdmin) repoAdminControl.getMock();
 
         //( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfig );
 
-        action.setManagedRepositoryAdmin( managedRepositoryAdmin );
-        action.setUserRepositories( userRepos );
-        action.setNexusSearch( search );
+        action.setManagedRepositoryAdmin(managedRepositoryAdmin);
+        action.setUserRepositories(userRepos);
+        action.setNexusSearch(search);
     }
 
     // quick search...
@@ -110,43 +110,44 @@ public class SearchActionTest
     public void testQuickSearch()
         throws Exception
     {
-        action.setQ( "archiva" );
-        action.setCurrentPage( 0 );
-        action.setSearchResultsOnly( false );
-        action.setCompleteQueryString( "" );
+        action.setQ("archiva");
+        action.setCurrentPage(0);
+        action.setSearchResultsOnly(false);
+        action.setCompleteQueryString("");
 
         List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
-        selectedRepos.add( "snapshots" );
+        selectedRepos.add("internal");
+        selectedRepos.add("snapshots");
 
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
+        SearchResultLimits limits = new SearchResultLimits(action.getCurrentPage());
+        limits.setPageSize(30);
 
         SearchResultHit hit = new SearchResultHit();
-        hit.setGroupId( "org.apache.archiva" );
-        hit.setArtifactId( "archiva-configuration" );
-        hit.setUrl( "url" );
-        hit.addVersion( "1.0" );
-        hit.addVersion( "1.1" );
+        hit.setGroupId("org.apache.archiva");
+        hit.setArtifactId("archiva-configuration");
+        hit.setUrl("url");
+        hit.addVersion("1.0");
+        hit.addVersion("1.1");
 
         SearchResults results = new SearchResults();
-        results.setLimits( limits );
-        results.setTotalHits( 1 );
-        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
+        results.setLimits(limits);
+        results.setTotalHits(1);
+        results.addHit(SearchUtil.getHitId("org.apache.archiva", "archiva-configuration", null, "jar"), hit);
+        results.setTotalHitsMapSize( results.getHitsMap().values().size() );
 
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
+        userReposControl.expectAndReturn(userRepos.getObservableRepositoryIds("user"), selectedRepos);
 
-        searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, null ), results );
+        searchControl.expectAndReturn(search.search("user", selectedRepos, "archiva", limits, null), results);
 
         userReposControl.replay();
         searchControl.replay();
 
-        action.setPrincipal( "user" );
+        action.setPrincipal("user");
         String result = action.quickSearch();
 
-        assertEquals( Action.SUCCESS, result );
-        assertEquals( 1, action.getTotalPages() );
-        assertEquals( 1, action.getResults().getTotalHits() );
+        assertEquals(Action.SUCCESS, result);
+        assertEquals("total pages not 1", 1, action.getTotalPages());
+        assertEquals("totol hits not 1", 1, action.getResults().getTotalHits());
 
         userReposControl.verify();
         searchControl.verify();
@@ -155,48 +156,48 @@ public class SearchActionTest
     public void testSearchWithinSearchResults()
         throws Exception
     {
-        action.setQ( "archiva" );
-        action.setCurrentPage( 0 );
-        action.setSearchResultsOnly( true );
-        action.setCompleteQueryString( "org;apache" );
+        action.setQ("archiva");
+        action.setCurrentPage(0);
+        action.setSearchResultsOnly(true);
+        action.setCompleteQueryString("org;apache");
 
         List<String> parsed = new ArrayList<String>();
-        parsed.add( "org" );
-        parsed.add( "apache" );
+        parsed.add("org");
+        parsed.add("apache");
 
         List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
-        selectedRepos.add( "snapshots" );
+        selectedRepos.add("internal");
+        selectedRepos.add("snapshots");
 
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
+        SearchResultLimits limits = new SearchResultLimits(action.getCurrentPage());
+        limits.setPageSize(30);
 
         SearchResultHit hit = new SearchResultHit();
-        hit.setGroupId( "org.apache.archiva" );
-        hit.setArtifactId( "archiva-configuration" );
-        hit.setUrl( "url" );
-        hit.addVersion( "1.0" );
-        hit.addVersion( "1.1" );
+        hit.setGroupId("org.apache.archiva");
+        hit.setArtifactId("archiva-configuration");
+        hit.setUrl("url");
+        hit.addVersion("1.0");
+        hit.addVersion("1.1");
 
         SearchResults results = new SearchResults();
-        results.setLimits( limits );
-        results.setTotalHits( 1 );
-        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
-
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
+        results.setLimits(limits);
+        results.setTotalHits(1);
+        results.addHit(SearchUtil.getHitId("org.apache.archiva", "archiva-configuration", null, "jar"), hit);
+        results.setTotalHitsMapSize( results.getHitsMap().values().size() );
+        userReposControl.expectAndReturn(userRepos.getObservableRepositoryIds("user"), selectedRepos);
 
-        searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, parsed ), results );
+        searchControl.expectAndReturn(search.search("user", selectedRepos, "archiva", limits, parsed), results);
 
         userReposControl.replay();
         searchControl.replay();
 
-        action.setPrincipal( "user" );
+        action.setPrincipal("user");
         String result = action.quickSearch();
 
-        assertEquals( Action.SUCCESS, result );
-        assertEquals( "org;apache;archiva", action.getCompleteQueryString() );
-        assertEquals( 1, action.getTotalPages() );
-        assertEquals( 1, action.getResults().getTotalHits() );
+        assertEquals(Action.SUCCESS, result);
+        assertEquals("org;apache;archiva", action.getCompleteQueryString());
+        assertEquals(1, action.getTotalPages());
+        assertEquals(1, action.getResults().getTotalHits());
 
         userReposControl.verify();
         searchControl.verify();
@@ -205,19 +206,19 @@ public class SearchActionTest
     public void testQuickSearchUserHasNoAccessToAnyRepository()
         throws Exception
     {
-        action.setQ( "archiva" );
-        action.setCurrentPage( 0 );
+        action.setQ("archiva");
+        action.setCurrentPage(0);
 
         List<String> selectedRepos = new ArrayList<String>();
 
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
+        userReposControl.expectAndReturn(userRepos.getObservableRepositoryIds("user"), selectedRepos);
 
         userReposControl.replay();
 
-        action.setPrincipal( "user" );
+        action.setPrincipal("user");
         String result = action.quickSearch();
 
-        assertEquals( GlobalResults.ACCESS_TO_NO_REPOS, result );
+        assertEquals(GlobalResults.ACCESS_TO_NO_REPOS, result);
 
         userReposControl.verify();
     }
@@ -225,31 +226,31 @@ public class SearchActionTest
     public void testQuickSearchNoSearchHits()
         throws Exception
     {
-        action.setQ( "archiva" );
-        action.setCurrentPage( 0 );
-        action.setSearchResultsOnly( false );
-        action.setCompleteQueryString( "" );
+        action.setQ("archiva");
+        action.setCurrentPage(0);
+        action.setSearchResultsOnly(false);
+        action.setCompleteQueryString("");
 
         List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
-        selectedRepos.add( "snapshots" );
+        selectedRepos.add("internal");
+        selectedRepos.add("snapshots");
 
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
+        SearchResultLimits limits = new SearchResultLimits(action.getCurrentPage());
+        limits.setPageSize(30);
 
         SearchResults results = new SearchResults();
 
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
+        userReposControl.expectAndReturn(userRepos.getObservableRepositoryIds("user"), selectedRepos);
 
-        searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, null ), results );
+        searchControl.expectAndReturn(search.search("user", selectedRepos, "archiva", limits, null), results);
 
         userReposControl.replay();
         searchControl.replay();
 
-        action.setPrincipal( "user" );
+        action.setPrincipal("user");
         String result = action.quickSearch();
 
-        assertEquals( Action.INPUT, result );
+        assertEquals(Action.INPUT, result);
 
         userReposControl.verify();
         searchControl.verify();
@@ -261,45 +262,45 @@ public class SearchActionTest
         throws Exception
     {
         List<String> managedRepos = new ArrayList<String>();
-        managedRepos.add( "internal" );
-        managedRepos.add( "snapshots" );
+        managedRepos.add("internal");
+        managedRepos.add("snapshots");
 
-        action.setRepositoryId( "internal" );
-        action.setManagedRepositoryList( managedRepos );
-        action.setCurrentPage( 0 );
-        action.setRowCount( 30 );
-        action.setGroupId( "org" );
+        action.setRepositoryId("internal");
+        action.setManagedRepositoryList(managedRepos);
+        action.setCurrentPage(0);
+        action.setRowCount(30);
+        action.setGroupId("org");
 
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
+        SearchResultLimits limits = new SearchResultLimits(action.getCurrentPage());
+        limits.setPageSize(30);
 
         SearchResultHit hit = new SearchResultHit();
-        hit.setGroupId( "org.apache.archiva" );
-        hit.setArtifactId( "archiva-configuration" );
-        hit.setUrl( "url" );
-        hit.addVersion( "1.0" );
-        hit.addVersion( "1.1" );
+        hit.setGroupId("org.apache.archiva");
+        hit.setArtifactId("archiva-configuration");
+        hit.setUrl("url");
+        hit.addVersion("1.0");
+        hit.addVersion("1.1");
 
         SearchResults results = new SearchResults();
-        results.setLimits( limits );
-        results.setTotalHits( 1 );
-        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
+        results.setLimits(limits);
+        results.setTotalHits(1);
+        results.addHit(SearchUtil.getHitId("org.apache.archiva", "archiva-configuration", null, "jar"), hit);
 
         List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
-        selectedRepos.add( "snapshots" );
+        selectedRepos.add("internal");
+        selectedRepos.add("snapshots");
 
-        SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
+        SearchFields searchFields = new SearchFields("org", null, null, null, null, selectedRepos);
 
-        searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
+        searchControl.expectAndReturn(search.search("user", searchFields, limits), results);
 
         searchControl.replay();
 
         String result = action.filteredSearch();
 
-        assertEquals( Action.SUCCESS, result );
-        assertEquals( 1, action.getTotalPages() );
-        assertEquals( 1, action.getResults().getTotalHits() );
+        assertEquals(Action.SUCCESS, result);
+        assertEquals(1, action.getTotalPages());
+        assertEquals(1, action.getResults().getTotalHits());
 
         searchControl.verify();
     }
@@ -308,48 +309,48 @@ public class SearchActionTest
         throws Exception
     {
         List<String> managedRepos = new ArrayList<String>();
-        managedRepos.add( "internal" );
-        managedRepos.add( "snapshots" );
+        managedRepos.add("internal");
+        managedRepos.add("snapshots");
 
-        action.setRepositoryId( "all" );
-        action.setManagedRepositoryList( managedRepos );
-        action.setCurrentPage( 0 );
-        action.setRowCount( 30 );
-        action.setGroupId( "org" );
+        action.setRepositoryId("all");
+        action.setManagedRepositoryList(managedRepos);
+        action.setCurrentPage(0);
+        action.setRowCount(30);
+        action.setGroupId("org");
 
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
+        SearchResultLimits limits = new SearchResultLimits(action.getCurrentPage());
+        limits.setPageSize(30);
 
         SearchResultHit hit = new SearchResultHit();
-        hit.setGroupId( "org.apache.archiva" );
-        hit.setArtifactId( "archiva-configuration" );
-        hit.setUrl( "url" );
-        hit.addVersion( "1.0" );
-        hit.addVersion( "1.1" );
+        hit.setGroupId("org.apache.archiva");
+        hit.setArtifactId("archiva-configuration");
+        hit.setUrl("url");
+        hit.addVersion("1.0");
+        hit.addVersion("1.1");
 
         SearchResults results = new SearchResults();
-        results.setLimits( limits );
-        results.setTotalHits( 1 );
-        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
+        results.setLimits(limits);
+        results.setTotalHits(1);
+        results.addHit(SearchUtil.getHitId("org.apache.archiva", "archiva-configuration", null, "jar"), hit);
 
         List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
+        selectedRepos.add("internal");
 
-        SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
+        SearchFields searchFields = new SearchFields("org", null, null, null, null, selectedRepos);
 
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
+        userReposControl.expectAndReturn(userRepos.getObservableRepositoryIds("user"), selectedRepos);
 
-        searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
+        searchControl.expectAndReturn(search.search("user", searchFields, limits), results);
 
         searchControl.replay();
         userReposControl.replay();
 
-        action.setPrincipal( "user" );
+        action.setPrincipal("user");
         String result = action.filteredSearch();
 
-        assertEquals( Action.SUCCESS, result );
-        assertEquals( 1, action.getTotalPages() );
-        assertEquals( 1, action.getResults().getTotalHits() );
+        assertEquals(Action.SUCCESS, result);
+        assertEquals(1, action.getTotalPages());
+        assertEquals(1, action.getResults().getTotalHits());
 
         searchControl.verify();
         userReposControl.verify();
@@ -359,35 +360,35 @@ public class SearchActionTest
         throws Exception
     {
         List<String> managedRepos = new ArrayList<String>();
-        managedRepos.add( "internal" );
-        managedRepos.add( "snapshots" );
+        managedRepos.add("internal");
+        managedRepos.add("snapshots");
 
-        action.setRepositoryId( "internal" );
-        action.setManagedRepositoryList( managedRepos );
-        action.setCurrentPage( 0 );
-        action.setRowCount( 30 );
-        action.setGroupId( "org" );
+        action.setRepositoryId("internal");
+        action.setManagedRepositoryList(managedRepos);
+        action.setCurrentPage(0);
+        action.setRowCount(30);
+        action.setGroupId("org");
 
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
+        SearchResultLimits limits = new SearchResultLimits(action.getCurrentPage());
+        limits.setPageSize(30);
 
         SearchResults results = new SearchResults();
 
         List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
-        selectedRepos.add( "snapshots" );
+        selectedRepos.add("internal");
+        selectedRepos.add("snapshots");
 
-        SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
+        SearchFields searchFields = new SearchFields("org", null, null, null, null, selectedRepos);
 
-        searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
+        searchControl.expectAndReturn(search.search("user", searchFields, limits), results);
 
         searchControl.replay();
 
         String result = action.filteredSearch();
 
-        assertEquals( Action.INPUT, result );
-        assertFalse( action.getActionErrors().isEmpty() );
-        assertEquals( "No results found", (String) action.getActionErrors().iterator().next() );
+        assertEquals(Action.INPUT, result);
+        assertFalse(action.getActionErrors().isEmpty());
+        assertEquals("No results found", (String) action.getActionErrors().iterator().next());
 
         searchControl.verify();
     }
@@ -397,12 +398,12 @@ public class SearchActionTest
     {
         List<String> managedRepos = new ArrayList<String>();
 
-        action.setGroupId( "org.apache.archiva" );
-        action.setManagedRepositoryList( managedRepos );
+        action.setGroupId("org.apache.archiva");
+        action.setManagedRepositoryList(managedRepos);
 
         String result = action.filteredSearch();
 
-        assertEquals( GlobalResults.ACCESS_TO_NO_REPOS, result );
+        assertEquals(GlobalResults.ACCESS_TO_NO_REPOS, result);
     }
 
     public void testAdvancedSearchNoSpecifiedCriteria()
@@ -410,40 +411,40 @@ public class SearchActionTest
     {
         List<String> managedRepos = new ArrayList<String>();
 
-        action.setManagedRepositoryList( managedRepos );
+        action.setManagedRepositoryList(managedRepos);
 
         String result = action.filteredSearch();
 
-        assertEquals( Action.INPUT, result );
-        assertFalse( action.getActionErrors().isEmpty() );
-        assertEquals( "Advanced Search - At least one search criteria must be provided.",
-                      (String) action.getActionErrors().iterator().next() );
+        assertEquals(Action.INPUT, result);
+        assertFalse(action.getActionErrors().isEmpty());
+        assertEquals("Advanced Search - At least one search criteria must be provided.",
+                     (String) action.getActionErrors().iterator().next());
     }
 
     // find artifact..
     public void testFindArtifactWithOneHit()
         throws Exception
     {
-        action.setQ( TEST_CHECKSUM );
+        action.setQ(TEST_CHECKSUM);
 
-        MockControl control = MockControl.createControl( MetadataRepository.class );
+        MockControl control = MockControl.createControl(MetadataRepository.class);
         MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
-        when( session.getRepository() ).thenReturn( metadataRepository );
+        when(session.getRepository()).thenReturn(metadataRepository);
 
-        ArtifactMetadata artifact = createArtifact( "archiva-configuration", "1.0" );
-        control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ),
-                                 Collections.singletonList( artifact ) );
+        ArtifactMetadata artifact = createArtifact("archiva-configuration", "1.0");
+        control.expectAndReturn(metadataRepository.getArtifactsByChecksum(TEST_REPO, TEST_CHECKSUM),
+                                Collections.singletonList(artifact));
 
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ),
-                                          Collections.singletonList( TEST_REPO ) );
+        userReposControl.expectAndReturn(userRepos.getObservableRepositoryIds(GUEST),
+                                         Collections.singletonList(TEST_REPO));
 
         control.replay();
         userReposControl.replay();
 
         String result = action.findArtifact();
-        assertEquals( "artifact", result );
-        assertEquals( 1, action.getDatabaseResults().size() );
-        assertEquals( artifact, action.getDatabaseResults().get( 0 ) );
+        assertEquals("artifact", result);
+        assertEquals(1, action.getDatabaseResults().size());
+        assertEquals(artifact, action.getDatabaseResults().get(0));
 
         control.verify();
         userReposControl.verify();
@@ -452,26 +453,26 @@ public class SearchActionTest
     public void testFindArtifactWithMultipleHits()
         throws Exception
     {
-        action.setQ( TEST_CHECKSUM );
+        action.setQ(TEST_CHECKSUM);
 
-        MockControl control = MockControl.createControl( MetadataRepository.class );
+        MockControl control = MockControl.createControl(MetadataRepository.class);
         MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
-        when( session.getRepository() ).thenReturn( metadataRepository );
+        when(session.getRepository()).thenReturn(metadataRepository);
 
-        List<ArtifactMetadata> artifacts = Arrays.asList( createArtifact( "archiva-configuration", "1.0" ),
-                                                          createArtifact( "archiva-indexer", "1.0" ) );
-        control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ), artifacts );
+        List<ArtifactMetadata> artifacts =
+            Arrays.asList(createArtifact("archiva-configuration", "1.0"), createArtifact("archiva-indexer", "1.0"));
+        control.expectAndReturn(metadataRepository.getArtifactsByChecksum(TEST_REPO, TEST_CHECKSUM), artifacts);
 
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ),
-                                          Collections.singletonList( TEST_REPO ) );
+        userReposControl.expectAndReturn(userRepos.getObservableRepositoryIds(GUEST),
+                                         Collections.singletonList(TEST_REPO));
 
         control.replay();
         userReposControl.replay();
 
         String result = action.findArtifact();
-        assertEquals( "results", result );
-        assertFalse( action.getDatabaseResults().isEmpty() );
-        assertEquals( 2, action.getDatabaseResults().size() );
+        assertEquals("results", result);
+        assertFalse(action.getDatabaseResults().isEmpty());
+        assertEquals(2, action.getDatabaseResults().size());
 
         control.verify();
         userReposControl.verify();
@@ -482,47 +483,47 @@ public class SearchActionTest
     {
         String result = action.findArtifact();
 
-        assertEquals( Action.INPUT, result );
-        assertFalse( action.getActionErrors().isEmpty() );
-        assertEquals( "Unable to search for a blank checksum", (String) action.getActionErrors().iterator().next() );
+        assertEquals(Action.INPUT, result);
+        assertFalse(action.getActionErrors().isEmpty());
+        assertEquals("Unable to search for a blank checksum", (String) action.getActionErrors().iterator().next());
     }
 
     public void testFindArtifactNoResults()
         throws Exception
     {
-        action.setQ( TEST_CHECKSUM );
+        action.setQ(TEST_CHECKSUM);
 
-        MockControl control = MockControl.createControl( MetadataRepository.class );
+        MockControl control = MockControl.createControl(MetadataRepository.class);
         MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
-        when( session.getRepository() ).thenReturn( metadataRepository );
+        when(session.getRepository()).thenReturn(metadataRepository);
 
-        control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ),
-                                 Collections.<ArtifactMetadata>emptyList() );
+        control.expectAndReturn(metadataRepository.getArtifactsByChecksum(TEST_REPO, TEST_CHECKSUM),
+                                Collections.<ArtifactMetadata>emptyList());
 
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ),
-                                          Collections.singletonList( TEST_REPO ) );
+        userReposControl.expectAndReturn(userRepos.getObservableRepositoryIds(GUEST),
+                                         Collections.singletonList(TEST_REPO));
 
         control.replay();
         userReposControl.replay();
 
         String result = action.findArtifact();
-        assertEquals( Action.INPUT, result );
-        assertFalse( action.getActionErrors().isEmpty() );
-        assertEquals( "No results found", (String) action.getActionErrors().iterator().next() );
+        assertEquals(Action.INPUT, result);
+        assertFalse(action.getActionErrors().isEmpty());
+        assertEquals("No results found", (String) action.getActionErrors().iterator().next());
 
         control.verify();
         userReposControl.verify();
     }
 
-    private ArtifactMetadata createArtifact( String project, String version )
+    private ArtifactMetadata createArtifact(String project, String version)
     {
         ArtifactMetadata metadata = new ArtifactMetadata();
-        metadata.setNamespace( "org.apache.archiva" );
-        metadata.setProject( project );
-        metadata.setProjectVersion( version );
-        metadata.setVersion( version );
-        metadata.setRepositoryId( TEST_REPO );
-        metadata.setId( project + "-" + version + ".jar" );
+        metadata.setNamespace("org.apache.archiva");
+        metadata.setProject(project);
+        metadata.setProjectVersion(version);
+        metadata.setVersion(version);
+        metadata.setRepositoryId(TEST_REPO);
+        metadata.setId(project + "-" + version + ".jar");
         return metadata;
     }
 }