mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
[ SEARCH-1485 ] moved RESTAPI tests under org.alfresco.service.search.rest namespace (package)
This commit is contained in:
@@ -1,134 +0,0 @@
|
||||
package org.alfresco.rest.renditions;
|
||||
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.model.RestRenditionInfoModel;
|
||||
import org.alfresco.rest.model.RestRenditionInfoModelCollection;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Sanity check for renditions through REST API.<br>
|
||||
* Tests upload files and then request renditions for those files. <br>
|
||||
* Renditions are requested based on supported renditions according to GET '/nodes/{nodeId}/renditions'. <br>
|
||||
*/
|
||||
@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION, TestGroup.RENDITIONS_REGRESSION})
|
||||
public class AvailableRenditionTests extends RenditionIntegrationTests
|
||||
{
|
||||
/** List of parameters used as an input to supportedRenditionTest - fileName, nodeId, renditionId, expectedMimeType **/
|
||||
private List<Object[]> renditionsToTest;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
super.dataPreparation();
|
||||
|
||||
// Upload files and get available renditions for each file
|
||||
List<String> toTest = Arrays.asList("doc", "xls", "ppt", "docx", "xlsx", "pptx", "msg", "pdf", "png", "gif", "jpg");
|
||||
List<Object[]> renditionsForFiles = new LinkedList<>();
|
||||
for (String extensions : toTest)
|
||||
{
|
||||
String sourceFile = "quick/quick." + extensions;
|
||||
renditionsForFiles.addAll(uploadFileAndGetAvailableRenditions(sourceFile));
|
||||
}
|
||||
|
||||
renditionsToTest = Collections.unmodifiableList(renditionsForFiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a source file and get all supported renditions for it.
|
||||
*/
|
||||
private List<Object[]> uploadFileAndGetAvailableRenditions(String sourceFile) throws Exception
|
||||
{
|
||||
|
||||
// Create folder & upload file
|
||||
RestNodeModel fileNode = uploadFile(sourceFile);
|
||||
FileModel file = new FileModel();
|
||||
file.setNodeRef(fileNode.getId());
|
||||
|
||||
List<Object[]> renditionsForFile = new LinkedList<>();
|
||||
|
||||
// Get supported renditions
|
||||
RestRenditionInfoModelCollection renditionsInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionsInfo();
|
||||
for (RestRenditionInfoModel m : renditionsInfo.getEntries())
|
||||
{
|
||||
RestRenditionInfoModel renditionInfo = m.onModel();
|
||||
String renditionId = renditionInfo.getId();
|
||||
String targetMimeType = renditionInfo.getContent().getMimeType();
|
||||
|
||||
renditionsForFile.add(new Object[]{sourceFile, fileNode.getId(), renditionId, targetMimeType});
|
||||
|
||||
}
|
||||
|
||||
return renditionsForFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that a particular rendition can be created for the file and that it has the expected Mime type
|
||||
*/
|
||||
@Test(dataProvider = "RenditionTestDataProvider", groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY})
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify renditions created for a selection of test files via POST nodes/{nodeId}/renditions")
|
||||
public void supportedRenditionTest(String fileName, String nodeId, String renditionId, String expectedMimeType) throws Exception
|
||||
{
|
||||
checkRendition(fileName, nodeId, renditionId, expectedMimeType);
|
||||
}
|
||||
|
||||
@DataProvider(name = "RenditionTestDataProvider")
|
||||
protected Iterator<Object[]> renditionTestDataProvider() throws Exception
|
||||
{
|
||||
return renditionsToTest.iterator();
|
||||
}
|
||||
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY})
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify that there are some available renditions.")
|
||||
public void renditionsAvailableTest()
|
||||
{
|
||||
Assert.assertFalse(renditionsToTest.isEmpty(), "No available renditions were reported for any of the test files.");
|
||||
}
|
||||
|
||||
@Test(dataProvider = "UnsupportedRenditionTestDataProvider",groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY})
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify that requests for unsupported renditions return 400 ")
|
||||
public void unsupportedRenditionTest(String sourceFile, String renditionId) throws Exception
|
||||
{
|
||||
RestNodeModel fileNode = uploadFile(sourceFile);
|
||||
|
||||
// 2. Request rendition of the file using RESTAPI
|
||||
FileModel file = new FileModel(sourceFile);
|
||||
file.setNodeRef(fileNode.getId());
|
||||
restClient.withCoreAPI().usingNode(file).createNodeRendition(renditionId);
|
||||
|
||||
Assert.assertEquals(restClient.getStatusCode(), HttpStatus.BAD_REQUEST.toString(),
|
||||
"Expected to see the rendition rejected. [" + sourceFile + ", " + renditionId + "] [source file, rendition ID] ");
|
||||
}
|
||||
|
||||
@DataProvider(name = "UnsupportedRenditionTestDataProvider")
|
||||
protected Iterator<Object[]> unsupportedRenditionTestDataProvider() throws Exception
|
||||
{
|
||||
String renditionId = "pdf";
|
||||
|
||||
List<Object[]> toTest = new LinkedList<>();
|
||||
toTest.add(new Object[]{"quick/quick.png", renditionId});
|
||||
toTest.add(new Object[]{"quick/quick.gif", renditionId});
|
||||
toTest.add(new Object[]{"quick/quick.jpg", renditionId});
|
||||
toTest.add(new Object[]{"quick/quick.pdf", renditionId});
|
||||
|
||||
return toTest.iterator();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,322 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.testng.Assert;
|
||||
import org.testng.TestException;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Faceted search test.
|
||||
* @author Michael Suzuki
|
||||
*
|
||||
*/
|
||||
public class FacetedSearchTest extends AbstractSearchTest
|
||||
{
|
||||
|
||||
/**
|
||||
* Perform the below facet query.
|
||||
* {
|
||||
* "query": {
|
||||
* "query": "cars",
|
||||
* "language": "afts"
|
||||
* },
|
||||
* "facetQueries": [
|
||||
* {"query": "content.size:[o TO 102400]", "label": "small"},
|
||||
* {"query": "content.size:[102400 TO 1048576]", "label": "medium"},
|
||||
* {"query": "content.size:[1048576 TO 16777216]", "label": "large"}
|
||||
* ],
|
||||
* "facetFields": {"facets": [{"field": "'content.size'"}]}
|
||||
* }
|
||||
*
|
||||
* Expected response
|
||||
* {"list": {
|
||||
* "entries": [... All the results],
|
||||
* "pagination": {
|
||||
* "maxItems": 100,
|
||||
* "hasMoreItems": false,
|
||||
* "totalItems": 61,
|
||||
* "count": 61,
|
||||
* "skipCount": 0
|
||||
* },
|
||||
* "facetsFields": [
|
||||
* {
|
||||
* "type": "query",
|
||||
* "label": "foo",
|
||||
* "buckets": [
|
||||
* {
|
||||
* "label": "small",
|
||||
* "filterQuery": "content.size:[0 TO 102400]",
|
||||
* "display": 1
|
||||
* },
|
||||
* {
|
||||
* "label": "large",
|
||||
* "filterQuery": "content.size:[1048576 TO 16777216]",
|
||||
* "metrics": [
|
||||
* {
|
||||
* "type": "count",
|
||||
* "value": {
|
||||
* "count": 0
|
||||
* }
|
||||
* }
|
||||
* ]
|
||||
* },
|
||||
* }}
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
waitForContentIndexing(file4.getContent(), true);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SEARCH,
|
||||
TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks facet queries for the Search api")
|
||||
public void searchWithQueryFaceting() throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
queryReq.setQuery("cars");
|
||||
query.setQuery(queryReq);
|
||||
|
||||
List<FacetQuery> facets = new ArrayList<FacetQuery>();
|
||||
facets.add(new FacetQuery("content.size:[0 TO 102400]", "small"));
|
||||
facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium"));
|
||||
facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large"));
|
||||
query.setFacetQueries(facets);
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
List<RestRequestFacetFieldModel> list = new ArrayList<>();
|
||||
list.add(new RestRequestFacetFieldModel("'content.size'"));
|
||||
facetFields.setFacets(list);
|
||||
query.setFacetFields(facetFields);
|
||||
query.setIncludeRequest(true);
|
||||
|
||||
SearchResponse response = query(query);
|
||||
|
||||
response.assertThat().entriesListIsNotEmpty();
|
||||
response.getContext().assertThat().field("facetQueries").isNotEmpty();
|
||||
|
||||
FacetFieldBucket facet = response.getContext().getFacetQueries().get(0);
|
||||
facet.assertThat().field("label").contains("small").and().field("count").isGreaterThan(0);
|
||||
facet.assertThat().field("label").contains("small").and().field("filterQuery").is("content.size:[0 TO 102400]");
|
||||
response.getContext().getFacetQueries().get(1).assertThat().field("label").contains("large")
|
||||
.and().field("count").isLessThan(1)
|
||||
.and().field("filterQuery").is("content.size:[1048576 TO 16777216]");
|
||||
response.getContext().getFacetQueries().get(2).assertThat().field("label").contains("medium")
|
||||
.and().field("count").isLessThan(1)
|
||||
.and().field("filterQuery").is("content.size:[102400 TO 1048576]");
|
||||
//We don't expect to see the FacetFields if group is being used.
|
||||
Assert.assertNull(response.getContext().getFacetsFields());
|
||||
Assert.assertNull(response.getContext().getFacets());
|
||||
}
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks facet queries for the Search api")
|
||||
/**
|
||||
* * Perform a group by faceting, below test groups the facet by group name foo.
|
||||
* {
|
||||
* "query": {
|
||||
* "query": "cars",
|
||||
* "language": "afts"
|
||||
* },
|
||||
* "facetQueries": [
|
||||
* {"query": "content.size:[o TO 102400]", "label": "small","group":"foo"},
|
||||
* {"query": "content.size:[102400 TO 1048576]", "label": "medium","group":"foo"},
|
||||
* {"query": "content.size:[1048576 TO 16777216]", "label": "large","group":"foo"}
|
||||
* ],
|
||||
* "facetFields": {"facets": [{"field": "'content.size'"}]}
|
||||
* }
|
||||
*
|
||||
* Expected response
|
||||
* {"list": {
|
||||
* "entries": [... All the results],
|
||||
* "pagination": {
|
||||
* "maxItems": 100,
|
||||
* "hasMoreItems": false,
|
||||
* "totalItems": 61,
|
||||
* "count": 61,
|
||||
* "skipCount": 0
|
||||
* },
|
||||
* "context": {
|
||||
* "consistency": {"lastTxId": 512},
|
||||
* //Added below as part of SEARCH-374
|
||||
* "facets": [
|
||||
* { "label": "foo",
|
||||
* "buckets": [
|
||||
* { "label": "small", "count": 61, "filterQuery": "content.size:[o TO 102400]"},
|
||||
* { "label": "large", "count": 0, "filterQuery": "content.size:[1048576 TO 16777216]"},
|
||||
* { "label": "medium", "count": 61, "filterQuery": "content.size:[102400 TO 1048576]"}
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
* }}
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void searchQueryFacetingWithGroup() throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
queryReq.setQuery("cars");
|
||||
query.setQuery(queryReq);
|
||||
|
||||
List<FacetQuery> facets = new ArrayList<FacetQuery>();
|
||||
facets.add(new FacetQuery("content.size:[0 TO 102400]", "small", "foo"));
|
||||
facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium", "foo"));
|
||||
facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large", "foo"));
|
||||
query.setFacetQueries(facets);
|
||||
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
List<RestRequestFacetFieldModel> list = new ArrayList<>();
|
||||
list.add(new RestRequestFacetFieldModel("'content.size'"));
|
||||
facetFields.setFacets(list);
|
||||
query.setFacetFields(facetFields);
|
||||
|
||||
SearchResponse response = query(query);
|
||||
|
||||
// We don't expect to see the FacetQueries if group is being used.
|
||||
Assert.assertTrue(response.getContext().getFacetQueries() == null);
|
||||
// Validate the facet field structure is correct.
|
||||
Assert.assertFalse(response.getContext().getFacets().isEmpty());
|
||||
Assert.assertEquals(response.getContext().getFacets().get(0).getLabel(), "foo");
|
||||
|
||||
RestGenericBucketModel bucket = response.getContext().getFacets().get(0).getBuckets().get(0);
|
||||
bucket.assertThat().field("label").isNotEmpty();
|
||||
Assert.assertEquals(bucket.getMetrics().get(0).getType(), "count");
|
||||
Assert.assertNotEquals(bucket.getMetrics().get(0).getValue(), "");
|
||||
bucket.assertThat().field("filterQuery").isNotEmpty();
|
||||
response.getContext().getFacets().get(0).getBuckets().forEach(action -> {
|
||||
switch (action.getLabel())
|
||||
{
|
||||
case "small":
|
||||
Assert.assertEquals(action.getFilterQuery(), "content.size:[0 TO 102400]");
|
||||
break;
|
||||
case "medium":
|
||||
Assert.assertEquals(action.getFilterQuery(), "content.size:[102400 TO 1048576]");
|
||||
break;
|
||||
case "large":
|
||||
Assert.assertEquals(action.getFilterQuery(), "content.size:[1048576 TO 16777216]");
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new TestException("Unexpected value returned");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks facet queries for the Search api")
|
||||
/**
|
||||
* {
|
||||
* "query": {
|
||||
* "query": "*"
|
||||
* },
|
||||
* "facetFields": {
|
||||
* "facets": [{"field": "cm:mimetype"},{"field": "modifier"}]
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public void searchWithFactedFields() throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
queryReq.setQuery(unique_searchString);
|
||||
query.setQuery(queryReq);
|
||||
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<RestRequestFacetFieldModel>();
|
||||
facets.add(new RestRequestFacetFieldModel("cm:mimetype"));
|
||||
facets.add(new RestRequestFacetFieldModel("modifier"));
|
||||
facetFields.setFacets(facets);
|
||||
query.setFacetFields(facetFields);
|
||||
|
||||
SearchResponse response = query(query);
|
||||
|
||||
Assert.assertFalse(response.getContext().getFacetsFields().isEmpty());
|
||||
Assert.assertNull(response.getContext().getFacetQueries());
|
||||
Assert.assertNull(response.getContext().getFacets());
|
||||
|
||||
RestResultBucketsModel model = response.getContext().getFacetsFields().get(0);
|
||||
Assert.assertEquals(model.getLabel(), "modifier");
|
||||
|
||||
model.assertThat().field("label").is("modifier");
|
||||
FacetFieldBucket bucket1 = model.getBuckets().get(0);
|
||||
bucket1.assertThat().field("label").is(userModel.getUsername());
|
||||
bucket1.assertThat().field("display").is(userModel.getUsername() + " FirstName LN-" + userModel.getUsername());
|
||||
bucket1.assertThat().field("filterQuery").is("modifier:\"" + userModel.getUsername() + "\"");
|
||||
bucket1.assertThat().field("count").is(1);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks facet queries for the Search api")
|
||||
/**
|
||||
* Test that items returned are in the format of generic facets.
|
||||
* {
|
||||
* "query": {
|
||||
* "query": "*"
|
||||
* },
|
||||
* "facetFields": {
|
||||
* "facets": [{"field": "cm:mimetype"},{"field": "modifier"}]
|
||||
* },
|
||||
* "facetFormat":"V2"
|
||||
* }
|
||||
*/
|
||||
public void searchWithFactedFieldsFacetFormatV2() throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
queryReq.setQuery(unique_searchString);
|
||||
query.setQuery(queryReq);
|
||||
query.setFacetFormat("V2");
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<RestRequestFacetFieldModel>();
|
||||
facets.add(new RestRequestFacetFieldModel("cm:mimetype"));
|
||||
facets.add(new RestRequestFacetFieldModel("modifier"));
|
||||
facetFields.setFacets(facets);
|
||||
query.setFacetFields(facetFields);
|
||||
|
||||
SearchResponse response = query(query);
|
||||
|
||||
Assert.assertNull(response.getContext().getFacetsFields());
|
||||
Assert.assertNull(response.getContext().getFacetQueries());
|
||||
Assert.assertFalse(response.getContext().getFacets().isEmpty());
|
||||
RestGenericFacetResponseModel model = response.getContext().getFacets().get(0);
|
||||
Assert.assertEquals(model.getLabel(), "modifier");
|
||||
|
||||
model.assertThat().field("label").is("modifier");
|
||||
RestGenericBucketModel bucket1 = model.getBuckets().get(0);
|
||||
bucket1.assertThat().field("label").is(userModel.getUsername());
|
||||
bucket1.assertThat().field("display").is(userModel.getUsername() + " FirstName LN-" + userModel.getUsername());
|
||||
bucket1.assertThat().field("filterQuery").is("modifier:\"" + userModel.getUsername() + "\"");
|
||||
bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=1}}]");
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Search end point Public API test with finger print.
|
||||
* @author Michael Suzuki
|
||||
*
|
||||
*/
|
||||
public class FingerPrintTest extends AbstractSearchTest
|
||||
{
|
||||
private FileModel file1, file2, file3, file4;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void indexSimilarFile() throws Exception
|
||||
{
|
||||
|
||||
/*
|
||||
* Create the following file structure in the same Site : In addition to the preconditions created in dataPreparation
|
||||
* |- folder
|
||||
* |-- pangram-banana.txt
|
||||
* |-- pangram-taco.txt
|
||||
* |-- pangram-cat.txt
|
||||
* |-- dog.txt
|
||||
*/
|
||||
|
||||
FolderModel folder = new FolderModel("The quick brown fox jumps over");
|
||||
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");
|
||||
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file1);
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2);
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3);
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4);
|
||||
|
||||
waitForContentIndexing(file4.getContent(), true);
|
||||
// Additional wait implemented to remove inconsistent failures. Ref: Search-1438 for details
|
||||
waitForIndexing("FINGERPRINT:" + file2.getNodeRefWithoutVersion(), true);
|
||||
waitForIndexing("FINGERPRINT:" + file3.getNodeRefWithoutVersion(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search similar document based on document finger print.
|
||||
* 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 = file1.getNodeRefWithoutVersion();
|
||||
Assert.assertNotNull(uuid);
|
||||
String fingerprint = String.format("FINGERPRINT:%s", uuid);
|
||||
SearchResponse response = query(fingerprint);
|
||||
int count = response.getEntries().size();
|
||||
Assert.assertTrue(count > 1);
|
||||
for (SearchNodeModel m : response.getEntries())
|
||||
{
|
||||
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 entity 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* 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 = searchRequestWithAPATHFacet("name:*", "0");
|
||||
SearchResponse response = query(searchQuery);
|
||||
|
||||
List<FacetFieldBucket> buckets = getBuckets(response);
|
||||
Assert.assertEquals(2, buckets.size());
|
||||
|
||||
buckets.forEach(bucket -> bucket.assertThat().field("label").contains("0/"));
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
|
||||
public void searchLevel0andIncludeSubLevel1() throws Exception
|
||||
{
|
||||
SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "1/");
|
||||
SearchResponse response = query(searchQuery);
|
||||
|
||||
List<FacetFieldBucket> buckets = getBuckets(response);
|
||||
Assert.assertEquals(4, buckets.size());
|
||||
|
||||
getFirstBucket(response).assertThat().field("label").contains("1/");
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
|
||||
public void searchLevel2() throws Exception
|
||||
{
|
||||
String queryString = "name:cars";
|
||||
|
||||
SearchRequest l1Request = searchRequestWithAPATHFacet(queryString, "1/");
|
||||
SearchResponse l1Response = query(l1Request);
|
||||
|
||||
String l2Prefix = getFirstBucket(l1Response).getLabel().replaceFirst("^1/", "2/");
|
||||
|
||||
SearchRequest l2Request = searchRequestWithAPATHFacet(queryString, l2Prefix);
|
||||
SearchResponse l2Response = query(l2Request);
|
||||
|
||||
FacetFieldBucket bucket = getFirstBucket(l2Response);
|
||||
bucket.assertThat().field("label").contains(l2Prefix);
|
||||
|
||||
String l3Prefix = bucket.getLabel().replaceFirst("^2/", "3/");
|
||||
|
||||
SearchRequest l3Request = searchRequestWithAPATHFacet(queryString, l3Prefix);
|
||||
SearchResponse l3response = query(l3Request);
|
||||
|
||||
List<FacetFieldBucket> buckets = getBuckets(l3response);
|
||||
Assert.assertEquals(1, buckets.size());
|
||||
|
||||
getFirstBucket(l3response).assertThat().field("label").contains(l3Prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link SearchRequest} for this test case.
|
||||
*
|
||||
* @param queryString the query string.
|
||||
* @param facetPrefix the facet prefix.
|
||||
* @return a new {@link SearchRequest} for this test case.
|
||||
*/
|
||||
private SearchRequest searchRequestWithAPATHFacet(String queryString, String facetPrefix)
|
||||
{
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
|
||||
RestRequestQueryModel query = new RestRequestQueryModel();
|
||||
query.setQuery(queryString);
|
||||
searchRequest.setQuery(query);
|
||||
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
facetFields.setFacets(Collections.singletonList(new RestRequestFacetFieldModel("APATH", facetPrefix)));
|
||||
searchRequest.setFacetFields(facetFields);
|
||||
|
||||
return searchRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the first bucket from the given response.
|
||||
*
|
||||
* @param response the results of a query execution.
|
||||
* @return the first bucket included in the search response.
|
||||
*/
|
||||
private FacetFieldBucket getFirstBucket(SearchResponse response)
|
||||
{
|
||||
return getBuckets(response).iterator().next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the buckets from the given response.
|
||||
* The method also makes sure the buckets list is not empty in the input response.
|
||||
*
|
||||
* @param response the results of a query execution.
|
||||
* @return the getBuckets included in the search response.
|
||||
*/
|
||||
private List<FacetFieldBucket> getBuckets(SearchResponse response)
|
||||
{
|
||||
List<RestResultBucketsModel> facetFields = response.getContext().getFacetsFields();
|
||||
Assert.assertNotNull(facetFields);
|
||||
Assert.assertFalse(facetFields.isEmpty());
|
||||
|
||||
List<FacetFieldBucket> buckets = facetFields.iterator().next().getBuckets();
|
||||
Assert.assertNotNull(buckets);
|
||||
Assert.assertFalse(buckets.isEmpty());
|
||||
|
||||
return buckets;
|
||||
}
|
||||
}
|
||||
@@ -1,309 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.reverse;
|
||||
|
||||
import static org.codehaus.groovy.runtime.InvokerHelper.asList;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.testng.AssertJUnit.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.rest.model.body.RestNodeLockBodyModel;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Search end point Public API test.
|
||||
* @author Michael Suzuki
|
||||
*
|
||||
*/
|
||||
public class SearchTest extends AbstractSearchTest
|
||||
{
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
waitForContentIndexing(file4.getContent(), true);
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API})
|
||||
public void searchOnIndexedData() throws Exception
|
||||
{
|
||||
SearchResponse nodes = query(unique_searchString);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
nodes.assertThat().entriesListIsNotEmpty();
|
||||
|
||||
SearchNodeModel entity = nodes.getEntryByIndex(0);
|
||||
entity.assertThat().field("search").contains("score");
|
||||
entity.getSearch().assertThat().field("score").isNotEmpty();
|
||||
Assert.assertEquals("pangram.txt",entity.getName());
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH,TestGroup.REST_API})
|
||||
public void searchNonIndexedData() throws Exception
|
||||
{
|
||||
SearchResponse nodes = query("yeti");
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
nodes.assertThat().entriesListIsEmpty();
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks its possible to include the original request in the response")
|
||||
public void searchWithRequest() throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
queryReq.setQuery("fox");
|
||||
query.setQuery(queryReq);
|
||||
query.setIncludeRequest(true);
|
||||
|
||||
SearchResponse response = query(query);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
response.getContext().assertThat().field("request").isNotEmpty();
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Tests a search request containing a sort clause.")
|
||||
public void searchWithOneSortClause() throws Exception
|
||||
{
|
||||
// Tests the ascending order first
|
||||
List<String> expectedOrder = asList("alfresco.txt", "cars.txt", "pangram.txt");
|
||||
|
||||
SearchRequest searchRequest = createQuery("cm_name:alfresco\\.txt cm_name:cars\\.txt cm_name:pangram\\.txt");
|
||||
searchRequest.addSortClause("FIELD", "name", true);
|
||||
|
||||
RestRequestFilterQueryModel filters = new RestRequestFilterQueryModel();
|
||||
filters.setQuery("SITE:'" + siteModel.getId() + "'");
|
||||
searchRequest.setFilterQueries(filters);
|
||||
|
||||
SearchResponse responseWithAscendingOrder = query(searchRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
assertEquals(
|
||||
expectedOrder,
|
||||
responseWithAscendingOrder.getEntries().stream()
|
||||
.map(SearchNodeModel::getModel)
|
||||
.map(SearchNodeModel::getName)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
// Reverts the expected order...
|
||||
reverse(expectedOrder);
|
||||
|
||||
// ...and test the descending order
|
||||
searchRequest.getSort().clear();
|
||||
searchRequest.addSortClause("FIELD", "name", false);
|
||||
|
||||
SearchResponse responseWithDescendingOrder = query(searchRequest);
|
||||
assertEquals(
|
||||
expectedOrder,
|
||||
responseWithDescendingOrder.getEntries().stream()
|
||||
.map(SearchNodeModel::getModel)
|
||||
.map(SearchNodeModel::getName)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the query execution with two sort clauses.
|
||||
* The first clause has always the same value for all matches so the test makes sure the request is correctly
|
||||
* processed and the returned order is determined by the second clause.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Tests a search request containing a sort clause.")
|
||||
public void searchWithTwoSortClauses() throws Exception
|
||||
{
|
||||
// Tests the ascending order first
|
||||
List<String> expectedOrder = asList("alfresco.txt", "cars.txt", "pangram.txt");
|
||||
|
||||
SearchRequest searchRequest = createQuery("cm_name:alfresco\\.txt cm_name:cars\\.txt cm_name:pangram\\.txt");
|
||||
searchRequest.addSortClause("FIELD", "name", true);
|
||||
searchRequest.addSortClause("FIELD", "createdByUser.id", true);
|
||||
|
||||
RestRequestFilterQueryModel filters = new RestRequestFilterQueryModel();
|
||||
filters.setQuery("SITE:'" + siteModel.getId() + "'");
|
||||
searchRequest.setFilterQueries(filters);
|
||||
|
||||
SearchResponse responseWithAscendingOrder = query(searchRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
assertEquals(
|
||||
expectedOrder,
|
||||
responseWithAscendingOrder.getEntries().stream()
|
||||
.map(SearchNodeModel::getModel)
|
||||
.map(SearchNodeModel::getName)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
// Reverts the expected order...
|
||||
reverse(expectedOrder);
|
||||
|
||||
// ...and test the descending order
|
||||
searchRequest.getSort().clear();
|
||||
searchRequest.addSortClause("FIELD", "name", false);
|
||||
searchRequest.addSortClause("FIELD", "createdByUser.id", true);
|
||||
|
||||
SearchResponse responseWithDescendingOrder = query(searchRequest);
|
||||
assertEquals(
|
||||
expectedOrder,
|
||||
responseWithDescendingOrder.getEntries().stream()
|
||||
.map(SearchNodeModel::getModel)
|
||||
.map(SearchNodeModel::getName)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) @TestRail(section = {
|
||||
TestGroup.REST_API, TestGroup.SEARCH,
|
||||
TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, description = "Checks the \"include\" request parameter support the 'permissions' option") public void searchQuery_includePermissions_shouldReturnNodeWithPermissionsInformation()
|
||||
throws Exception
|
||||
{
|
||||
String query = "fox";
|
||||
String include = "permissions";
|
||||
|
||||
SearchRequest retrievalQueryIncludingPermissionsInformation = createQuery(query);
|
||||
retrievalQueryIncludingPermissionsInformation.setInclude(asList(include));
|
||||
|
||||
query(retrievalQueryIncludingPermissionsInformation);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("list.entries[0].entry.permissions", notNullValue());
|
||||
|
||||
SearchRequest retrievalQueryNotIncludingLockInformation = createQuery(query);
|
||||
|
||||
query(retrievalQueryNotIncludingLockInformation);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("list.entries[0].entry.permissions", nullValue());
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks the \"include\" request parameter support the 'isLocked' option")
|
||||
public void searchQuery_includeIsLocked_shouldReturnNodeWithLockInformation() throws Exception {
|
||||
String query = "fox";
|
||||
String include = "isLocked";
|
||||
|
||||
SearchRequest retrievalQueryIncludingLockInformation = createQuery(query);
|
||||
retrievalQueryIncludingLockInformation.setInclude(asList(include));
|
||||
|
||||
query(retrievalQueryIncludingLockInformation);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", equalTo(false));
|
||||
|
||||
RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel();
|
||||
lockBodyModel.setLifetime("EPHEMERAL");
|
||||
lockBodyModel.setTimeToExpire(20);
|
||||
lockBodyModel.setType("FULL");
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).usingParams("include=isLocked").lockNode(lockBodyModel);
|
||||
|
||||
query(retrievalQueryIncludingLockInformation);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", equalTo(true));
|
||||
|
||||
SearchRequest retrievalQueryNotIncludingLockInformation = createQuery(query);
|
||||
|
||||
query(retrievalQueryNotIncludingLockInformation);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", nullValue());
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks the \"include\" request parameter does not support the 'notValid' option")
|
||||
public void searchQuery_includeInvalid_shouldReturnBadResponse() throws Exception
|
||||
{
|
||||
String query = "fox";
|
||||
String notValidInclude = "notValid";
|
||||
SearchRequest permissionsRetrieval = createQuery(query);
|
||||
permissionsRetrieval.setInclude(asList(notValidInclude));
|
||||
|
||||
query(permissionsRetrieval);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
|
||||
restClient.onResponse()
|
||||
.assertThat()
|
||||
.body("error.briefSummary", containsString("An invalid argument was received "+notValidInclude));
|
||||
}
|
||||
|
||||
// Test that when fields parameter is set, only restricted fields appear in the response
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
public void searchWithFields() throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
queryReq.setQuery("alfresco");
|
||||
query.setQuery(queryReq);
|
||||
|
||||
// Restrict to fields: parentId
|
||||
List<String> fields = new ArrayList<String>();
|
||||
fields.add("parentId");
|
||||
query.setFields(fields);
|
||||
|
||||
query(query);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
// Only Field parentId is included in the response
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0].parentId", Matchers.notNullValue());
|
||||
// Usual Fields such as 'name, id' aren't included in the response
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0].id", Matchers.nullValue());
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API })
|
||||
public void searchSpecialCharacters() throws Exception
|
||||
{
|
||||
// Create a file with Special Characters
|
||||
String specialCharfileName = "è¥äæ§ç§-åæ.pdf";
|
||||
FileModel file = new FileModel(specialCharfileName, "è¥äæ§ç§-忬¯¸" + "è¥äæ§ç§-忬¯¸", "è¥äæ§ç§-忬¯¸", FileType.TEXT_PLAIN,
|
||||
"Text file with Special Characters: " + specialCharfileName);
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).createContent(file);
|
||||
|
||||
waitForIndexing(file.getName(), true);
|
||||
|
||||
// Search
|
||||
SearchRequest searchReq = createQuery("name:'" + specialCharfileName + "'");
|
||||
SearchResponse nodes = query(searchReq);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
nodes.assertThat().entriesListIsNotEmpty();
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.equalToIgnoringCase(specialCharfileName));
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import org.alfresco.rest.exception.EmptyRestModelCollectionException;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Shard info end point REST API test.
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
*/
|
||||
public class ShardInfoTest extends AbstractSearchTest
|
||||
{
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n})
|
||||
public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException
|
||||
{
|
||||
RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
info.assertThat().entriesListIsNotEmpty();
|
||||
assertEquals(info.getPagination().getTotalItems().intValue(), 2);
|
||||
|
||||
List<String> stores = Arrays.asList("workspace://SpacesStore", "archive://SpacesStore");
|
||||
List<String> baseUrls = Arrays.asList("/solr/alfresco", "/solr/archive");
|
||||
|
||||
List<RestShardInfoModel> entries = info.getEntries();
|
||||
for (RestShardInfoModel shardInfoModel : entries)
|
||||
{
|
||||
RestShardInfoModel model = shardInfoModel.getModel();
|
||||
assertEquals(model.getTemplate(), "rerank");
|
||||
assertEquals(model.getMode(), "MASTER");
|
||||
assertEquals(model.getShardMethod(), "DB_ID");
|
||||
assertTrue(model.getHasContent());
|
||||
stores.contains(model.getStores());
|
||||
List<RestShardModel> shards = model.getShards();
|
||||
assertNotNull(shards);
|
||||
RestShardModel shard = shards.iterator().next();
|
||||
assertNotNull(shard);
|
||||
List<RestInstanceModel> instances = shard.getInstances();
|
||||
assertNotNull(instances);
|
||||
RestInstanceModel instance = instances.iterator().next();
|
||||
assertNotNull(instance);
|
||||
baseUrls.contains(instance.getBaseUrl());
|
||||
// TODO: Ideally Solr Host and Port should be Parameterised
|
||||
assertEquals(instance.getHost(), "search");
|
||||
assertEquals(instance.getPort().intValue(), 8983);
|
||||
assertEquals(instance.getState(), "ACTIVE");
|
||||
assertEquals(instance.getMode(), "MASTER");
|
||||
}
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n})
|
||||
public void getShardInfoWithoutAdminAuthority() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(dataUser.createRandomTestUser()).withShardInfoAPI().getInfo();
|
||||
restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search.solr;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import javax.json.JsonArrayBuilder;
|
||||
|
||||
import org.alfresco.rest.core.JsonBodyGenerator;
|
||||
import org.alfresco.rest.model.RestTextResponse;
|
||||
import org.alfresco.rest.search.AbstractSearchTest;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests for solr/alfresco Solr API.
|
||||
*
|
||||
* @author Meenal Bhave
|
||||
*/
|
||||
public class SearchSolrAPITest extends AbstractSearchTest
|
||||
{
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 01)
|
||||
public void testGetSolrConfig() throws Exception
|
||||
{
|
||||
RestTextResponse response = restClient.authenticateUser(adminUserModel).withSolrAPI().getConfig();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().content(Matchers.containsString("config"));
|
||||
Assert.assertNotNull(response.getJsonValueByPath("config.requestHandler"));
|
||||
Assert.assertNotNull(response.getJsonObjectByPath("config.requestHandler"));
|
||||
|
||||
// TODO: Following asserts fail with error:
|
||||
/*
|
||||
* java.lang.IllegalStateException: Expected response body to be verified as JSON, HTML or XML but content-type 'text/plain' is not supported out of the box.
|
||||
* Try registering a custom parser using: RestAssured.registerParser("text/plain", <parser type>);
|
||||
*/
|
||||
|
||||
// response.assertThat().body("config.requestHandler", Matchers.notNullValue());
|
||||
// restClient.onResponse().assertThat().body("config.requestHandler",Matchers.notNullValue());
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 02)
|
||||
public void testEditSolrConfig() throws Exception
|
||||
{
|
||||
String expectedError = "solrconfig editing is not enabled due to disable.configEdit";
|
||||
|
||||
JsonArrayBuilder argsArray = JsonBodyGenerator.defineJSONArray();
|
||||
argsArray.add("ANYARGS");
|
||||
|
||||
String postBody = JsonBodyGenerator.defineJSON()
|
||||
.add("add-listener", JsonBodyGenerator.defineJSON()
|
||||
.add("event", "postCommit")
|
||||
.add("name", "newlistener")
|
||||
.add("class", "solr.RunExecutableListener")
|
||||
.add("exe", "ANYCOMMAND")
|
||||
.add("dir", "/usr/bin/")
|
||||
.add("args", argsArray)).build().toString();
|
||||
|
||||
// RestTextResponse response =
|
||||
restClient.authenticateUser(adminUserModel).withSolrAPI().postConfig(postBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
|
||||
restClient.onResponse().assertThat().content(Matchers.containsString(expectedError));
|
||||
|
||||
// TODO: Following asserts fail with error:
|
||||
/*
|
||||
* java.lang.IllegalStateException: Expected response body to be verified as JSON, HTML or XML but content-type 'text/plain' is not supported out of the box.
|
||||
* Try registering a custom parser using: RestAssured.registerParser("text/plain", <parser type>);
|
||||
*/
|
||||
|
||||
// response.assertThat().body("error.msg", Matchers.contains(expectedError));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 03)
|
||||
public void testGetSolrConfigOverlay() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigOverlay();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().content(Matchers.containsString("overlay"));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 04)
|
||||
public void testGetSolrConfigParams() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigParams();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().content(Matchers.containsString("response"));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 05)
|
||||
public void testGetSolrSelect() throws Exception
|
||||
{
|
||||
String queryParams = "{!xmlparser v='<!DOCTYPE a SYSTEM \"http://localhost:4444/executed\"><a></a>'}";
|
||||
|
||||
String encodedQueryParams = URLEncoder.encode(queryParams, "UTF-8");
|
||||
|
||||
restClient.authenticateUser(dataContent.getAdminUser()).withParams(encodedQueryParams).withSolrAPI().getSelectQuery();
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
|
||||
String errorMsg = "No QueryObjectBuilder defined for node a in {q={!xmlparser";
|
||||
Assert.assertTrue(restClient.onResponse().getResponse().body().xmlPath().getString("response").contains(errorMsg));
|
||||
}
|
||||
}
|
||||
@@ -1,781 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search.sql;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.equalToIgnoringCase;
|
||||
import static org.hamcrest.Matchers.everyItem;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.isIn;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.search.AbstractSearchTest;
|
||||
import org.alfresco.rest.search.SearchSqlRequest;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests for /sql end point Search API.
|
||||
*
|
||||
* @author Meenal Bhave
|
||||
*/
|
||||
public class SearchSQLAPITest extends AbstractSearchTest
|
||||
{
|
||||
/**
|
||||
* Path selector to get the values of all cm_name entries for returned search results.
|
||||
* <p>
|
||||
* For example it will retrieve the "alfresco.txt" from:
|
||||
* <pre>
|
||||
* {"list": {
|
||||
* "entries": [
|
||||
* {"entry": [{
|
||||
* "label": "cm_name",
|
||||
* "value": "alfresco.txt"
|
||||
* }]},
|
||||
* ...
|
||||
* </pre>
|
||||
*/
|
||||
private static final String CM_NAME_VALUES = "list.entries.collect {it.entry.findAll {it.label == 'cm_name'}}.flatten().value";
|
||||
String sql = "select SITE, CM_OWNER from alfresco group by SITE,CM_OWNER";
|
||||
String[] locales = { "en-US" };
|
||||
String solrFormat = "solr";
|
||||
|
||||
/**
|
||||
* API post:
|
||||
* {
|
||||
* "stmt": "select SITE from alfresco",
|
||||
* "locales" : ["en_US"],
|
||||
* "format" : "solr",
|
||||
* "timezone":"",
|
||||
* "includeMetadata":false
|
||||
* }
|
||||
* Example Response: In Solr Format
|
||||
* {
|
||||
* "result-set":
|
||||
* {
|
||||
* "docs":
|
||||
* [
|
||||
* {
|
||||
* "SITE":
|
||||
* [
|
||||
* "swsdp"
|
||||
* ]
|
||||
* },
|
||||
* {
|
||||
* "SITE":
|
||||
* [
|
||||
* "swsdp"
|
||||
* ]
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 01)
|
||||
public void testWithSolr() throws Exception
|
||||
{
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setFormat(solrFormat);
|
||||
sqlRequest.setLocales(locales);
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* API post example:
|
||||
* {
|
||||
* "stmt": "select SITE from alfresco",
|
||||
* "locales" : ["en_US"],
|
||||
* "format" : "json",
|
||||
* "timezone":"",
|
||||
* "includeMetadata":false
|
||||
* }
|
||||
* Example Response: In json Format
|
||||
* {
|
||||
* "list":
|
||||
* {
|
||||
* "pagination":
|
||||
* {
|
||||
"count": 103,
|
||||
"hasMoreItems": false,
|
||||
"totalItems": 103,
|
||||
"skipCount": 0,
|
||||
"maxItems": 1000
|
||||
},
|
||||
* "entries":
|
||||
* [
|
||||
* "entry": [
|
||||
{
|
||||
"label": "SITE",
|
||||
"value": "[\"swsdp\"]"
|
||||
}
|
||||
],
|
||||
"entry": [
|
||||
{
|
||||
"label": "SITE",
|
||||
"value": "[\"swsdp\"]"
|
||||
}
|
||||
]
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 02)
|
||||
public void testWithJson() throws Exception
|
||||
{
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setLocales(locales);
|
||||
// Format not set
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue());
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setLocales(locales);
|
||||
sqlRequest.setFormat("json"); // Format json
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue());
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setLocales(locales);
|
||||
sqlRequest.setFormat("abcd"); // Format any other than solr
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* API post:
|
||||
* {
|
||||
* "stmt": "select SITE from alfresco",
|
||||
* "locales" : ["en_US"],
|
||||
* "format" : "solr",
|
||||
* "timezone":"",
|
||||
* "includeMetadata":true
|
||||
* }
|
||||
* Example Response: In Solr Format: Includes metadata: aliases, fields, isMetadata=true
|
||||
* {
|
||||
* "result-set": {
|
||||
* "docs": [
|
||||
* {
|
||||
* "aliases": {
|
||||
* "SITE": "SITE"
|
||||
* },
|
||||
* "isMetadata": true,
|
||||
* "fields": [
|
||||
* "SITE"
|
||||
* ]
|
||||
* },
|
||||
* {
|
||||
* "SITE": [
|
||||
* "swsdp"
|
||||
* ]
|
||||
* },
|
||||
* {
|
||||
* "SITE": [
|
||||
* "swsdp"
|
||||
* ]
|
||||
* },
|
||||
* {
|
||||
* "RESPONSE_TIME": 79,
|
||||
* "EOF": true
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 03)
|
||||
public void testWithSolrIncludeMetadata() throws Exception
|
||||
{
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setFormat(solrFormat);
|
||||
sqlRequest.setLocales(locales);
|
||||
sqlRequest.setIncludeMetadata(true);
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", equalToIgnoringCase("SITE"));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", is(true));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].fields[0]", equalToIgnoringCase("SITE"));
|
||||
}
|
||||
|
||||
/**
|
||||
* API post example:
|
||||
* {
|
||||
* "stmt": "select SITE from alfresco limit 2",
|
||||
* "locales" : ["en_US"],
|
||||
* "format" : "json",
|
||||
* "timezone":"",
|
||||
* "includeMetadata":false
|
||||
* }
|
||||
* Example Response: In json Format
|
||||
* {
|
||||
* "list":
|
||||
* {
|
||||
* "pagination":
|
||||
* {
|
||||
"count": 3,
|
||||
"hasMoreItems": false,
|
||||
"totalItems": 3,
|
||||
"skipCount": 0,
|
||||
"maxItems": 1000
|
||||
},
|
||||
* "entries":
|
||||
* [
|
||||
* "entry": [
|
||||
{
|
||||
"label": "aliases",
|
||||
"value": "{\"SITE\":\"SITE\"}"
|
||||
},
|
||||
{
|
||||
"label": "isMetadata",
|
||||
"value": "true"
|
||||
},
|
||||
{
|
||||
"label": "fields",
|
||||
"value": "[\"SITE\"]"
|
||||
}
|
||||
]
|
||||
},
|
||||
* "entry": [
|
||||
{
|
||||
"label": "SITE",
|
||||
"value": "[\"swsdp\"]"
|
||||
}
|
||||
],
|
||||
"entry": [
|
||||
{
|
||||
"label": "SITE",
|
||||
"value": "[\"swsdp\"]"
|
||||
}
|
||||
]
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 04)
|
||||
public void testWithJsonIncludeMetadata() throws Exception
|
||||
{
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setFormat("");
|
||||
sqlRequest.setLocales(locales);
|
||||
sqlRequest.setIncludeMetadata(true);
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("aliases"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("{\"SITE\":\"SITE\",\"cm_owner\":\"CM_OWNER\"}"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", equalToIgnoringCase("isMetadata"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", is("true"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][2].label", equalToIgnoringCase("fields"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][2].value", equalToIgnoringCase("[\"SITE\",\"cm_owner\"]"));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 05)
|
||||
public void testIncludeMetadataFalse() throws Exception
|
||||
{
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setFormat("solr"); // Format solr
|
||||
sqlRequest.setIncludeMetadata(false);
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].fields", Matchers.nullValue());
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setIncludeMetadata(false);
|
||||
sqlRequest.setFormat("json"); // Format json
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", not("aliases"));
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setIncludeMetadata(false); // Format not set
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", not("aliases"));
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setFormat(solrFormat); // IncludeMetadata = false when not specified
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].fields", Matchers.nullValue());
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 06)
|
||||
public void testLocales() throws Exception
|
||||
{
|
||||
String[] noLocales = {}; // Not specified
|
||||
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setLocales(noLocales);
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
String[] singleLocale = { "en-Uk" };
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setLocales(singleLocale);
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
String[] multipleLocales = { "en-US", "ja" };
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setLocales(multipleLocales);
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 07)
|
||||
public void testTimezone() throws Exception
|
||||
{
|
||||
String timezone = ""; // Not specified
|
||||
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setTimezone(timezone);
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
timezone = "UTC"; // UTC
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setTimezone(timezone);
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
timezone = "false"; // Invalid timezone is ignored
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setTimezone(timezone);
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 8)
|
||||
public void testAggregateSQL() throws Exception
|
||||
{
|
||||
String agSql = "select count(*) FROM alfresco where TYPE='cm:content'";
|
||||
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(agSql);
|
||||
|
||||
RestResponse response = searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("list.entries", Matchers.notNullValue());
|
||||
response.assertThat().body("list.entries.entry[0][0].value", not("0"));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 9)
|
||||
public void testLimit() throws Exception
|
||||
{
|
||||
Integer defaultLimit = 1000;
|
||||
|
||||
Integer limit = null; // Limit defaults to the default setting when null
|
||||
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setLimit(limit);
|
||||
|
||||
RestResponse response = searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(defaultLimit));
|
||||
|
||||
limit = 0; // Limit defaults to the default setting when 0
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setLimit(limit);
|
||||
|
||||
response = searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(defaultLimit));
|
||||
|
||||
limit = 100; // Limit is applied correctly, with maxItems = limit
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setLimit(limit);
|
||||
|
||||
response = searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(limit));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 10)
|
||||
public void testAuthenticationError() throws Exception
|
||||
{
|
||||
UserModel dummyUser = dataUser.createRandomTestUser("UserSearchDummy");
|
||||
dummyUser.setPassword("incorrect-password");
|
||||
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setLocales(locales);
|
||||
|
||||
restClient.authenticateUser(dummyUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 11)
|
||||
public void testPermissions() throws Exception
|
||||
{
|
||||
UserModel userNoPerm = dataUser.createRandomTestUser("UserSearchNoPerm");
|
||||
UserModel userPerm = dataUser.createRandomTestUser("UserSearchPerm");
|
||||
|
||||
dataUser.addUserToSite(userPerm, siteModel, UserRole.SiteContributor);
|
||||
|
||||
String siteSQL = "select SITE, CM_OWNER from alfresco where SITE='" + siteModel.getId() + "'";
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(siteSQL);
|
||||
|
||||
// 0 results expected for query as User does not have access to the private site
|
||||
restClient.authenticateUser(userNoPerm).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("list.pagination.count", is(0));
|
||||
restClient.onResponse().assertThat().body("list.pagination.totalItems", is(0));
|
||||
restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", is(false));
|
||||
restClient.onResponse().assertThat().body("list.entries", empty());
|
||||
|
||||
// Results expected for query as User does has access to the private site
|
||||
restClient.authenticateUser(userPerm).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0));
|
||||
restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("SITE"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("[\"" + siteModel.getId() + "\"]"));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 12)
|
||||
public void testErrors() throws Exception
|
||||
{
|
||||
String incorrectSQL = ""; // Missing SQL
|
||||
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(incorrectSQL);
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
|
||||
restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Required stmt parameter is missing"));
|
||||
|
||||
incorrectSQL = "select SITE from unknownTable"; // Wrong table name
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(incorrectSQL);
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
|
||||
restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue());
|
||||
// restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Table 'unknownTable' not found"));
|
||||
|
||||
incorrectSQL = "select Column1 from alfresco"; // Wrong ColumnName
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(incorrectSQL);
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
|
||||
restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Column 'Column1' not found"));
|
||||
|
||||
incorrectSQL = "select SITE alfresco"; // BAD SQL Grammar: from missing
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(incorrectSQL);
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
|
||||
restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Unable to execute the query"));
|
||||
|
||||
incorrectSQL = "select SITE, CM_OWNER from alfresco group by SITE"; // BAD SQL Grammar: CM_OWNER is not being grouped
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(incorrectSQL);
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
|
||||
restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Expression 'CM_OWNER' is not being grouped"));
|
||||
|
||||
incorrectSQL = "delete SITE from alfresco"; // BAD SQL Grammar
|
||||
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(incorrectSQL);
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
|
||||
restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Was expecting one of"));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.NOT_INSIGHT_ENGINE }, priority = 13)
|
||||
public void testErrorForSQLAPIWithASS() throws Exception
|
||||
{
|
||||
String acsVersion = serverHealth.getAlfrescoVersion();
|
||||
HttpStatus expectedStatus = HttpStatus.OK;
|
||||
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setLocales(locales);
|
||||
|
||||
// Set expected result based on ACS Version and ASS Version
|
||||
if (!acsVersion.startsWith("6"))
|
||||
{
|
||||
expectedStatus = HttpStatus.NOT_FOUND;
|
||||
}
|
||||
else
|
||||
{
|
||||
expectedStatus = HttpStatus.BAD_REQUEST;
|
||||
}
|
||||
|
||||
restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(expectedStatus);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 14)
|
||||
public void testSelectStar() throws Exception
|
||||
{
|
||||
// Select * with Limit, json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select * from alfresco");
|
||||
sqlRequest.setLimit(1);
|
||||
|
||||
RestResponse response = searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(1));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("PATH"));
|
||||
|
||||
// Select * with Limit, solr format: Also covered in JDBC
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select * from alfresco");
|
||||
sqlRequest.setFormat("solr");
|
||||
sqlRequest.setIncludeMetadata(true);
|
||||
sqlRequest.setLimit(1);
|
||||
|
||||
response = searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_name", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_created", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_creator", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_modified", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_modifier", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_owner", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.OWNER", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.TYPE", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.LID", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.DBID", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_title", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_description", Matchers.notNullValue());
|
||||
|
||||
// This type of assertion is required because of a '.' in the field name
|
||||
Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.size=cm_content.size"));
|
||||
Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.mimetype=cm_content.mimetype"));
|
||||
Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.encoding=cm_content.encoding"));
|
||||
Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.locale=cm_content.locale"));
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_lockOwner", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PARENT", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PATH", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PRIMARYPARENT", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.ASPECT", Matchers.notNullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.QNAME", Matchers.notNullValue());
|
||||
|
||||
// Test that cm_content and any other random field does not appear in the response
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_content", Matchers.nullValue());
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.RandomNonExistentField", Matchers.nullValue());
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 15)
|
||||
public void testDistinct() throws Exception
|
||||
{
|
||||
// Select distinct site: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select distinct Site from alfresco");
|
||||
sqlRequest.setLimit(10);
|
||||
|
||||
RestResponse response = searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(10));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("site"));
|
||||
|
||||
// Select distinct cm_name: solr format
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select distinct cm_name from alfresco limit 5");
|
||||
sqlRequest.setFormat("solr");
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.notNullValue());
|
||||
}
|
||||
|
||||
/** Check that a filter query can affect which results are included. */
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 16)
|
||||
public void testFilterQuery() throws Exception
|
||||
{
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
String siteSQL = "select SITE, CM_OWNER from alfresco where SITE='" + siteModel.getId() + "'";
|
||||
sqlRequest.setSql(siteSQL);
|
||||
// Add a filter query to only include results from inside the site (i.e. all results).
|
||||
String[] filterQuery = { "SITE:'" + siteModel.getId() + "'" };
|
||||
sqlRequest.setFilterQuery(filterQuery);
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0));
|
||||
restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("SITE"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("[\"" + siteModel.getId() + "\"]"));
|
||||
|
||||
// Now try instead removing everything from the site (i.e. all results).
|
||||
String[] inverseFilterQuery = { "-SITE:'" + siteModel.getId() + "'" };
|
||||
sqlRequest.setFilterQuery(inverseFilterQuery);
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("list.pagination.count", is(0));
|
||||
restClient.onResponse().assertThat().body("list.pagination.totalItems", is(0));
|
||||
restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", is(false));
|
||||
restClient.onResponse().assertThat().body("list.entries", empty());
|
||||
}
|
||||
|
||||
/** Check that the combination of multiple filter queries produce the intersection of results. */
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 17)
|
||||
public void testCombiningFilterQueries() throws Exception
|
||||
{
|
||||
String siteSQL = "select cm_name from alfresco where SITE='" + siteModel.getId() + "'";
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(siteSQL);
|
||||
// Add a filter query to only include results from inside the site (i.e. all results).
|
||||
String[] filterQueries = { "-cm_name:'cars'", "-cm_name:'pangram'" };
|
||||
sqlRequest.setFilterQuery(filterQueries);
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0));
|
||||
restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0));
|
||||
// Check that pangram.txt and cars.txt were both filtered out.
|
||||
restClient.onResponse().assertThat()
|
||||
.body(CM_NAME_VALUES, everyItem(not(isIn(asList("pangram.txt", "cars.txt")))));
|
||||
}
|
||||
|
||||
/** Check that an empty list of filter queries doesn't remove anything from the results. */
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 18)
|
||||
public void testEmptyFilterQuery() throws Exception
|
||||
{
|
||||
String siteSQL = "select cm_name from alfresco where SITE='" + siteModel.getId() + "'";
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(siteSQL);
|
||||
// Add an empty list of filter queries.
|
||||
sqlRequest.setFilterQuery(new String[]{});
|
||||
|
||||
searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
// Check that the cm_names of all nodes in the site are returned.
|
||||
restClient.onResponse().assertThat()
|
||||
.body(CM_NAME_VALUES, containsInAnyOrder("documentLibrary", SEARCH_DATA_SAMPLE_FOLDER, "pangram.txt", "cars.txt", "alfresco.txt", unique_searchString + ".txt"));
|
||||
}
|
||||
}
|
||||
@@ -1,256 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search.sql;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.search.AbstractSearchTest;
|
||||
import org.alfresco.rest.search.SearchSqlJDBCRequest;
|
||||
import org.alfresco.rest.search.SearchSqlRequest;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import org.hamcrest.Matchers;
|
||||
|
||||
/**
|
||||
* Tests for /sql end point Search API: Phrase Searching.
|
||||
*
|
||||
* @author Meenal Bhave
|
||||
*/
|
||||
public class SearchSQLPhraseTest extends AbstractSearchTest
|
||||
{
|
||||
FileModel fileBanana, fileYellowBanana, fileBigYellowBanana, fileBigBananaBoat, fileYellowBananaBigBoat, fileBigYellowBoat;
|
||||
|
||||
List expectedContent = new ArrayList<String>();
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
super.dataPreparation();
|
||||
|
||||
// Create files with different phrases
|
||||
fileBanana = new FileModel(unique_searchString + "-1.txt", "banana", "phrase searching", FileType.TEXT_PLAIN, "banana");
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBanana);
|
||||
|
||||
fileYellowBanana = new FileModel(unique_searchString + "-2.txt", "yellow banana", "phrase searching", FileType.TEXT_PLAIN, "yellow banana");
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBanana);
|
||||
|
||||
fileBigYellowBanana = new FileModel(unique_searchString + "-3.txt", "big yellow banana", "phrase searching", FileType.TEXT_PLAIN, "big yellow banana");
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBanana);
|
||||
|
||||
fileBigBananaBoat = new FileModel(unique_searchString + "-4.txt", "big boat", "phrase searching", FileType.TEXT_PLAIN, "big boat");
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigBananaBoat);
|
||||
|
||||
fileYellowBananaBigBoat = new FileModel(unique_searchString + "-5.txt", "yellow banana big boat", "phrase searching", FileType.TEXT_PLAIN, "yellow banana big boat");
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBananaBigBoat);
|
||||
|
||||
fileBigYellowBoat = new FileModel(unique_searchString + "-6.txt", "big yellow boat", "phrase searching", FileType.TEXT_PLAIN, "big yellow boat");
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBoat);
|
||||
|
||||
waitForIndexing(fileBigYellowBoat.getName(), true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 1)
|
||||
public void testPhraseQueries() throws Exception
|
||||
{
|
||||
// yellow banana: 5 results expected
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana)'");
|
||||
sqlRequest.setLimit(10);
|
||||
|
||||
RestResponse response = searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
// Set Expected Result
|
||||
expectedContent = new ArrayList<String>();
|
||||
expectedContent.add(Arrays.asList(fileBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileYellowBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent()));
|
||||
|
||||
// Check Result count matches
|
||||
response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size()));
|
||||
|
||||
// Check Results match
|
||||
Collection<Map<String, String>> actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value");
|
||||
Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
|
||||
// yellow banana big boat: 6 results expected
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana big boat)'");
|
||||
sqlRequest.setLimit(10);
|
||||
|
||||
response = searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
// Set Expected Result
|
||||
expectedContent = new ArrayList<String>();
|
||||
expectedContent.add(Arrays.asList(fileBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileYellowBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent()));
|
||||
|
||||
// Check Result count matches
|
||||
response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size()));
|
||||
|
||||
// Check Results match
|
||||
actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value");
|
||||
Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
|
||||
// yellow banana big boat: 4 results expected
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select cm_content from alfresco where cm_content = '(big boat)'");
|
||||
sqlRequest.setLimit(10);
|
||||
|
||||
response = searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
// Set Expected Result
|
||||
expectedContent = new ArrayList<String>();
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent()));
|
||||
|
||||
// Check Result count matches
|
||||
response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size()));
|
||||
|
||||
// Check Results match
|
||||
actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value");
|
||||
Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 2)
|
||||
public void testPhraseQueriesViaJDBC() throws Exception
|
||||
{
|
||||
// yellow banana: 5 results expected
|
||||
SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest();
|
||||
String sql = "select cm_content from alfresco where cm_content = '(yellow banana)'";
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(userModel);
|
||||
|
||||
ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
Assert.assertNotNull(rs);
|
||||
Assert.assertNull(sqlRequest.getErrorDetails());
|
||||
|
||||
// Set Expected Result
|
||||
expectedContent = new ArrayList<String>();
|
||||
expectedContent.add(Arrays.asList(fileBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileYellowBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent()));
|
||||
|
||||
Integer i = 0;
|
||||
List actualContent = new ArrayList<String>();
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
// Field values are retrieved
|
||||
Assert.assertNotNull(rs.getString("cm_content"));
|
||||
actualContent.add(Arrays.asList(rs.getString("cm_content")));
|
||||
i++;
|
||||
}
|
||||
|
||||
Assert.assertTrue(i == expectedContent.size());
|
||||
Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
|
||||
// yellow banana big boat: 6 results expected
|
||||
sql = "select cm_content from alfresco where cm_content = '(yellow banana big boat)'";
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(userModel);
|
||||
|
||||
rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
Assert.assertNotNull(rs);
|
||||
Assert.assertNull(sqlRequest.getErrorDetails());
|
||||
|
||||
// Set Expected Result
|
||||
expectedContent = new ArrayList<String>();
|
||||
expectedContent.add(Arrays.asList(fileBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileYellowBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent()));
|
||||
|
||||
i = 0;
|
||||
actualContent = new ArrayList<String>();
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
// Field values are retrieved
|
||||
Assert.assertNotNull(rs.getString("cm_content"));
|
||||
actualContent.add(Arrays.asList(rs.getString("cm_content")));
|
||||
i++;
|
||||
}
|
||||
|
||||
Assert.assertTrue(i == expectedContent.size());
|
||||
Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
|
||||
// big boat: 4 results expected
|
||||
sql = "select cm_content from alfresco where cm_content = '(big boat)'";
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(userModel);
|
||||
|
||||
rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
Assert.assertNotNull(rs);
|
||||
Assert.assertNull(sqlRequest.getErrorDetails());
|
||||
|
||||
// Set Expected Result
|
||||
expectedContent = new ArrayList<String>();
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent()));
|
||||
expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent()));
|
||||
|
||||
i = 0;
|
||||
actualContent = new ArrayList<String>();
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
// Field values are retrieved
|
||||
Assert.assertNotNull(rs.getString("cm_content"));
|
||||
actualContent.add(Arrays.asList(rs.getString("cm_content")));
|
||||
i++;
|
||||
}
|
||||
|
||||
Assert.assertTrue(i == expectedContent.size());
|
||||
Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString()));
|
||||
}
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search.sql;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.dataprep.SiteService.Visibility;
|
||||
import org.alfresco.rest.requests.search.SearchSQLJDBC;
|
||||
import org.alfresco.rest.search.AbstractSearchTest;
|
||||
import org.alfresco.rest.search.SearchSqlJDBCRequest;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.Assert;
|
||||
|
||||
/**
|
||||
* Search SQL end point test via JDBC.
|
||||
* @author MSuzuki
|
||||
* @author Meenal Bhave
|
||||
*
|
||||
*/
|
||||
public class SearchSQLViaJDBCTest extends AbstractSearchTest
|
||||
{
|
||||
List<String> sites = new ArrayList<String>();
|
||||
SearchSQLJDBC searchSql;
|
||||
SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest();
|
||||
|
||||
@AfterMethod(alwaysRun=true)
|
||||
public void cleanUp() throws SQLException
|
||||
{
|
||||
restClient.withSearchSqlViaJDBC().clearSearchQuery(sqlRequest);
|
||||
sqlRequest = new SearchSqlJDBCRequest();
|
||||
sites = new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=01)
|
||||
public void testQueryPublicSite() throws SQLException
|
||||
{
|
||||
|
||||
SiteModel publicSite = new SiteModel(RandomData.getRandomName("SiteSearch"));
|
||||
publicSite.setVisibility(Visibility.PUBLIC);
|
||||
|
||||
publicSite = dataSite.usingUser(adminUserModel).createSite(publicSite);
|
||||
|
||||
String sql = "select SITE,CM_OWNER from alfresco where SITE ='" + publicSite.getTitle() + "' group by SITE,CM_OWNER";
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(userModel);
|
||||
|
||||
ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
// User can see the Public Site created by other user
|
||||
Assert.assertNotNull(rs.getString("SITE"));
|
||||
Assert.assertTrue(publicSite.getTitle().equalsIgnoreCase(rs.getString("SITE")));
|
||||
|
||||
Assert.assertNotNull(rs.getString("CM_OWNER"));
|
||||
Assert.assertTrue(rs.getString("CM_OWNER").contains(adminUserModel.getUsername()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=02)
|
||||
public void testQueryMyCreatedPrivateSite() throws SQLException
|
||||
{
|
||||
String sql = "select distinct SITE from alfresco where SITE ='" + siteModel.getTitle() + "'";
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(userModel);
|
||||
|
||||
ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
// User can see Own Private Site
|
||||
Assert.assertNotNull(rs.getString("SITE"));
|
||||
Assert.assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE")));
|
||||
}
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=03)
|
||||
public void testQueryPrivateSiteWithSuperUser() throws SQLException
|
||||
{
|
||||
String sql = "select distinct SITE from alfresco where SITE ='" + siteModel.getTitle() + "'";
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(adminUserModel);
|
||||
|
||||
ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
// Super user can see Private Site created by other user
|
||||
Assert.assertNotNull(rs.getString("SITE"));
|
||||
Assert.assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE")));
|
||||
}
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=04)
|
||||
public void testQueryPrivateSiteWithSimpleUser() throws SQLException
|
||||
{
|
||||
UserModel managerUser = dataUser.createRandomTestUser("UserSearchMgr");
|
||||
|
||||
String sql = "select SITE from alfresco where SITE = '" + siteModel.getTitle() + "'";
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(managerUser);
|
||||
|
||||
// Non admin user can NOT see Private Site created by other user
|
||||
ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
Assert.assertFalse(rs.next());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=05)
|
||||
public void testQueryErrorReturned() throws SQLException
|
||||
{
|
||||
String expectedError = "Column 'SITE1' not found";
|
||||
|
||||
String sql = "select SITE1 from alfresco";
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(userModel);
|
||||
|
||||
// Appropriate error is retrieved when SQL is incorrect
|
||||
ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
|
||||
String error = sqlRequest.getErrorDetails();
|
||||
Assert.assertNotNull(error);
|
||||
Assert.assertTrue(error.contains(expectedError), "Error shown: " + error + " Error expected: " + expectedError);
|
||||
|
||||
// Record set is null
|
||||
Assert.assertNull(rs);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 06)
|
||||
public void testQuerySelectStar() throws SQLException
|
||||
{
|
||||
// Select * query with limit clause
|
||||
String sql = "select * from alfresco limit 5";
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(userModel);
|
||||
|
||||
// Select * with limit clause works: No error is retrieved
|
||||
ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
Assert.assertNotNull(rs);
|
||||
Assert.assertNull(sqlRequest.getErrorDetails());
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
// Field values are retrieved
|
||||
Assert.assertNotNull(rs.getString("PATH"));
|
||||
Assert.assertNotNull(rs.getString("DBID"));
|
||||
Assert.assertNotNull(rs.getString("cm_name"));
|
||||
}
|
||||
|
||||
// Select * query Without limit clause: No error is retrieved
|
||||
sql = "select * from alfresco";
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(userModel);
|
||||
|
||||
// No error is retrieved when SQL is incorrect
|
||||
rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
Assert.assertNotNull(rs);
|
||||
Assert.assertNull(sqlRequest.getErrorDetails());
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
// Field values are retrieved
|
||||
Assert.assertNotNull(rs.getString("PATH"));
|
||||
Assert.assertNotNull(rs.getString("DBID"));
|
||||
Assert.assertNotNull(rs.getString("cm_name"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 07)
|
||||
public void testQuerySelectDistinct() throws SQLException
|
||||
{
|
||||
// Select distinct query with limit clause
|
||||
String sql = "select distinct cm_name from alfresco limit 5";
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(adminUserModel);
|
||||
|
||||
// Select distinct with limit clause works: No error is retrieved
|
||||
ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
Assert.assertNotNull(rs);
|
||||
Assert.assertNull(sqlRequest.getErrorDetails());
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
// Field values are retrieved
|
||||
Assert.assertNotNull(rs.getString("cm_name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
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;
|
||||
|
||||
@Test(groups = {TestGroup.REQUIRE_SOLR})
|
||||
public class GetTagTests extends TagsDataPrep
|
||||
{
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToGetTag() throws Exception
|
||||
{
|
||||
RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(documentTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void userWithManagerRoleIsAbleToGetTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase())
|
||||
.assertThat().field("id").is(documentTag.getId());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userWithCollaboratorRoleIsAbleToGetTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userWithContributorRoleIsAbleToGetTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userWithConsumerRoleIsAbleToGetTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void managerIsNotAbleToGetTagIfAuthenticationFails() throws Exception
|
||||
{
|
||||
UserModel managerUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
String managerPassword = managerUser.getPassword();
|
||||
dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager);
|
||||
managerUser.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(managerUser).withCoreAPI().getTag(documentTag);
|
||||
managerUser.setPassword(managerPassword);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag id is invalid status code returned is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void invalidTagIdTest() throws Exception
|
||||
{
|
||||
String tagId = documentTag.getId();
|
||||
documentTag.setId("random_tag_value");
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(documentTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_tag_value"));
|
||||
documentTag.setId(tagId);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check that properties filter is applied when getting tag using Manager user.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void checkPropertiesFilterIsApplied() throws Exception
|
||||
{
|
||||
RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("properties=id,tag").withCoreAPI().getTag(documentTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("id").is(documentTag.getId())
|
||||
.assertThat().field("tag").is(documentTag.getTag().toLowerCase())
|
||||
.assertThat().fieldsCount().is(2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check that Manager user can get tag of a folder.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagOfAFolder() throws Exception
|
||||
{
|
||||
RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().getTag(folderTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(folderTagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Use invalid skipCount parameter.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void checkDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("skipCount=abc").withCoreAPI().getTag(documentTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"))
|
||||
.containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"))
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
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;
|
||||
|
||||
@Test(groups = {TestGroup.REQUIRE_SOLR})
|
||||
public class GetTagsTests extends TagsDataPrep
|
||||
{
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void getTagsWithManagerRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsWithCollaboratorRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsWithContributorRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsWithConsumerRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void failedAuthenticationReturnsUnauthorizedStatus() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
userModel.setPassword("user wrong password");
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(userModel);
|
||||
restClient.withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if maxItems is invalid status code returned is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void maxItemsInvalidValueTest() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if skipCount is invalid status code returned is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void skipCountInvalidValueTest() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that file tag is retrieved")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void fileTagIsRetrieved() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that folder tag is retrieved")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void folderTagIsRetrieved() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", folderTagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify site Manager is able to get tags using properties parameter."
|
||||
+ "Check that properties filter is applied.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void siteManagerIsAbleToRetrieveTagsWithPropertiesParameter() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("maxItems=5000&properties=tag").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase())
|
||||
.and().entriesListDoesNotContain("id");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get tags and use skipCount parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useSkipCountCheckPagination() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel();
|
||||
RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel();
|
||||
RestTagModelsCollection tagsWithSkipCount = restClient.withParams("skipCount=2").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag())
|
||||
.assertThat().entriesListDoesNotContain("tag", secondTag.getTag());
|
||||
tagsWithSkipCount.assertThat().paginationField("skipCount").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get tags and use maxItems parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useMaxItemsParameterCheckPagination() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel();
|
||||
RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel();
|
||||
RestTagModelsCollection tagsWithMaxItems = restClient.withParams("maxItems=2").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
tagsWithMaxItems.assertThat().entriesListContains("tag", firstTag.getTag())
|
||||
.assertThat().entriesListContains("tag", secondTag.getTag())
|
||||
.assertThat().entriesListCountIs(2);
|
||||
tagsWithMaxItems.assertThat().paginationField("maxItems").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With manager get tags and use high skipCount parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useHighSkipCountCheckPagination() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("skipCount=20000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsEmpty()
|
||||
.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("count").is("0")
|
||||
.and().field("skipCount").is(20000)
|
||||
.and().field("totalItems").isNull();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With Collaborator user get tags and use maxItems with value zero. Check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useMaxItemsWithValueZeroCheckDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withParams("maxItems=0").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS)
|
||||
.containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With Manager user delete tag. Check it is not retrieved anymore.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void checkThatDeletedTagIsNotRetrievedAnymore() throws Exception
|
||||
{
|
||||
String removedTag = RandomData.getRandomName("tag3");
|
||||
|
||||
RestTagModel deletedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addTag(removedTag);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(deletedTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListDoesNotContain("tag", removedTag.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -1,269 +0,0 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
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.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/4/2016.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REQUIRE_SOLR})
|
||||
public class UpdateTagTests extends TagsDataPrep
|
||||
{
|
||||
private RestTagModel oldTag;
|
||||
private String randomTag = "";
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun=true)
|
||||
public void addTagToDocument() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old"));
|
||||
randomTag = RandomData.getRandomName("tag");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200")
|
||||
@Bug(id="REPO-1828")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToUpdateTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(randomTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void managerIsNotAbleToUpdateTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToUpdateTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToUpdateTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws Exception
|
||||
{
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
String managerPassword = siteManager.getPassword();
|
||||
siteManager.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(siteManager);
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
siteManager.setPassword(managerPassword);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidId() throws Exception
|
||||
{
|
||||
String invalidTagId = "invalid-id";
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
tag.setId(invalidTagId);
|
||||
restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag"));
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTagId));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with empty id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithEmptyId() throws Exception
|
||||
{
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
tag.setId("");
|
||||
restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag"));
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED)
|
||||
.assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid body")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithEmptyBody() throws Exception
|
||||
{
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
restClient.withCoreAPI().usingTag(tag).update("");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(RestErrorModel.EMPTY_TAG);
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5629")
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin is not able to update tag with invalid body containing '|' symbol")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws Exception
|
||||
{
|
||||
String invalidTagBody = "|.\"/<>*";
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
Utility.waitToLoopTime(20);
|
||||
restClient.withCoreAPI().usingTag(tag).update(invalidTagBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody));
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5629")
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin is not able to update tag with invalid body without '|' symbol")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws Exception
|
||||
{
|
||||
String invalidTagBody = ".\"/<>*";
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
Utility.waitToLoopTime(20);
|
||||
restClient.withCoreAPI().usingTag(tag).update(invalidTagBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user can provide large string for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideLargeStringTag() throws Exception
|
||||
{
|
||||
String largeStringTag = RandomStringUtils.randomAlphanumeric(10000);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(largeStringTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user can provide short string for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideShortStringTag() throws Exception
|
||||
{
|
||||
String shortStringTag = RandomStringUtils.randomAlphanumeric(2);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(shortStringTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user can provide string with special chars for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws Exception
|
||||
{
|
||||
String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\";
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(specialCharsString);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user can provide existing tag for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideExistingTag() throws Exception
|
||||
{
|
||||
String existingTag = "oldTag";
|
||||
RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addTag(existingTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldExistingTag).update(existingTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(existingTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user can delete a tag, add tag and update it.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminDeleteTagAddTagUpdateTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).deleteTag(oldTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
String newTag = "addTag";
|
||||
RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingTag(newTagModel).update(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(newTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user can update a tag, delete tag and add it.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminUpdateTagDeleteTagAddTag() throws Exception
|
||||
{
|
||||
String newTag = "addTag";
|
||||
|
||||
returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(newTag);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(returnedModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).addTag(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
}
|
||||
@@ -1,337 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.rest.tags.TagsDataPrep;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/3/2016.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REQUIRE_SOLR})
|
||||
public class AddTagTests extends TagsDataPrep
|
||||
{
|
||||
private String tagValue;
|
||||
private RestTagModel returnedModel;
|
||||
private RestCommentModel returnedModelComment;
|
||||
private RestTagModelsCollection returnedModelTags;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void generateRandomTag()
|
||||
{
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToAddTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue)
|
||||
.and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToTagAFile() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue)
|
||||
.and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Collaborator user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToTagAFile() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue)
|
||||
.and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToAddTagToAnotherContent() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user adds tags to his content with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToAddTagToHisContent() throws Exception
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor);
|
||||
restClient.authenticateUser(userModel);
|
||||
FileModel contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(contributorDoc).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("id").isNotEmpty()
|
||||
.and().field("tag").is(tagValue);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToTagAFile() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToAddTagIfAuthenticationFails() throws Exception
|
||||
{
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
String managerPassword = siteManager.getPassword();
|
||||
siteManager.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(siteManager);
|
||||
restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized");
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
siteManager.setPassword(managerPassword);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding empty tag returns status code 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void emptyTagTest() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag("");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "tag"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding tag with user that has no permissions returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagWithUserThatDoesNotHavePermissions() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(dataUser.createRandomTestUser());
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding tag to a node that does not exist returns status code 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToInexistentNode() throws Exception
|
||||
{
|
||||
String oldNodeRef = document.getNodeRef();
|
||||
String nodeRef = RandomStringUtils.randomAlphanumeric(10);
|
||||
document.setNodeRef(nodeRef);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef));
|
||||
document.setNodeRef(oldNodeRef);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify that manager is able to tag a folder")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToTagAFolder() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that tagged file can be tagged again")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToATaggedFile() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag_value");
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty();
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).getNodeTags().assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", "random_tag_value");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that user cannot add invalid tag")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addInvalidTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag("-1~!|@#$%^&*()_=");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that contributor is able to tag a folder created by self")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToTagAFolderCreatedBySelf() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that collaborator is able to tag a folder")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToTagAFolder() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that consumer is not able to tag a folder. Check default error model schema.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToTagAFolder() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that tagged folder can be tagged again")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToATaggedFolder() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag("random_tag_value");
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty();
|
||||
|
||||
restClient.withCoreAPI().usingResource(folderModel).getNodeTags().assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", "random_tag_value")
|
||||
.and().entriesListCountIs(2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Using collaborator provide more than one tag element")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void provideMoreThanOneTagElement() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
String tagValue1 = RandomData.getRandomName("tag1");
|
||||
String tagValue2 = RandomData.getRandomName("tag2");
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
|
||||
returnedModelTags = restClient.withCoreAPI().usingResource(folderModel).addTags(tagValue, tagValue1, tagValue2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModelTags.assertThat().entriesListContains("tag", tagValue)
|
||||
.and().entriesListContains("tag", tagValue1)
|
||||
.and().entriesListContains("tag", tagValue2)
|
||||
.and().entriesListCountIs(3);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that manager cannot add tag with special characters.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagWithSpecialCharacters() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
String specialCharsTag = "!@#$%^&*()'\".,<>-_+=|\\";
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(folderModel).addTag(specialCharsTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that you cannot tag a comment and it returns status code 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToAComment() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String comment = "comment for a tag";
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModelComment = restClient.withCoreAPI().usingResource(file).addComment(comment);
|
||||
file.setNodeRef(returnedModelComment.getId());
|
||||
restClient.withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that you cannot tag a tag and it returns status code 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToATag() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
file.setNodeRef(returnedModel.getId());
|
||||
restClient.withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG);
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.rest.tags.TagsDataPrep;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/7/2016.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REQUIRE_SOLR})
|
||||
public class AddTagsTests extends TagsDataPrep
|
||||
{
|
||||
private FileModel contributorDoc;
|
||||
private String tag1, tag2;
|
||||
private RestTagModelsCollection returnedCollection;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void generateRandomTagsList()
|
||||
{
|
||||
tag1 = RandomData.getRandomName("tag");
|
||||
tag2 = RandomData.getRandomName("tag");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user adds multiple tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToAddTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedCollection.assertThat().entriesListContains("tag", tag1)
|
||||
.and().entriesListContains("tag", tag2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user adds multiple tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToAddTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedCollection.assertThat().entriesListContains("tag", tag1)
|
||||
.and().entriesListContains("tag", tag2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToAddTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedCollection.assertThat().entriesListContains("tag", tag1)
|
||||
.and().entriesListContains("tag", tag2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToAddTagsToAnotherContent() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToAddTagsToHisContent() throws Exception
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor);
|
||||
restClient.authenticateUser(userModel);
|
||||
contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(contributorDoc).addTags(tag1, tag2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedCollection.assertThat().entriesListContains("tag", tag1)
|
||||
.and().entriesListContains("tag", tag2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToAddTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToAddTagsIfAuthenticationFails() throws Exception
|
||||
{
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
String managerPassword = siteManager.getPassword();
|
||||
siteManager.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(siteManager).withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
siteManager.setPassword(managerPassword);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify include count parameter")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsUsingCountParam() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String tagName = RandomData.getRandomName("tag");
|
||||
returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(RandomData.getRandomName("tag"));
|
||||
RestTagModelsCollection tagsWithIncludeParamCount = restClient.withParams("include=count").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
for (RestTagModel tagModel : tagsWithIncludeParamCount.getEntries())
|
||||
{
|
||||
if (tagModel != null && tagModel.getTag() != null)
|
||||
{
|
||||
if (tagModel.getTag().equals(tagName))
|
||||
{
|
||||
Assert.assertEquals(tagModel.getCount().intValue(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,287 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.rest.tags.TagsDataPrep;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
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.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/4/2016.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REQUIRE_SOLR})
|
||||
public class DeleteTagTests extends TagsDataPrep
|
||||
{
|
||||
private RestTagModel tag;
|
||||
private FileModel contributorDoc;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user deletes tags with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToDeleteTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingResource(document).getNodeTags()
|
||||
.assertThat().entriesListDoesNotContain("tag", tag.getTag());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToDeleteTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToDeleteTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToDeleteTagsForHisContent() throws Exception
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor);
|
||||
restClient.authenticateUser(userModel);
|
||||
contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);;
|
||||
tag = restClient.withCoreAPI().usingResource(contributorDoc).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToDeleteTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
String managerPassword = siteManager.getPassword();
|
||||
siteManager.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(siteManager);
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
siteManager.setPassword(managerPassword);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if user has no permission to remove tag returned status code is 403. Check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagWithUserWithoutPermissionCheckDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(dataUser.createRandomTestUser());
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError()
|
||||
.containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if node does not exist returned status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagForANonexistentNode() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String nodeRef = RandomStringUtils.randomAlphanumeric(10);
|
||||
document.setNodeRef(nodeRef);
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag does not exist returned status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagThatDoesNotExist() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
tag.setId("abc");
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag id is empty returned status code is 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagWithEmptyId() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
tag.setId("");
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that folder tag can be deleted")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteFolderTag() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();;
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag"));
|
||||
restClient.withCoreAPI().usingResource(folderModel).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingResource(folderModel).getNodeTags()
|
||||
.assertThat().entriesListDoesNotContain("tag", tag.getTag());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't delete deleted tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id = "ACE-5455")
|
||||
public void managerCannotDeleteDeletedTag() throws Exception
|
||||
{
|
||||
tag = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete long tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userCollaboratorCanDeleteLongTag() throws Exception
|
||||
{
|
||||
String longTag = RandomStringUtils.randomAlphanumeric(800);
|
||||
|
||||
tag = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(longTag);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete short tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void managerCanDeleteShortTag() throws Exception
|
||||
{
|
||||
String shortTag = RandomStringUtils.randomAlphanumeric(10);
|
||||
|
||||
tag = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(shortTag);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Admin can delete tag then add it again.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminRemovesTagAndAddsItAgain() throws Exception
|
||||
{
|
||||
String tagValue = RandomStringUtils.randomAlphanumeric(10);
|
||||
|
||||
tag = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
tag = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(tagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete tag added by another user.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void managerCanDeleteTagAddedByAnotherUser() throws Exception
|
||||
{
|
||||
tag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addTag(RandomStringUtils.randomAlphanumeric(10));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -1,319 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.tags.TagsDataPrep;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
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.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = {TestGroup.REQUIRE_SOLR})
|
||||
public class GetNodeTagsTests extends TagsDataPrep
|
||||
{
|
||||
private String tagValue;
|
||||
private String tagValue2;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
init();
|
||||
tagValue = documentTagValue;
|
||||
tagValue2 = documentTagValue2;
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void siteManagerIsAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify site Collaborator is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void siteCollaboratorIsAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify site Contributor is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void siteContributorIsAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify site Consumer is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void siteConsumerIsAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify admin is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id = "MNT-16904", description = "fails only on environment with tenants")
|
||||
public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"));
|
||||
restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that using invalid value for skipCount parameter returns status code 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void invalidSkipCountTest() throws Exception
|
||||
{
|
||||
restClient.withParams("skipCount=abc").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"));
|
||||
|
||||
restClient.withParams("skipCount=-1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that using invalid value for maxItems parameter returns status code 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void invalidMaxItemsTest() throws Exception
|
||||
{
|
||||
restClient.withParams("maxItems=abc").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc"));
|
||||
|
||||
restClient.withParams("maxItems=-1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that user without permissions returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void userWithoutPermissionsTest() throws Exception
|
||||
{
|
||||
SiteModel moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite();
|
||||
FileModel moderatedDocument = dataContent.usingSite(moderatedSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingResource(moderatedDocument).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if node does not exist returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void nonexistentNodeTest() throws Exception
|
||||
{
|
||||
FileModel badDocument = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String nodeRef = RandomStringUtils.randomAlphanumeric(10);
|
||||
badDocument.setNodeRef(nodeRef);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(badDocument).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if node id is empty returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void emptyNodeIdTest() throws Exception
|
||||
{
|
||||
FileModel badDocument = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
badDocument.setNodeRef("");
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(badDocument).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, ""));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify folder tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void folderTagsTest() throws Exception
|
||||
{
|
||||
FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.withCoreAPI().usingResource(folder).addTag(tagValue);
|
||||
restClient.withCoreAPI().usingResource(folder).addTag(tagValue2);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getNodeTags()
|
||||
.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify site Manager is able to get node tags using properties parameter")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void siteManagerIsAbleToRetrieveNodeTagsWithPropertiesParameter() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("properties=tag").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase())
|
||||
.and().entriesListDoesNotContain("id");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that Collaborator user is not able to get node tags using site id instead of node id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorGetNodeTagsUseSiteIdInsteadOfNodeId() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
file.setNodeRef(siteModel.getId());
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef()));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get node tags and use skipCount parameter. Check pagination and maxItems")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useSkipCountCheckPaginationAndMaxItems() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("skipCount=1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("count").isGreaterThan(1);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get node tags and use maxItems parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useMaxItemsParameterCheckPagination() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("maxItems=1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(1)
|
||||
.and().field("hasMoreItems").is("true")
|
||||
.and().field("count").is("1")
|
||||
.and().field("skipCount").is("0");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Using manager user get only one tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void usingManagerGetOnlyOneTag() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("totalItems").is("1")
|
||||
.and().field("count").is("1")
|
||||
.and().field("skipCount").is("0");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Using admin get last 2 tags and skip first 2 tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminUserGetLast2TagsAndSkipFirst2Tags() throws Exception
|
||||
{
|
||||
String firstTag = "1st tag";
|
||||
String secondTag = "2nd tag";
|
||||
String thirdTag = "3rd tag";
|
||||
String fourthTag = "4th tag";
|
||||
FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(firstTag);
|
||||
restClient.withCoreAPI().usingResource(file).addTag(secondTag);
|
||||
restClient.withCoreAPI().usingResource(file).addTag(thirdTag);
|
||||
restClient.withCoreAPI().usingResource(file).addTag(fourthTag);
|
||||
|
||||
returnedCollection = restClient.withParams("skipCount=2").withCoreAPI().usingResource(file).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
returnedCollection.assertThat().entriesListContains("tag", thirdTag.toLowerCase())
|
||||
.and().entriesListContains("tag", fourthTag.toLowerCase());
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("totalItems").is("4")
|
||||
.and().field("count").is("2")
|
||||
.and().field("skipCount").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get node tags and use maxItems=0.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsWithZeroMaxItems() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("maxItems=0").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that using high skipCount parameter returns status code 200.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsWithHighSkipCount() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel).withParams("skipCount=10000")
|
||||
.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("count").is("0")
|
||||
.and().field("skipCount").is("10000");
|
||||
returnedCollection.assertThat().entriesListCountIs(0);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
package org.alfresco.rest;
|
||||
package org.alfresco.service.search.rest;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.dataprep.SiteService.Visibility;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestActivityModelsCollection;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.rest.model.RestCommentModelsCollection;
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package org.alfresco.rest;
|
||||
package org.alfresco.service.search.rest;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestNetworkModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest;
|
||||
package org.alfresco.service.search.rest;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.actions;
|
||||
package org.alfresco.service.search.rest.actions;
|
||||
|
||||
import static org.testng.Assert.assertFalse;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.aos;
|
||||
package org.alfresco.service.search.rest.aos;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestRequest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.audit;
|
||||
package org.alfresco.service.search.rest.audit;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package org.alfresco.rest.audit;
|
||||
package org.alfresco.service.search.rest.audit;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.alfresco.rest.audit.AuditTest;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.audit;
|
||||
package org.alfresco.service.search.rest.audit;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
@@ -6,6 +6,7 @@ import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.alfresco.rest.audit.AuditTest;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package org.alfresco.rest.audit;
|
||||
package org.alfresco.service.search.rest.audit;
|
||||
|
||||
import org.alfresco.rest.audit.AuditTest;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.auth;
|
||||
package org.alfresco.service.search.rest.auth;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.cmis;
|
||||
package org.alfresco.service.search.rest.cmis;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.comments;
|
||||
package org.alfresco.service.search.rest.comments;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.comments;
|
||||
package org.alfresco.service.search.rest.comments;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.comments;
|
||||
package org.alfresco.service.search.rest.comments;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.comments;
|
||||
package org.alfresco.service.search.rest.comments;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.comments;
|
||||
package org.alfresco.service.search.rest.comments;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.demo;
|
||||
package org.alfresco.service.search.rest.demo;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.dataprep.SiteService.Visibility;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.demo;
|
||||
package org.alfresco.service.search.rest.demo;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.demo;
|
||||
package org.alfresco.service.search.rest.demo;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.utility.exception.DataPreparationException;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.demo;
|
||||
package org.alfresco.service.search.rest.demo;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.demo.workshop;
|
||||
package org.alfresco.service.search.rest.demo.workshop;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.demo.workshop;
|
||||
package org.alfresco.service.search.rest.demo.workshop;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.testng.annotations.Test;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.discovery;
|
||||
package org.alfresco.service.search.rest.discovery;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.downloads;
|
||||
package org.alfresco.service.search.rest.downloads;
|
||||
|
||||
import javax.json.JsonObject;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
package org.alfresco.service.search.rest.favorites;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
package org.alfresco.service.search.rest.favorites;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
package org.alfresco.service.search.rest.favorites;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
package org.alfresco.service.search.rest.favorites;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
package org.alfresco.service.search.rest.favorites;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
package org.alfresco.service.search.rest.favorites;
|
||||
|
||||
import org.alfresco.rest.NetworkDataPrep;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
package org.alfresco.service.search.rest.favorites;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.dataprep.SiteService;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
package org.alfresco.service.search.rest.favorites;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
package org.alfresco.service.search.rest.favorites;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.dataprep.SiteService;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
package org.alfresco.service.search.rest.favorites;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.groups;
|
||||
package org.alfresco.service.search.rest.groups;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.networks;
|
||||
package org.alfresco.service.search.rest.networks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.networks;
|
||||
package org.alfresco.service.search.rest.networks;
|
||||
|
||||
import org.alfresco.rest.NetworkDataPrep;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.networks;
|
||||
package org.alfresco.service.search.rest.networks;
|
||||
|
||||
import org.alfresco.rest.NetworkDataPrep;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.nodes;
|
||||
package org.alfresco.service.search.rest.nodes;
|
||||
|
||||
|
||||
import static org.testng.Assert.assertFalse;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.nodes;
|
||||
package org.alfresco.service.search.rest.nodes;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.nodes;
|
||||
package org.alfresco.service.search.rest.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.nodes;
|
||||
package org.alfresco.service.search.rest.nodes;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.nodes;
|
||||
package org.alfresco.service.search.rest.nodes;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.nodes;
|
||||
package org.alfresco.service.search.rest.nodes;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestNodeBodyMoveCopyModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.nodes;
|
||||
package org.alfresco.service.search.rest.nodes;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestRequest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestSiteMembershipModelsCollection;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people;
|
||||
package org.alfresco.service.search.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people.activities;
|
||||
package org.alfresco.service.search.rest.people.activities;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people.activities;
|
||||
package org.alfresco.service.search.rest.people.activities;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people.activities;
|
||||
package org.alfresco.service.search.rest.people.activities;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people.preferences;
|
||||
package org.alfresco.service.search.rest.people.preferences;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people.preferences;
|
||||
package org.alfresco.service.search.rest.people.preferences;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people.preferences;
|
||||
package org.alfresco.service.search.rest.people.preferences;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people.preferences;
|
||||
package org.alfresco.service.search.rest.people.preferences;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people.preferences;
|
||||
package org.alfresco.service.search.rest.people.preferences;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.people.preferences;
|
||||
package org.alfresco.service.search.rest.people.preferences;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.queries;
|
||||
package org.alfresco.service.search.rest.queries;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.ratings;
|
||||
package org.alfresco.service.search.rest.ratings;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.ratings;
|
||||
package org.alfresco.service.search.rest.ratings;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.ratings;
|
||||
package org.alfresco.service.search.rest.ratings;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.ratings;
|
||||
package org.alfresco.service.search.rest.ratings;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.renditions;
|
||||
package org.alfresco.service.search.rest.renditions;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.renditions;
|
||||
package org.alfresco.service.search.rest.renditions;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.rest.renditions;
|
||||
package org.alfresco.service.search.rest.renditions;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
+7
-2
@@ -16,11 +16,16 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
package org.alfresco.service.search.rest.search;
|
||||
|
||||
import org.alfresco.dataprep.SiteService.Visibility;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.search.RestRequestHighlightModel;
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
import org.alfresco.rest.search.SearchRequest;
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
import org.alfresco.rest.search.SearchSqlRequest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
@@ -122,7 +127,7 @@ public class AbstractSearchTest extends RestTest
|
||||
* @throws Exception if error
|
||||
*
|
||||
*/
|
||||
protected SearchResponse query(RestRequestQueryModel queryReq,RestRequestHighlightModel highlight) throws Exception
|
||||
protected SearchResponse query(RestRequestQueryModel queryReq, RestRequestHighlightModel highlight) throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest(queryReq);
|
||||
query.setHighlight(highlight);
|
||||
+9
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
package org.alfresco.service.search.rest.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -25,6 +25,14 @@ import javax.json.Json;
|
||||
import javax.json.JsonObject;
|
||||
|
||||
import org.alfresco.dataprep.SiteService.Visibility;
|
||||
import org.alfresco.rest.search.AbstractSearchTest;
|
||||
import org.alfresco.rest.search.FacetFieldBucket;
|
||||
import org.alfresco.rest.search.RestRequestFacetFieldModel;
|
||||
import org.alfresco.rest.search.RestRequestFacetFieldsModel;
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
import org.alfresco.rest.search.RestResultBucketsModel;
|
||||
import org.alfresco.rest.search.SearchRequest;
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
+9
-1
@@ -16,9 +16,17 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
package org.alfresco.service.search.rest.search;
|
||||
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.search.AbstractSearchTest;
|
||||
import org.alfresco.rest.search.FacetInterval;
|
||||
import org.alfresco.rest.search.RestGenericBucketModel;
|
||||
import org.alfresco.rest.search.RestGenericFacetResponseModel;
|
||||
import org.alfresco.rest.search.RestRequestFacetIntervalsModel;
|
||||
import org.alfresco.rest.search.RestRequestFacetSetModel;
|
||||
import org.alfresco.rest.search.SearchRequest;
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
+6
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
package org.alfresco.service.search.rest.search;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
@@ -27,6 +27,11 @@ import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestRequestRangesModel;
|
||||
import org.alfresco.rest.search.AbstractSearchTest;
|
||||
import org.alfresco.rest.search.RestGenericBucketModel;
|
||||
import org.alfresco.rest.search.RestGenericFacetResponseModel;
|
||||
import org.alfresco.rest.search.SearchRequest;
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
+10
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
package org.alfresco.service.search.rest.search;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -26,6 +26,15 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestRequestRangesModel;
|
||||
import org.alfresco.rest.search.AbstractSearchTest;
|
||||
import org.alfresco.rest.search.Pagination;
|
||||
import org.alfresco.rest.search.RestGenericBucketModel;
|
||||
import org.alfresco.rest.search.RestGenericFacetResponseModel;
|
||||
import org.alfresco.rest.search.RestRequestFacetFieldModel;
|
||||
import org.alfresco.rest.search.RestRequestFacetFieldsModel;
|
||||
import org.alfresco.rest.search.RestRequestPivotModel;
|
||||
import org.alfresco.rest.search.SearchRequest;
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
+7
-1
@@ -16,11 +16,17 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
package org.alfresco.service.search.rest.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.search.AbstractSearchTest;
|
||||
import org.alfresco.rest.search.ResponseHighLightModel;
|
||||
import org.alfresco.rest.search.RestRequestFieldsModel;
|
||||
import org.alfresco.rest.search.RestRequestHighlightModel;
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
+5
-1
@@ -16,9 +16,13 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
package org.alfresco.service.search.rest.search;
|
||||
|
||||
import org.alfresco.rest.model.RestRequestSpellcheckModel;
|
||||
import org.alfresco.rest.search.AbstractSearchTest;
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
import org.alfresco.rest.search.SearchRequest;
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
+13
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
package org.alfresco.service.search.rest.search;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
@@ -30,6 +30,18 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.search.Pagination;
|
||||
import org.alfresco.rest.search.RestGenericBucketModel;
|
||||
import org.alfresco.rest.search.RestGenericFacetResponseModel;
|
||||
import org.alfresco.rest.search.RestGenericMetricModel;
|
||||
import org.alfresco.rest.search.RestRequestFacetFieldModel;
|
||||
import org.alfresco.rest.search.RestRequestFacetFieldsModel;
|
||||
import org.alfresco.rest.search.RestRequestFilterQueryModel;
|
||||
import org.alfresco.rest.search.RestRequestPivotModel;
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
import org.alfresco.rest.search.RestRequestStatsModel;
|
||||
import org.alfresco.rest.search.SearchRequest;
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user