diff options
author | James William Dumay <jdumay@apache.org> | 2008-12-16 01:47:57 +0000 |
---|---|---|
committer | James William Dumay <jdumay@apache.org> | 2008-12-16 01:47:57 +0000 |
commit | 5210f5f2299d338434c279e8957188be324c19e4 (patch) | |
tree | a6b0400921a5ecf8a82515e2a71d7a07a5cfdd67 | |
parent | ad8ffba93ba0a5800703f452f94615e100599ab8 (diff) | |
download | archiva-5210f5f2299d338434c279e8957188be324c19e4.tar.gz archiva-5210f5f2299d338434c279e8957188be324c19e4.zip |
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
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<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 ); } 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<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) |