Refactor of the SiteService Lucene query to support users explicitly searching for "*" in the site-finder UI.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29015 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2011-07-14 09:11:09 +00:00
parent 68956f2c48
commit 7c65a094d5
2 changed files with 38 additions and 3 deletions

View File

@@ -605,6 +605,37 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest
}
}
/**
* This test method ensures that searches with wildcards work as they should
*/
public void testfindSitesWithWildcardTitles() throws Exception
{
// How many sites are there already in the repo?
List<SiteInfo> preexistingSites = this.siteService.findSites(null, null, 0);
final int preexistingSitesCount = preexistingSites.size();
// Create some test sites
//
// Note that the shortName can't contain an asterisk but the title can.
this.siteService.createSite(TEST_SITE_PRESET, "siteAlpha", "asterix", TEST_DESCRIPTION, SiteVisibility.PUBLIC);
this.siteService.createSite(TEST_SITE_PRESET, "siteBeta", "asterix*obelix", TEST_DESCRIPTION, SiteVisibility.PUBLIC);
// Get sites by matching title
List<SiteInfo> sites = this.siteService.findSites("asterix", null, 0);
assertNotNull(sites);
// As the name & description do not contain "asterix", this will become a search for sites whose titles match "asterix"
assertEquals("Matched wrong number of sites with title equal to 'asterix'", 2, sites.size());
// This means 'find all'
sites = this.siteService.findSites("*", null, 0);
assertNotNull(sites);
assertEquals("Matched wrong number of sites using '*'", preexistingSitesCount + 2, sites.size());
sites = this.siteService.findSites("as?erix", null, 0);
assertNotNull(sites);
assertEquals("Matched wrong number of sites using '?'", 2, sites.size());
}
public void testGetSite()
{
// Get a site that isn't there