From caa7128117746c8cfc38786a0c026e81932b3f70 Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Thu, 5 Feb 2009 09:22:22 +0000 Subject: [PATCH] [MRM-1046] o added more tests git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@741054 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/web/action/SearchActionTest.java | 51 ++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java index 617ca3b24..3210e7364 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java @@ -182,13 +182,60 @@ public class SearchActionTest public void testSearchUserHasNoAccessToAnyRepository() throws Exception { - + action.setQ( "archiva" ); + action.setCurrentPage( 0 ); + + List selectedRepos = new ArrayList(); + + archivaXworkUserControl.expectAndReturn( archivaXworkUser.getActivePrincipal( new HashMap() ), "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(); } public void testNoSearchHits() throws Exception { - + action.setQ( "archiva" ); + action.setCurrentPage( 0 ); + action.setSearchResultsOnly( false ); + action.setCompleteQueryString( "" ); + + List selectedRepos = new ArrayList(); + selectedRepos.add( "internal" ); + selectedRepos.add( "snapshots" ); + + SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() ); + limits.setPageSize( 30 ); + + SearchResults results = new SearchResults(); + + archivaXworkUserControl.expectAndReturn( archivaXworkUser.getActivePrincipal( new HashMap() ), "user", 2 ); + + userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos ); + + searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, null ), results ); + + archivaXworkUserControl.replay(); + userReposControl.replay(); + searchControl.replay(); + + String result = action.quickSearch(); + + assertEquals( Action.INPUT, result ); + + archivaXworkUserControl.verify(); + userReposControl.verify(); + searchControl.verify(); } // test pagination or just totalPages?