]> source.dussan.org Git - archiva.git/commitdiff
Fixing up tests. Snapshot versions are now merged in the search action
authorJames William Dumay <jdumay@apache.org>
Tue, 16 Dec 2008 01:47:57 +0000 (01:47 +0000)
committerJames William Dumay <jdumay@apache.org>
Tue, 16 Dec 2008 01:47:57 +0000 (01:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-search-improvements@726923 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java

index 890cdfa525af9fd6313802a82c0c95c28f9bc3e1..6877129462eb64e6a77f43d8a04c6a92103c9ed8 100644 (file)
@@ -126,17 +126,6 @@ public class DefaultCrossRepositorySearchTest
         return search;
     }
 
-    public void testSearchTerm_Org()
-        throws Exception
-    {
-        CrossRepositorySearch search = lookupCrossRepositorySearch();
-
-        SearchResults results = search.searchForTerm( "guest", Arrays.asList(TEST_DEFAULT_REPO_ID), "org", new SearchResultLimits(1) );
-
-        assertNotNull(results);
-        assertEquals(7, results.getHits().size());
-    }
-
     public void testSearchArtifactIdHasMoreWieghtThanGroupId() throws Exception
     {
         CrossRepositorySearch search = lookupCrossRepositorySearch();
@@ -149,12 +138,6 @@ public class DefaultCrossRepositorySearchTest
         SearchResultHit hit = new SearchResultHit();
         hit.setGroupId("ant");
         hit.setArtifactId("ant");
-        hit.setVersion("1.5.1");
-        expectedHits.add(hit);
-
-        hit = new SearchResultHit();
-        hit.setGroupId("ant");
-        hit.setArtifactId("ant");
         hit.setVersion("1.5");
         expectedHits.add(hit);
 
@@ -194,27 +177,25 @@ public class DefaultCrossRepositorySearchTest
             TEST_DEFAULT_REPO_ID
         };
 
-//        String expectedResults[] = new String[] {
-//            "archiva-common-1.0.jar"
-//        };
-
-        ArrayList<SearchResultHit> expectedHits = new ArrayList<SearchResultHit>();
+        SearchResultHit archivaCommon = new SearchResultHit();
+        archivaCommon.setArtifactId("archiva-common");
+        archivaCommon.setGroupId("org.apache.maven.archiva");
+        archivaCommon.setVersion("1.0");
 
         // class with packagename search
-        assertSearchResults( expectedRepos, expectedHits, search,
+        assertSearchResults( expectedRepos, Arrays.asList(archivaCommon), search,
                              "org.apache.maven.archiva.common.utils.BaseFile", null, true );
         // class name search
-        assertSearchResults( expectedRepos, expectedHits, search,
+        assertSearchResults( expectedRepos, Arrays.asList(archivaCommon), search,
                              "BaseFile", null, true );
 
-//        String expectedMethodSearchResults[] = new String[] {
-//            "continuum-webapp-1.0.3-SNAPSHOT.war"
-//        };
-
-        ArrayList<SearchResultHit> expectedMethodSearchResults = new ArrayList<SearchResultHit>();
+        SearchResultHit hit = new SearchResultHit();
+        hit.setGroupId("org.apache.maven.continuum");
+        hit.setArtifactId("continuum-webapp");
+        hit.setVersion("1.0.3-SNAPSHOT");
 
         // method search
-        assertSearchResults( expectedRepos, expectedMethodSearchResults, search,
+        assertSearchResults( expectedRepos, Arrays.asList(hit), search,
                              "org.apache.maven.continuum.web.action.BuildDefinitionAction.isBuildFresh", null, true );
     }
     
index a191faea26634650f47fc6b476e1b13127124a58..c3d9194fb59a270a14b7ab0559fbe1d00a434f0f 100644 (file)
@@ -286,7 +286,7 @@ public class SearchAction
                 if (versions != null && !versions.isEmpty())
                 {
                     resultHit.setVersion(null);
-                    resultHit.setVersions(filterOutTimestampedSnapshots(versions));
+                    resultHit.setVersions(filterTimestampedSnapshots(versions));
                 }
             }
         }
@@ -297,7 +297,7 @@ public class SearchAction
     /**
      * Remove timestamped snapshots from versions
      */
-    private static List<String> filterOutTimestampedSnapshots(List<String> versions)
+    private static List<String> filterTimestampedSnapshots(List<String> versions)
     {
         final List<String> filtered = new ArrayList<String>();
         for (final String version : versions)