From e2572e839dc92034b07eff06aa70ee8486112c1c Mon Sep 17 00:00:00 2001 From: Keerat Date: Tue, 5 May 2020 11:46:07 +0100 Subject: [PATCH 1/4] SEARCH-2139 tests for test definition in the solr schema --- .../resources/model/search-2139-model.xml | 154 ++++++++++++++++++ .../search/FieldDefinitionTest.java | 47 ++++++ 2 files changed, 201 insertions(+) create mode 100644 e2e-test/src/main/resources/model/search-2139-model.xml create mode 100644 e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java diff --git a/e2e-test/src/main/resources/model/search-2139-model.xml b/e2e-test/src/main/resources/model/search-2139-model.xml new file mode 100644 index 000000000..a734f2e04 --- /dev/null +++ b/e2e-test/src/main/resources/model/search-2139-model.xml @@ -0,0 +1,154 @@ + + + Administrator + + + + + + + + + + + allfieldtypes Content + cm:content + + + Text + d:text + + + + + + + false + false + + + cm:content + false + false + + + + + + + + text + + + mltextLOVPartial + d:mltext + false + + BOTH + true + + + + textPatternUnique + d:text + false + + FALSE + false + + + + mltextFree + d:mltext + false + + TRUE + false + + + + textLOVPartial + d:text + false + + BOTH + true + + + + mltextPatternUnique + d:mltext + false + + FALSE + false + + + + mltextPatternMany + d:mltext + false + + BOTH + false + + + + textLOVWhole + d:text + false + + FALSE + true + + + + mltextNone + d:mltext + false + + TRUE + + + + textNone + d:text + false + + TRUE + + + + textFree + d:text + false + + TRUE + false + + + + mltextLOVWhole + d:mltext + false + + FALSE + true + + + + textPatternMany + d:text + false + + BOTH + false + + + + + + + + + \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java new file mode 100644 index 000000000..42fc02d46 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java @@ -0,0 +1,47 @@ +package org.alfresco.test.search.functional.searchServices.search; + +import org.alfresco.rest.search.SearchResponse; +import org.alfresco.utility.data.CustomObjectTypeProperties; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * A test for fields defined in the solr schema + * Based on https://issues.alfresco.com/jira/browse/SEARCH-2139 + */ +public class FieldDefinitionTest extends AbstractSearchServicesE2ETest { + + private FolderModel Folder1; + private FileModel File1; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + dataContent.usingAdmin().deployContentModel("model/search-2139-model.xml"); + + Folder1 = new FolderModel("folder1"); + + File1 = new FileModel("standard-file1.txt"); + File1.setContent("file1"); + + // dataContent.usingUser(testUser).usingResource(Folder1).createCustomContent(File1, "D:text:document", new CustomObjectTypeProperties() + // .addProperty("allfieldtypes:mltextLOVPartial", "text file-1")); + + // dataContent.usingUser(testUser).usingSite(testSite).createCustomContent(File1, "D:allfieldtypes:document", new CustomObjectTypeProperties() + // .addProperty("allfieldtypes:mltextLOVPartial", "text folder-2")); + + dataContent.usingUser(testUser).usingSite(testSite).createCustomContent(File1, "allfieldtypes:document", new CustomObjectTypeProperties()); + } + + @Test(priority = 1) + public void testTextField() + { + SearchResponse response = queryAsUser(testUser, "allfieldtypes_mltextLOVPartial:text file-1"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + } +} From 27690817ecbf0967b0528b2665ef1e8f3fb37984 Mon Sep 17 00:00:00 2001 From: eliaporciani Date: Tue, 5 May 2020 15:26:07 +0200 Subject: [PATCH 2/4] [SEARCH-2139] updated custom model --- .../resources/model/search-2139-model.xml | 38 +++++++------------ .../search/FieldDefinitionTest.java | 9 ++++- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/e2e-test/src/main/resources/model/search-2139-model.xml b/e2e-test/src/main/resources/model/search-2139-model.xml index a734f2e04..76555ed20 100644 --- a/e2e-test/src/main/resources/model/search-2139-model.xml +++ b/e2e-test/src/main/resources/model/search-2139-model.xml @@ -9,33 +9,23 @@ - - - allfieldtypes Content - cm:content + + + content - - Text - d:text + + alltypecontent + d:content + false + + BOTH + - - - - - false - false - - - cm:content - false - false - - - - - - + + + + text diff --git a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java index 42fc02d46..dab56567d 100644 --- a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java +++ b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java @@ -34,7 +34,14 @@ public class FieldDefinitionTest extends AbstractSearchServicesE2ETest { // dataContent.usingUser(testUser).usingSite(testSite).createCustomContent(File1, "D:allfieldtypes:document", new CustomObjectTypeProperties() // .addProperty("allfieldtypes:mltextLOVPartial", "text folder-2")); - dataContent.usingUser(testUser).usingSite(testSite).createCustomContent(File1, "allfieldtypes:document", new CustomObjectTypeProperties()); + dataContent.usingUser(testUser).usingSite(testSite).createCustomContent(File1, "cmis:document", new CustomObjectTypeProperties()); + + cmisApi.authenticateUser(testUser).usingResource(File1).addSecondaryTypes("P:allfieldtypes:text", "P:allfieldtypes:content") + .updateProperty("allfieldtypes:mltextLOVPartial", "field definition test") + .updateProperty("allfieldtypes:textPatternUnique", "field definition test"); +// .updateProperty("allfieldtypes:contentTokenizedBoth", "field definition content test"); + + } @Test(priority = 1) From 872d6edb609e104f674c94156187ba1bb1b93966 Mon Sep 17 00:00:00 2001 From: Keerat Date: Wed, 6 May 2020 13:18:36 +0100 Subject: [PATCH 3/4] SEARCH_2139 Adding e2e test coverage for the text and mltext fields in the solr schema --- .../search/FieldDefinitionTest.java | 149 +++++++++++++++--- 1 file changed, 131 insertions(+), 18 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java index dab56567d..210d2f36e 100644 --- a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java +++ b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java @@ -3,7 +3,6 @@ package org.alfresco.test.search.functional.searchServices.search; import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.data.CustomObjectTypeProperties; import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; import org.springframework.http.HttpStatus; import org.testng.Assert; import org.testng.annotations.BeforeClass; @@ -15,40 +14,154 @@ import org.testng.annotations.Test; */ public class FieldDefinitionTest extends AbstractSearchServicesE2ETest { - private FolderModel Folder1; - private FileModel File1; + private FileModel File1, File2; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { dataContent.usingAdmin().deployContentModel("model/search-2139-model.xml"); - Folder1 = new FolderModel("folder1"); - File1 = new FileModel("standard-file1.txt"); - File1.setContent("file1"); - - // dataContent.usingUser(testUser).usingResource(Folder1).createCustomContent(File1, "D:text:document", new CustomObjectTypeProperties() - // .addProperty("allfieldtypes:mltextLOVPartial", "text file-1")); - - // dataContent.usingUser(testUser).usingSite(testSite).createCustomContent(File1, "D:allfieldtypes:document", new CustomObjectTypeProperties() - // .addProperty("allfieldtypes:mltextLOVPartial", "text folder-2")); dataContent.usingUser(testUser).usingSite(testSite).createCustomContent(File1, "cmis:document", new CustomObjectTypeProperties()); - cmisApi.authenticateUser(testUser).usingResource(File1).addSecondaryTypes("P:allfieldtypes:text", "P:allfieldtypes:content") - .updateProperty("allfieldtypes:mltextLOVPartial", "field definition test") - .updateProperty("allfieldtypes:textPatternUnique", "field definition test"); -// .updateProperty("allfieldtypes:contentTokenizedBoth", "field definition content test"); - + cmisApi.authenticateUser(testUser).usingResource(File1).addSecondaryTypes("P:allfieldtypes:text") + .updateProperty("allfieldtypes:mltextLOVPartial", "file1") + .updateProperty("allfieldtypes:textPatternUnique", "file2") + .updateProperty("allfieldtypes:mltextFree", "file3") + .updateProperty("allfieldtypes:textLOVPartial", "file4"); + + File2 = new FileModel("standard-file2.txt"); + + dataContent.usingUser(testUser).usingSite(testSite).createCustomContent(File2, "cmis:document", new CustomObjectTypeProperties()); + cmisApi.authenticateUser(testUser).usingResource(File2).addSecondaryTypes("P:allfieldtypes:text") + .updateProperty("allfieldtypes:textFree", "text field definition test") + .updateProperty("allfieldtypes:textPatternMany", "mltext field definition test") + .updateProperty("allfieldtypes:textLOVWhole", "text field not tokenised") + .updateProperty("allfieldtypes:mltextLOVWhole", "mltext field not tokenised"); + + waitForMetadataIndexing(File1.getName(), true); + waitForMetadataIndexing(File2.getName(), true); } + // A test to test the text field in the solr schema, using a single word @Test(priority = 1) public void testTextField() { - SearchResponse response = queryAsUser(testUser, "allfieldtypes_mltextLOVPartial:text file-1"); + SearchResponse response = queryAsUser(testUser, "allfieldtypes_textPatternUnique:file2"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "allfieldtypes_textLOVPartial:file4"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 1); } + + // A test to test the mltext field in the solr schema, using a single word + @Test(priority = 2) + public void testmlTextField() + { + SearchResponse response = queryAsUser(testUser, "allfieldtypes_mltextLOVPartial:file1"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "allfieldtypes_mltextFree:file3"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + } + + // A test to test the text field in the solr schema, where the field hasn't been defined + @Test(priority = 3) + public void testTextFieldNotDefined() + { + SearchResponse response = queryAsUser(testUser, "allfieldtypes_textPatternMany:file1"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 0); + + response = queryAsUser(testUser, "allfieldtypes:textNone:file2"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 0); + } + + // A test to test the mltext field in the solr schema, where the field hasn't been defined + @Test(priority = 4) + public void testmlTextFieldNotDefined() + { + SearchResponse response = queryAsUser(testUser, "allfieldtypes_mltextNone:file1"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 0); + + response = queryAsUser(testUser, "allfieldtypes_mltextPatternUnique:file2"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 0); + } + + // A test to test the tokenised text field in the solr schema + @Test(priority = 5) + public void testTextFieldTokenised() + { + SearchResponse response = queryAsUser(testUser, "allfieldtypes_textFree:\"text field definition test\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "allfieldtypes_textFree:\"text\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "allfieldtypes_textFree:\"definition test\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + } + + // A test to test a non tokenised text field in the solr schema + @Test(priority = 6) + public void testTextFieldNotTokenised() + { + SearchResponse response = queryAsUser(testUser, "allfieldtypes_textLOVWhole:\"text field not tokenised\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "allfieldtypes_textLOVWhole:\"text\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 0); + + response = queryAsUser(testUser, "allfieldtypes_textLOVWhole:\"field not\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 0); + } + + // A test to test the tokenised mltext field in the solr schema + @Test(priority = 7) + public void testmlTextFieldTokenised() + { + SearchResponse response = queryAsUser(testUser, "allfieldtypes_textPatternMany:\"mltext field definition test\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "allfieldtypes_textPatternMany:\"mltext\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "allfieldtypes_textPatternMany:\"field definition\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + } + + // A test to test the non tokenised mltext field in the solr schema + @Test(priority = 7) + public void testmlTextFieldNotTokenised() + { + SearchResponse response = queryAsUser(testUser, "allfieldtypes_mltextLOVWhole:\"mltext field not tokenised\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "allfieldtypes_mltextLOVWhole:\"mltext\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 0); + + response = queryAsUser(testUser, "allfieldtypes_mltextLOVWhole:\"not tokenised\""); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 0); + } } From a8ee1bfe024cdeb8181af3758b47c93b873826ea Mon Sep 17 00:00:00 2001 From: Keerat Date: Thu, 7 May 2020 09:02:43 +0100 Subject: [PATCH 4/4] SEARCH-2139 review comments added --- .../search/FieldDefinitionTest.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java index 210d2f36e..bae7bd1ca 100644 --- a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java +++ b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/search/FieldDefinitionTest.java @@ -105,13 +105,17 @@ public class FieldDefinitionTest extends AbstractSearchServicesE2ETest { restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 1); - response = queryAsUser(testUser, "allfieldtypes_textFree:\"text\""); + response = queryAsUser(testUser, "allfieldtypes_textFree:text"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 1); response = queryAsUser(testUser, "allfieldtypes_textFree:\"definition test\""); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "allfieldtypes_textPatternMany:definition"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); } // A test to test a non tokenised text field in the solr schema @@ -122,7 +126,7 @@ public class FieldDefinitionTest extends AbstractSearchServicesE2ETest { restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 1); - response = queryAsUser(testUser, "allfieldtypes_textLOVWhole:\"text\""); + response = queryAsUser(testUser, "allfieldtypes_textLOVWhole:text"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 0); @@ -139,13 +143,17 @@ public class FieldDefinitionTest extends AbstractSearchServicesE2ETest { restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 1); - response = queryAsUser(testUser, "allfieldtypes_textPatternMany:\"mltext\""); + response = queryAsUser(testUser, "allfieldtypes_textPatternMany:mltext"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 1); response = queryAsUser(testUser, "allfieldtypes_textPatternMany:\"field definition\""); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 1); + + response = queryAsUser(testUser, "allfieldtypes_textPatternMany:field"); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(response.getPagination().getCount(), 1); } // A test to test the non tokenised mltext field in the solr schema @@ -156,7 +164,7 @@ public class FieldDefinitionTest extends AbstractSearchServicesE2ETest { restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 1); - response = queryAsUser(testUser, "allfieldtypes_mltextLOVWhole:\"mltext\""); + response = queryAsUser(testUser, "allfieldtypes_mltextLOVWhole:mltext"); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertEquals(response.getPagination().getCount(), 0);