From 5210f5f2299d338434c279e8957188be324c19e4 Mon Sep 17 00:00:00 2001 From: James William Dumay Date: Tue, 16 Dec 2008 01:47:57 +0000 Subject: Fixing up tests. Snapshot versions are now merged in the search action git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-search-improvements@726923 13f79535-47bb-0310-9956-ffa450edef68 --- .../search/DefaultCrossRepositorySearchTest.java | 41 ++++++---------------- .../maven/archiva/web/action/SearchAction.java | 4 +-- 2 files changed, 13 insertions(+), 32 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java index 890cdfa52..687712946 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java @@ -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 expectedHits = new ArrayList(); + 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 expectedMethodSearchResults = new ArrayList(); + 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 ); } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java index a191faea2..c3d9194fb 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java @@ -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 filterOutTimestampedSnapshots(List versions) + private static List filterTimestampedSnapshots(List versions) { final List filtered = new ArrayList(); for (final String version : versions) -- cgit v1.2.3