diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java
index bd25d30ff..789d7cca1 100644
--- a/e2e-test/java/org/alfresco/rest/RestTest.java
+++ b/e2e-test/java/org/alfresco/rest/RestTest.java
@@ -14,6 +14,7 @@ import org.alfresco.utility.data.DataLink;
import org.alfresco.utility.data.DataSite;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.data.DataWorkflow;
+import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.network.ServerHealth;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -63,11 +64,14 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests
@Autowired
protected WorkflowService workflow;
+ protected SiteModel testSite;
+
@BeforeSuite(alwaysRun = true)
public void checkServerHealth() throws Exception
{
super.springTestContextPrepareTestInstance();
serverHealth.assertServerIsOnline();
+ testSite = dataSite.createPublicRandomSite();
}
@BeforeMethod(alwaysRun=true)
diff --git a/e2e-test/java/org/alfresco/rest/aos/AosApiTest.java b/e2e-test/java/org/alfresco/rest/aos/AosApiTest.java
new file mode 100644
index 000000000..6223db2f7
--- /dev/null
+++ b/e2e-test/java/org/alfresco/rest/aos/AosApiTest.java
@@ -0,0 +1,24 @@
+package org.alfresco.rest.aos;
+
+import org.alfresco.rest.RestTest;
+import org.alfresco.rest.core.RestRequest;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.testng.annotations.Test;
+
+public class AosApiTest extends RestTest
+{
+ /*
+ * @author: Catalin Gornea
+ *
+ * simple test for demo purposes on how to use Aos with Rest
+ */
+ @Test(enabled=false)
+ public void assertResponsIsSuccesufulWhenGetRootDirectory() throws Exception
+ {
+ restClient.authenticateUser(dataUser.getAdminUser()).withAosAPI();
+ RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "");
+ restClient.process(request);
+ restClient.assertStatusCodeIs(HttpStatus.OK);
+ }
+}
diff --git a/e2e-test/java/org/alfresco/rest/cmis/CmisBrowserTest.java b/e2e-test/java/org/alfresco/rest/cmis/CmisBrowserTest.java
new file mode 100644
index 000000000..1e9afbab7
--- /dev/null
+++ b/e2e-test/java/org/alfresco/rest/cmis/CmisBrowserTest.java
@@ -0,0 +1,25 @@
+package org.alfresco.rest.cmis;
+
+import org.alfresco.dataprep.CMISUtil.DocumentType;
+import org.alfresco.rest.RestTest;
+import org.alfresco.rest.core.RestResponse;
+import org.alfresco.utility.model.FileModel;
+import org.testng.annotations.Test;
+
+public class CmisBrowserTest extends RestTest
+{
+ /*
+ * @author: Paul Brodner
+ * simple test for demo purposes on how to use CMIS browser binding with Rest
+ */
+ @Test(enabled=false)
+ public void assertContentDispositionHeaderOnCmisFile() throws Exception
+ {
+ FileModel document = dataContent.usingUser(dataUser.getAdminUser())
+ .usingSite(testSite).createContent(DocumentType.HTML);
+
+ RestResponse response = restClient.authenticateUser(dataUser.getAdminUser()).withCMISApi().getRootObjectByID(document);
+ response.assertThat().header("Content-Disposition", String.format("attachment; filename=%s", document.getName()));
+ }
+
+}
diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java
index 58cd1f92a..91d4b8153 100644
--- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java
+++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java
@@ -154,9 +154,9 @@ public class AddCommentsFullTests extends RestTest
restClient.processModel(RestCommentModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
- restClient.assertLastError().getErrorKey().contains("Unrecognized field \"content2\"");
- restClient.assertLastError().containsSummary("Unrecognized field \"content2\"");
- restClient.assertLastError().getDescriptionURL().contains("https://api-explorer.alfresco.com");
- restClient.assertLastError().getStackTrace().contains("For security reasons the stack trace is no longer displayed, but the property is kept for previous versions");
+ restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2"));
+ restClient.assertLastError().containsSummary(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2"));
+ restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER);
+ restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE);
}
}
diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java
index b7021f602..cf0e38b9f 100644
--- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java
+++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java
@@ -207,9 +207,9 @@ public class GetCommentsFullTests extends RestTest
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
- restClient.assertLastError().getErrorKey().contains("Only positive values supported for maxItems.");
- restClient.assertLastError().containsSummary("Only positive values supported for maxItems.");
- restClient.assertLastError().getDescriptionURL().contains("https://api-explorer.alfresco.com");
- restClient.assertLastError().getStackTrace().contains("For security reasons the stack trace is no longer displayed, but the property is kept for previous versions");
+ restClient.assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
+ restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
+ restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER);
+ restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE);
}
}
\ No newline at end of file
diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java
new file mode 100644
index 000000000..abc729ab7
--- /dev/null
+++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java
@@ -0,0 +1,62 @@
+package org.alfresco.rest.nodes;
+
+import org.alfresco.dataprep.CMISUtil.DocumentType;
+import org.alfresco.rest.RestTest;
+import org.alfresco.utility.model.FileModel;
+import org.alfresco.utility.model.FileType;
+import org.alfresco.utility.model.SiteModel;
+import org.alfresco.utility.model.TestGroup;
+import org.alfresco.utility.model.UserModel;
+import org.alfresco.utility.report.Bug;
+import org.alfresco.utility.testrail.ExecutionType;
+import org.alfresco.utility.testrail.annotation.TestRail;
+import org.springframework.http.HttpStatus;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+/**
+ *
+ * @author mpopa
+ *
+ */
+public class NodesContentTests extends RestTest
+{
+ private UserModel user1, user2;
+ private SiteModel site1, site2;
+ private FileModel file1;
+
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ user1 = dataUser.createRandomTestUser();
+ user2 = dataUser.createRandomTestUser();
+ site1 = dataSite.usingUser(user1).createPublicRandomSite();
+ site2 = dataSite.usingUser(user2).createPublicRandomSite();
+ file1 = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN);
+ }
+
+ @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY,
+ description = "Verify file name in Content-Disposition header")
+ @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
+ public void checkFileNameWithRegularCharsInHeader() throws Exception
+ {
+ restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("attachment=false").getNodeContent();
+ restClient.assertStatusCodeIs(HttpStatus.OK);
+ restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file1.getName()));
+ }
+
+ @Bug(id="REPO-2112")
+ @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION,
+ description = "Verify file name with special chars is escaped in Content-Disposition header")
+ @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE})
+ public void checkFileNameWithSpecialCharsInHeader() throws Exception
+ {
+ char c1 = 127;
+ char c2 = 31;
+ char c3 = 256;
+ FileModel file = dataContent.usingUser(user2).usingSite(site2).createContent(new FileModel("\ntest\"" + c1 + c2 + c3, FileType.TEXT_PLAIN));
+ restClient.authenticateUser(user2).withCoreAPI().usingNode(file).usingParams("attachment=false").getNodeContent();
+ restClient.assertStatusCodeIs(HttpStatus.OK);
+ restClient.assertHeaderValueContains("Content-Disposition","filename=\" test .txt\"");
+ }
+
+}
diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java
new file mode 100644
index 000000000..441008d64
--- /dev/null
+++ b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java
@@ -0,0 +1,95 @@
+package org.alfresco.rest.renditions;
+
+import org.alfresco.dataprep.CMISUtil.DocumentType;
+import org.alfresco.rest.RestTest;
+import org.alfresco.rest.exception.JsonToModelConversionException;
+import org.alfresco.rest.model.RestNodeModel;
+import org.alfresco.utility.Utility;
+import org.alfresco.utility.model.FileModel;
+import org.alfresco.utility.model.FolderModel;
+import org.alfresco.utility.model.SiteModel;
+import org.alfresco.utility.model.TestGroup;
+import org.alfresco.utility.model.UserModel;
+import org.alfresco.utility.report.Bug;
+import org.alfresco.utility.testrail.ExecutionType;
+import org.alfresco.utility.testrail.annotation.TestRail;
+import org.springframework.http.HttpStatus;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Handles tests related to POST api-explorer/#!/renditions
+ * @author Cristina Axinte
+ *
+ */
+public class CreateRenditionTests extends RestTest
+{
+ private UserModel adminUser, user;
+ private SiteModel site;
+ private FileModel document;
+
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ adminUser = dataUser.getAdminUser();
+ user = dataUser.createRandomTestUser();
+ site = dataSite.usingUser(user).createPublicRandomSite();
+ }
+
+ @BeforeMethod(alwaysRun = true)
+ public void createDocument() throws Exception
+ {
+ document = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN);
+ }
+
+ @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux" )
+ @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY,
+ description = "Verify admin user creates rendition with Rest API and status code is 202")
+ @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY })
+ public void adminCanCreateRenditionToExistingNode() throws JsonToModelConversionException, Exception
+ {
+ restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).createNodeRendition("pdf");
+ restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
+
+ restClient.withCoreAPI().usingNode(document).getNodeRendition("pdf")
+ .assertThat().field("status").is("CREATED");
+ }
+
+ @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux" )
+ @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY,
+ description = "Verify user that created the document can also creates 'pdf' rendition for it with Rest API and status code is 202")
+ @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY })
+ public void userThatCreatedFileCanCreatePdfRenditionForIt() throws JsonToModelConversionException, Exception
+ {
+ restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("pdf");
+ restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
+
+ restClient.withCoreAPI().usingNode(document).getNodeRendition("pdf")
+ .assertThat().field("status").is("CREATED");
+ }
+
+ @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux" )
+ @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY,
+ description = "Verify user that created the document can also creates 'doclib' rendition for it with Rest API and status code is 202")
+ @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY })
+ public void userThatCreatedFileCanCreateDoclibRenditionForIt() throws JsonToModelConversionException, Exception
+ {
+ FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
+ restClient.authenticateUser(user)
+ .configureRequestSpec()
+ .addMultiPart("filedata", Utility.getResourceTestDataFile("my-file.tif"));
+
+ RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingResource(folder).createNode();
+ restClient.assertStatusCodeIs(HttpStatus.CREATED);
+ document = new FileModel("my-file.tif");
+ document.setCmisLocation(folder.getCmisLocation() + "/my-file.tif");
+ document.setNodeRef(fileNode.getId());
+
+ restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("doclib");
+ restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
+
+ restClient.withCoreAPI().usingNode(document).getNodeRendition("doclib")
+ .assertThat().field("status").is("CREATED");
+ }
+}
diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java
index e69a47cce..594105873 100644
--- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java
+++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java
@@ -35,6 +35,7 @@ import org.testng.annotations.BeforeClass;
*
*
Preparing the data to index.
*
Preparing search requests.
+ *
* @author Michael Suzuki
*
*/
@@ -61,17 +62,15 @@ public class AbstractSearchTest extends RestTest
*/
nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes();
FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER);
- dataContent.usingSite(siteModel).createFolder(folder);
+ dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder);
//Create files
file = new FileModel("pangram.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog");
file2 = new FileModel("cars.txt", FileType.TEXT_PLAIN, "The landrover discovery is not a sports car");
ContentModel cm = new ContentModel();
cm.setCmisLocation(folder.getCmisLocation());
cm.setName(folder.getName());
- dataContent.usingSite(siteModel).usingResource(cm).createContent(file);
- dataContent.usingSite(siteModel).usingResource(cm).createContent(file2);
-
- Utility.waitToLoopTime(60);
+ dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file);
+ dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2);
}
/**
* Helper method which create an http post request to Search API end point.
diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java
index 4569ad349..675d5da3c 100644
--- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java
+++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java
@@ -18,8 +18,13 @@
*/
package org.alfresco.rest.search;
+import org.alfresco.utility.model.ContentModel;
+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.testng.Assert;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
@@ -29,28 +34,123 @@ import org.testng.annotations.Test;
*/
public class FingerPrintTest extends AbstractSearchTest
{
-// Disabled until solr4 resolution @Test(groups={TestGroup.SEARCH, TestGroup.REST_API})
+ private FileModel file1,file2,file3,file4;
+ @BeforeClass
+ public void indexSimilarFile() throws Exception
+ {
+ adminUserModel = dataUser.getAdminUser();
+ userModel = dataUser.createRandomTestUser();
+ siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
+ /*
+ * Create the following file structure for preconditions :
+ * |- folder
+ * |-- fox.txt
+ */
+ nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes();
+ FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER);
+ dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder);
+ file1 = new FileModel("pangram-banana.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy banana");
+ file2 = new FileModel("pangram-taco.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog that ate the taco");
+ file3 = new FileModel("pangram-cat.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy cat");
+ file4 = new FileModel("dog.txt", FileType.TEXT_PLAIN, "The quick brown fox ate the lazy dog");
+ ContentModel cm = new ContentModel();
+ cm.setCmisLocation(folder.getCmisLocation());
+ cm.setName(folder.getName());
+ dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file1);
+ dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2);
+ dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file3);
+ dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file4);
+ Thread.sleep(35000);//Allow indexing to complete.
+ }
/**
* Search similar document based on document finger print.
- * The data prep should have loaded a file
- * identical to the one loaded as part of this test.
+ * The data prep should have loaded 2 files which one is similar
+ * to the files loaded as part of this test.
+ * Note that for fingerprint to work it need a 5 word sequence.
+ *
* @throws Exception
*/
+ @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1})
public void search() throws Exception
{
- String uuid = file.getNodeRefWithoutVersion();
+ String uuid = file1.getNodeRefWithoutVersion();
Assert.assertNotNull(uuid);
- SearchResponse response = query(uuid);
- int count = response.getEntries().size();
String fingerprint = String.format("FINGERPRINT:%s", uuid);
- Thread.sleep(25000);//Allow indexing to complete.
- response = query(fingerprint);
- count = response.getEntries().size();
+ SearchResponse response = query(fingerprint);
+ int count = response.getEntries().size();
Assert.assertTrue(count > 1);
for(SearchNodeModel m :response.getEntries())
{
- m.getModel().assertThat().field("name").contains("pangram.txt");
+ String match = m.getModel().getName();
+ switch (match)
+ {
+ case "pangram.txt":
+ break;
+ case "pangram-banana.txt":
+ break;
+ case "pangram-taco.txt":
+ break;
+ case "pangram-cat.txt":
+ break;
+ default:
+ throw new AssertionError("Not a match to an expected file: " + m.getModel().getName());
+ }
+ m.getModel().assertThat().field("name").isNot("dog.txt");
+ m.getModel().assertThat().field("name").isNot("cars.txt");
+ }
+ }
+ @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1})
+ public void searchSimilar() throws Exception
+ {
+ String uuid = file2.getNodeRefWithoutVersion();
+ Assert.assertNotNull(uuid);
+ // In the response eneity there is a score of each doc, change below threshold to bring more like or less.
+ String fingerprint = String.format("FINGERPRINT:%s_68", uuid);
+ SearchResponse response = query(fingerprint);
+ int count = response.getEntries().size();
+ Assert.assertTrue(count > 1);
+ for(SearchNodeModel m :response.getEntries())
+ {
+ switch (m.getModel().getName())
+ {
+ case "pangram.txt":
+ break;
+ case "pangram-taco.txt":
+ break;
+ default:
+ throw new AssertionError("Not a match to an expected file: " + m.getModel().getName());
+ }
+ m.getModel().assertThat().field("name").isNot("pangram-banana.txt");
+ m.getModel().assertThat().field("name").isNot("pangram-cat.txt");
+ m.getModel().assertThat().field("name").isNot("dog.txt");
+ m.getModel().assertThat().field("name").isNot("cars.txt");
+ }
+ }
+ @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1})
+ public void searchSimilar67Percent() throws Exception
+ {
+ String uuid = file2.getNodeRefWithoutVersion();
+ Assert.assertNotNull(uuid);
+ String fingerprint = String.format("FINGERPRINT:%s_68", uuid);
+ SearchResponse response = query(fingerprint);
+ int count = response.getEntries().size();
+ Assert.assertTrue(count > 1);
+ for(SearchNodeModel m :response.getEntries())
+ {
+ switch (m.getModel().getName())
+ {
+ case "pangram.txt":
+ break;
+ case "pangram-taco.txt":
+ break;
+ case "pangram-cat.txt":
+ break;
+ default:
+ throw new AssertionError("Not a match to an expected file: " + m.getModel().getName());
+ }
+ m.getModel().assertThat().field("name").isNot("pangram-banana.txt");
+ m.getModel().assertThat().field("name").isNot("dog.txt");
+ m.getModel().assertThat().field("name").isNot("cars.txt");
}
}
-
}
diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java
new file mode 100644
index 000000000..01ee183e7
--- /dev/null
+++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2017 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.rest.search;
+
+import org.alfresco.utility.model.TestGroup;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests the search functionality using an ancestor path.
+ * Using the category as an example, it is a node that is located
+ * in root/rootCategory/classifiable. We now provide the ability to search by path
+ * so that we can return all the child elements of our target path.
+ * A search on root/rootCategory/classifiable should return Regions, Languages
+ * as they are the child elements of the given path.
+ *
+ * @author Michael Suzuki
+ *
+ */
+public class SearchAPATHTest extends AbstractSearchTest
+{
+
+ @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
+ /**
+ * {
+ * "query": {
+ * "query": "name:*"
+ * },
+ * "facetFields": {
+ * "facets": [
+ * {"field": "APATH", "prefix": "0" }
+ * ]
+ * }
+ * }
+ * Expected result
+ * entries[],
+ * "pagination": {
+ * "maxItems": 100,
+ * "hasMoreItems": true,
+ * "totalItems": 914,
+ * "count": 100,
+ * "skipCount": 0
+ * },
+ * "context": {
+ * "facetsFields": [{
+ * "buckets": [
+ * {
+ * "count": 913,
+ * "label": "0/5c09534f-3ca2-4272-bc25-064a7c1762b4"
+ * },
+ * {
+ * "count": 2,
+ * "label": "0/"
+ * }
+ * ],
+ * "label": "APATH"
+ * }],
+ * "consistency": {"lastTxId": 89}
+ * }
+ *}}
+ *
+ */
+ public void searchLevel0() throws Exception
+ {
+ SearchRequest searchQuery = new SearchRequest();
+ RestRequestQueryModel queryReq = new RestRequestQueryModel();
+ queryReq.setQuery("name:*");
+ searchQuery.setQuery(queryReq);
+
+ RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
+ List