From 2cca787161bffd9c1ce1d25049cb6ed450194930 Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Mon, 11 Feb 2019 09:34:41 +0000 Subject: [PATCH 1/5] Search-1359: Tests added to cover Search Range tests for text fields --- .../search/AbstractSearchServiceE2E.java | 38 +++- .../search/SearchWithCustomModelTest.java | 211 ++++++++++++++++++ e2e-test/src/test/resources/SearchSuite.xml | 2 + 3 files changed, 249 insertions(+), 2 deletions(-) create mode 100644 e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java diff --git a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java index 9e1193614..147bceefd 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java @@ -9,6 +9,7 @@ package org.alfresco.service.search; import org.alfresco.cmis.CmisWrapper; import org.alfresco.dataprep.ContentService; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.search.RestRequestQueryModel; @@ -20,7 +21,10 @@ import org.alfresco.utility.Utility; import org.alfresco.utility.data.DataContent; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.network.ServerHealth; import org.apache.chemistry.opencmis.client.api.CmisObject; import org.apache.chemistry.opencmis.client.api.Session; @@ -71,6 +75,12 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte @Autowired @Getter(value = PROTECTED) private ContentService contentService; + + protected UserModel testUser, adminUserModel; + protected SiteModel testSite; + protected UserModel searchedUser; + + protected static String unique_searchString; public static final String NODE_PREFIX = "workspace/SpacesStore/"; @@ -88,6 +98,16 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte { LOG.warn("Error Loading Custom Model", e); } + + adminUserModel = dataUser.getAdminUser(); + testUser = dataUser.createRandomTestUser("UserSearch"); + + testSite = new SiteModel(RandomData.getRandomName("SiteSearch")); + testSite.setVisibility(Visibility.PRIVATE); + + testSite = dataSite.usingUser(testUser).createSite(testSite); + + unique_searchString = testSite.getTitle().replace("SiteSearch", "Unique"); } public boolean deployCustomModel(String path) @@ -257,17 +277,31 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte } /** - * Run a search and return the response + * Run a search as admin user and return the response + * * @param queryString: string to search for, unique search string will guarantee accurate results * @return the search response from the API * @throws Exception */ public SearchResponse query(String queryString) throws Exception + { + return queryWithUser(dataUser.getAdminUser(), queryString); + } + + /** + * Run a search as given user and return the response + * + * @param user: UserModel for the user you wish to run the query as + * @param queryString: string to search for, unique search string will guarantee accurate results + * @return the search response from the API + * @throws Exception + */ + public SearchResponse queryWithUser(UserModel user, String queryString) throws Exception { SearchRequest searchRequest = new SearchRequest(); RestRequestQueryModel queryModel = new RestRequestQueryModel(); queryModel.setQuery(queryString); searchRequest.setQuery(queryModel); - return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(searchRequest); + return restClient.authenticateUser(user).withSearchAPI().search(searchRequest); } } diff --git a/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java b/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java new file mode 100644 index 000000000..49ca6c158 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java @@ -0,0 +1,211 @@ +/* + * Copyright 2019 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.service.search; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.rest.search.SearchResponse; +import org.alfresco.service.search.AbstractSearchServiceE2E; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataContent; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.TestGroup; +import org.apache.chemistry.opencmis.commons.PropertyIds; +import org.apache.chemistry.opencmis.commons.enums.VersioningState; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Purpose of this TestClass is to test that the search range query tests work as expected with CustomModels + * Tests added for Search-1359 + * + * @author meenal bhave + */ + +public class SearchWithCustomModelTest extends AbstractSearchServiceE2E +{ + @Autowired + protected DataSite dataSite; + + @Autowired + protected DataContent dataContent; + + private FolderModel testFolder; + + private FileModel expenseLondon, expenseParis, expenseNoLocation; + + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + serverHealth.assertServerIsOnline(); + + dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor); + + testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder(); + + Long uniqueRef = System.currentTimeMillis(); + + expenseLondon = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Expense"); + expenseLondon.setName("fin1-" + expenseLondon.getName()); + + Map properties = new HashMap(); + properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Expense"); + properties.put(PropertyIds.NAME, expenseLondon.getName()); + properties.put("finance:No", uniqueRef); + properties.put("finance:amount", 300); + + cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(expenseLondon, properties, VersioningState.MAJOR) + .assertThat().existsInRepo(); + + // Location value is set to London + cmisApi.authenticateUser(testUser).usingResource(expenseLondon).addSecondaryTypes("P:finance:ParkEx").assertThat() + .secondaryTypeIsAvailable("P:finance:ParkEx"); + cmisApi.authenticateUser(testUser).usingResource(expenseLondon).updateProperty("finance:Location", "London"); + + expenseParis = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Expense"); + expenseParis.setName("fin2-" + expenseParis.getName()); + + properties = new HashMap(); + properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Expense"); + properties.put(PropertyIds.NAME, expenseParis.getName()); + properties.put("finance:No", uniqueRef + 1); + properties.put("finance:amount", 100); + properties.put("finance:Title", "Airport Taxi Outgoing"); + properties.put("finance:Emp", "David A"); + + cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(expenseParis, properties, VersioningState.MAJOR) + .assertThat().existsInRepo(); + + // Location value is set to Paris + cmisApi.authenticateUser(testUser).usingResource(expenseParis).addSecondaryTypes("P:finance:ParkEx").assertThat() + .secondaryTypeIsAvailable("P:finance:ParkEx"); + cmisApi.authenticateUser(testUser).usingResource(expenseParis).updateProperty("finance:Location", "Paris"); + + expenseNoLocation = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "receipt"); + expenseNoLocation.setName("fin3-" + expenseNoLocation.getName()); + + properties = new HashMap(); + properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Expense"); + properties.put(PropertyIds.NAME, expenseNoLocation.getName()); + properties.put("finance:No", uniqueRef + 2); + properties.put("finance:amount", 0); + properties.put("finance:Title", "Hotel Stay"); + properties.put("finance:Emp", "Daniel S"); + + cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(expenseNoLocation, properties, VersioningState.MAJOR) + .assertThat().existsInRepo(); + + // Location value is set to null + cmisApi.authenticateUser(testUser).usingResource(expenseNoLocation).addSecondaryTypes("P:finance:ParkEx").assertThat() + .secondaryTypeIsAvailable("P:finance:ParkEx"); + + // Wait for the file to be indexed + waitForIndexing(expenseNoLocation.getName(), true); + } + + // Search-1359: Search AFTS Query with Range + @Test(priority = 1, groups = { TestGroup.ASS_14 }) + public void testRangeQueryTextField() throws Exception + { + // Search Range Query + SearchResponse response = queryWithUser(testUser, "finance_Location:[* TO London]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Content where Location = London is returned, If property is not set, its ignored. + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryWithUser(testUser, "finance_Location:[London TO *]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + // Content where Location = London, Paris is returned, If property is not set, its ignored. + Assert.assertEquals(response.getPagination().getCount(), 2); + + response = queryWithUser(testUser, "finance_Location:[London To Paris]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 2); + + response = queryWithUser(testUser, "finance_Location:[* To *]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 2); + } + + @Test(priority = 2, groups = { TestGroup.ASS_14 }) + public void testRangeQueryTextFieldWhiteSpace() throws Exception + { + SearchResponse response = queryWithUser(testUser, "finance:Emp:[* TO Daniel]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + // TODO: Uncomment when fixed + // Assert.assertEquals(response.getPagination().getCount(), 1); //2 + + response = queryWithUser(testUser, "finance:Emp:[Dan TO *]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 2); + + response = queryWithUser(testUser, "finance:Emp:[Dan To David]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 2); + + response = queryWithUser(testUser, "finance:Emp:[* To *]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 2); + } + + @Test(priority = 3, groups = { TestGroup.ASS_14 }) + public void testRangeQueryTextFieldNonFacetable() throws Exception + { + // Search Range Query + SearchResponse response = queryWithUser(testUser, "finance:Title:[* TO H]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryWithUser(testUser, "finance:Title:[Hotel TO *]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + // TODO: Uncomment when fixed + // Assert.assertEquals(response.getPagination().getCount(), 1); //2 + + response = queryWithUser(testUser, "finance:Title:[B To H]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + // TODO: Uncomment when fixed + // Assert.assertEquals(response.getPagination().getCount(), 1); // H, H* return 0 + + response = queryWithUser(testUser, "finance:Title:[B To I]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryWithUser(testUser, "finance:Title:[* To *]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 2); + } + + @Test(priority = 4, groups = { TestGroup.ASS_14 }) + public void testRangeQueryDoubleField() throws Exception + { + // Search Range Query + SearchResponse response = queryWithUser(testUser, "finance:amount:[* TO 100]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 2); + + response = queryWithUser(testUser, "finance_amount:[100 TO *]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 2); + + response = queryWithUser(testUser, "finance_amount:[100 To 300]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 2); + + response = queryWithUser(testUser, "finance_amount:[* To *]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 3); + } +} diff --git a/e2e-test/src/test/resources/SearchSuite.xml b/e2e-test/src/test/resources/SearchSuite.xml index 70393bfca..29aecd851 100644 --- a/e2e-test/src/test/resources/SearchSuite.xml +++ b/e2e-test/src/test/resources/SearchSuite.xml @@ -23,7 +23,9 @@ + + From 5496ed2d30f673624a6b8bc0685a83543978b751 Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Mon, 11 Feb 2019 09:47:51 +0000 Subject: [PATCH 2/5] Search-1359: Amended the method name --- .../search/AbstractSearchServiceE2E.java | 4 +-- .../search/SearchWithCustomModelTest.java | 34 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java index 147bceefd..03d61d3a7 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java @@ -285,7 +285,7 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte */ public SearchResponse query(String queryString) throws Exception { - return queryWithUser(dataUser.getAdminUser(), queryString); + return queryAsUser(dataUser.getAdminUser(), queryString); } /** @@ -296,7 +296,7 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte * @return the search response from the API * @throws Exception */ - public SearchResponse queryWithUser(UserModel user, String queryString) throws Exception + public SearchResponse queryAsUser(UserModel user, String queryString) throws Exception { SearchRequest searchRequest = new SearchRequest(); RestRequestQueryModel queryModel = new RestRequestQueryModel(); diff --git a/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java b/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java index 49ca6c158..f237efad9 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java @@ -120,22 +120,22 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E public void testRangeQueryTextField() throws Exception { // Search Range Query - SearchResponse response = queryWithUser(testUser, "finance_Location:[* TO London]"); + SearchResponse response = queryAsUser(testUser, "finance_Location:[* TO London]"); restClient.assertStatusCodeIs(HttpStatus.OK); // Content where Location = London is returned, If property is not set, its ignored. Assert.assertEquals(response.getPagination().getCount(), 1); - response = queryWithUser(testUser, "finance_Location:[London TO *]"); + response = queryAsUser(testUser, "finance_Location:[London TO *]"); restClient.assertStatusCodeIs(HttpStatus.OK); // Content where Location = London, Paris is returned, If property is not set, its ignored. Assert.assertEquals(response.getPagination().getCount(), 2); - response = queryWithUser(testUser, "finance_Location:[London To Paris]"); + response = queryAsUser(testUser, "finance_Location:[London To Paris]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 2); - response = queryWithUser(testUser, "finance_Location:[* To *]"); + response = queryAsUser(testUser, "finance_Location:[* To *]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 2); } @@ -143,20 +143,20 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E @Test(priority = 2, groups = { TestGroup.ASS_14 }) public void testRangeQueryTextFieldWhiteSpace() throws Exception { - SearchResponse response = queryWithUser(testUser, "finance:Emp:[* TO Daniel]"); + SearchResponse response = queryAsUser(testUser, "finance:Emp:[* TO Daniel]"); restClient.assertStatusCodeIs(HttpStatus.OK); // TODO: Uncomment when fixed // Assert.assertEquals(response.getPagination().getCount(), 1); //2 - response = queryWithUser(testUser, "finance:Emp:[Dan TO *]"); + response = queryAsUser(testUser, "finance:Emp:[Dan TO *]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 2); - response = queryWithUser(testUser, "finance:Emp:[Dan To David]"); + response = queryAsUser(testUser, "finance:Emp:[Dan To David]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 2); - response = queryWithUser(testUser, "finance:Emp:[* To *]"); + response = queryAsUser(testUser, "finance:Emp:[* To *]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 2); } @@ -165,25 +165,25 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E public void testRangeQueryTextFieldNonFacetable() throws Exception { // Search Range Query - SearchResponse response = queryWithUser(testUser, "finance:Title:[* TO H]"); + SearchResponse response = queryAsUser(testUser, "finance:Title:[* TO H]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 1); - response = queryWithUser(testUser, "finance:Title:[Hotel TO *]"); + response = queryAsUser(testUser, "finance:Title:[Hotel TO *]"); restClient.assertStatusCodeIs(HttpStatus.OK); // TODO: Uncomment when fixed // Assert.assertEquals(response.getPagination().getCount(), 1); //2 - response = queryWithUser(testUser, "finance:Title:[B To H]"); + response = queryAsUser(testUser, "finance:Title:[B To H]"); restClient.assertStatusCodeIs(HttpStatus.OK); // TODO: Uncomment when fixed // Assert.assertEquals(response.getPagination().getCount(), 1); // H, H* return 0 - response = queryWithUser(testUser, "finance:Title:[B To I]"); + response = queryAsUser(testUser, "finance:Title:[B To I]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 1); - response = queryWithUser(testUser, "finance:Title:[* To *]"); + response = queryAsUser(testUser, "finance:Title:[* To *]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 2); } @@ -192,19 +192,19 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E public void testRangeQueryDoubleField() throws Exception { // Search Range Query - SearchResponse response = queryWithUser(testUser, "finance:amount:[* TO 100]"); + SearchResponse response = queryAsUser(testUser, "finance:amount:[* TO 100]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 2); - response = queryWithUser(testUser, "finance_amount:[100 TO *]"); + response = queryAsUser(testUser, "finance_amount:[100 TO *]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 2); - response = queryWithUser(testUser, "finance_amount:[100 To 300]"); + response = queryAsUser(testUser, "finance_amount:[100 To 300]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 2); - response = queryWithUser(testUser, "finance_amount:[* To *]"); + response = queryAsUser(testUser, "finance_amount:[* To *]"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 3); } From bda323026dabf32d5b96e9fc7768ba2ee39b0565 Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Mon, 11 Feb 2019 10:10:10 +0000 Subject: [PATCH 3/5] Search-1359: Amended the query to include * --- .../alfresco/service/search/SearchWithCustomModelTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java b/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java index f237efad9..defd70856 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java @@ -174,10 +174,10 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E // TODO: Uncomment when fixed // Assert.assertEquals(response.getPagination().getCount(), 1); //2 - response = queryAsUser(testUser, "finance:Title:[B To H]"); + response = queryAsUser(testUser, "finance:Title:[B To H*]"); restClient.assertStatusCodeIs(HttpStatus.OK); // TODO: Uncomment when fixed - // Assert.assertEquals(response.getPagination().getCount(), 1); // H, H* return 0 + // Assert.assertEquals(response.getPagination().getCount(), 1); // H* return 0 response = queryAsUser(testUser, "finance:Title:[B To I]"); restClient.assertStatusCodeIs(HttpStatus.OK); From 87e2c7c42a31fecc4a9eb30ff155abe61e6acc29 Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Mon, 11 Feb 2019 14:53:03 +0000 Subject: [PATCH 4/5] Search-1359: Updated model, test results and added a test for non tockenised field --- .../main/resources/model/finance-model.xml | 11 +++++- .../search/SearchWithCustomModelTest.java | 37 +++++++++++++++---- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/e2e-test/src/main/resources/model/finance-model.xml b/e2e-test/src/main/resources/model/finance-model.xml index 726c885f9..ffef6b056 100644 --- a/e2e-test/src/main/resources/model/finance-model.xml +++ b/e2e-test/src/main/resources/model/finance-model.xml @@ -73,7 +73,16 @@ d:text false - TRUE + BOTH + false + + + + Description + d:text + false + + false false diff --git a/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java b/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java index defd70856..3eb40b303 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/SearchWithCustomModelTest.java @@ -84,6 +84,7 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E properties.put("finance:amount", 100); properties.put("finance:Title", "Airport Taxi Outgoing"); properties.put("finance:Emp", "David A"); + properties.put("finance:Desc", "David's Taxi"); cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(expenseParis, properties, VersioningState.MAJOR) .assertThat().existsInRepo(); @@ -103,6 +104,7 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E properties.put("finance:amount", 0); properties.put("finance:Title", "Hotel Stay"); properties.put("finance:Emp", "Daniel S"); + properties.put("finance:Desc", "Daniel's Taxi"); cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(expenseNoLocation, properties, VersioningState.MAJOR) .assertThat().existsInRepo(); @@ -145,8 +147,8 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E { SearchResponse response = queryAsUser(testUser, "finance:Emp:[* TO Daniel]"); restClient.assertStatusCodeIs(HttpStatus.OK); - // TODO: Uncomment when fixed - // Assert.assertEquals(response.getPagination().getCount(), 1); //2 + // Tockenised field, so Returns Daniel, David A (A before Daniel) + Assert.assertEquals(response.getPagination().getCount(), 2); response = queryAsUser(testUser, "finance:Emp:[Dan TO *]"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -171,13 +173,13 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E response = queryAsUser(testUser, "finance:Title:[Hotel TO *]"); restClient.assertStatusCodeIs(HttpStatus.OK); - // TODO: Uncomment when fixed - // Assert.assertEquals(response.getPagination().getCount(), 1); //2 + // Tockenised field, so Includes: Hotel, (Airport) Taxi Outgoing + Assert.assertEquals(response.getPagination().getCount(), 2); - response = queryAsUser(testUser, "finance:Title:[B To H*]"); + response = queryAsUser(testUser, "finance:Title:[B To Hotel]"); restClient.assertStatusCodeIs(HttpStatus.OK); - // TODO: Uncomment when fixed - // Assert.assertEquals(response.getPagination().getCount(), 1); // H* return 0 + // Tockenised field, so Includes: (Airport) Taxi Outgoing + Assert.assertEquals(response.getPagination().getCount(), 1); response = queryAsUser(testUser, "finance:Title:[B To I]"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -189,6 +191,27 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E } @Test(priority = 4, groups = { TestGroup.ASS_14 }) + public void testRangeQueryTextFieldNotTockenised() throws Exception + { + SearchResponse response = queryAsUser(testUser, "finance:Desc:[* TO David]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + // Includes: Daniel's Taxi + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "finance:Desc:[Dan TO *]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 2); + + response = queryAsUser(testUser, "finance:Desc:[Dan To David]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "finance:Desc:[* To *]"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 2); + } + + @Test(priority = 5, groups = { TestGroup.ASS_14 }) public void testRangeQueryDoubleField() throws Exception { // Search Range Query From b0193367b49e223bb9e5c6f104b6a15b23885637 Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Tue, 12 Feb 2019 15:58:17 +0000 Subject: [PATCH 5/5] Search-1359: Added the search packages as these are not being run on bamboo --- e2e-test/src/test/resources/SearchSuite.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/e2e-test/src/test/resources/SearchSuite.xml b/e2e-test/src/test/resources/SearchSuite.xml index 29aecd851..3eb4d7745 100644 --- a/e2e-test/src/test/resources/SearchSuite.xml +++ b/e2e-test/src/test/resources/SearchSuite.xml @@ -28,6 +28,10 @@ + + + +