mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-7145 Addressed code review comments
This commit is contained in:
@@ -91,6 +91,10 @@ public class RestAPIFactory
|
|||||||
getRmRestWrapper().authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
|
getRmRestWrapper().authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
|
||||||
return getRmRestWrapper().withSearchAPI();
|
return getRmRestWrapper().withSearchAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When no user is given the default is set to admin
|
||||||
|
*/
|
||||||
public SearchAPI getSearchAPI()
|
public SearchAPI getSearchAPI()
|
||||||
{
|
{
|
||||||
return getSearchAPI(null);
|
return getSearchAPI(null);
|
||||||
|
@@ -1,163 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* 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/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
package org.alfresco.rest.rm.community.search;
|
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
import static org.testng.Assert.assertFalse;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.ContentActions;
|
|
||||||
import org.alfresco.rest.core.search.SearchRequestBuilder;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
|
||||||
import org.alfresco.rest.search.SearchResponse;
|
|
||||||
import org.alfresco.rest.v0.UserTrashcanAPI;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.alfresco.utility.Utility;
|
|
||||||
import org.alfresco.utility.model.FileModel;
|
|
||||||
import org.alfresco.utility.model.FileType;
|
|
||||||
import org.alfresco.utility.model.SiteModel;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class contains the tests for v1 Search API for documents using AFTS query
|
|
||||||
*
|
|
||||||
* @author Roxana Lucanu
|
|
||||||
* @since 2.6.3
|
|
||||||
*/
|
|
||||||
public class SearchDocumentsV1AftsTest extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
private static final String SEARCH_TERM = generateTestPrefix(SearchDocumentsV1AftsTest.class);
|
|
||||||
private SiteModel collaborationSite;
|
|
||||||
private FileModel fileModel;
|
|
||||||
private RestRequestQueryModel queryModel;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserTrashcanAPI userTrashcanAPI;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ContentActions contentActions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a collaboration site and some documents in it.
|
|
||||||
*/
|
|
||||||
@BeforeClass (alwaysRun = true)
|
|
||||||
public void setupSearchAPI() throws Exception
|
|
||||||
{
|
|
||||||
STEP("Create a collaboration site");
|
|
||||||
collaborationSite = dataSite.usingAdmin().createPrivateRandomSite();
|
|
||||||
|
|
||||||
STEP("Create 10 documents with name ending with SEARCH_TERM");
|
|
||||||
for (int i = 0; ++i <= 10; )
|
|
||||||
{
|
|
||||||
fileModel = new FileModel("Doc" + i + SEARCH_TERM, FileType.UNDEFINED);
|
|
||||||
fileModel = dataContent.usingAdmin().usingSite(collaborationSite).createContent(fileModel);
|
|
||||||
}
|
|
||||||
queryModel = new RestRequestQueryModel();
|
|
||||||
queryModel.setLanguage("afts");
|
|
||||||
queryModel.setQuery("cm:name:*" + SEARCH_TERM);
|
|
||||||
|
|
||||||
//do a cmis query to wait for solr indexing
|
|
||||||
Utility.sleep(5000, 80000, () ->
|
|
||||||
{
|
|
||||||
SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(100, 0))
|
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
|
||||||
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI(null).search(sqlRequest);
|
|
||||||
assertEquals(searchResponse.getPagination().getTotalItems().intValue(), 10,
|
|
||||||
"Total number of items is not 10, got " + searchResponse.getPagination().getTotalItems() + " total items");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given some documents having a common term in the name
|
|
||||||
* When executing the search query with paging
|
|
||||||
* And setting the skipCount and maxItems to reach the number of total items
|
|
||||||
* Then hasMoreItems will be set to false
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest (jira = "RM-7145")
|
|
||||||
public void searchWhenMaxItemsReached() throws Exception
|
|
||||||
{
|
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 5))
|
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
|
||||||
|
|
||||||
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI(null).search(sqlRequest);
|
|
||||||
assertEquals(searchResponse.getPagination().getCount(), 5);
|
|
||||||
assertEquals(searchResponse.getPagination().getSkipCount(), 5);
|
|
||||||
assertFalse(searchResponse.getPagination().isHasMoreItems());
|
|
||||||
assertEquals(searchResponse.getEntries().size(), 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given some documents ending with a particular text
|
|
||||||
* When executing the search query with paging
|
|
||||||
* And setting skipCount and maxItems to exceed the number of total items
|
|
||||||
* Then hasMoreItems will be set to false
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void searchWhenTotalItemsExceed() throws Exception
|
|
||||||
{
|
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 6))
|
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
|
||||||
|
|
||||||
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI(null).search(sqlRequest);
|
|
||||||
assertEquals(searchResponse.getPagination().getCount(), 4);
|
|
||||||
assertEquals(searchResponse.getPagination().getSkipCount(), 6);
|
|
||||||
assertFalse(searchResponse.getPagination().isHasMoreItems());
|
|
||||||
assertEquals(searchResponse.getEntries().size(), 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given some documents ending with a particular text
|
|
||||||
* When executing the search query with paging
|
|
||||||
* And setting skipCount and maxItems under the number of total items
|
|
||||||
* Then hasMoreItems will be set to true
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void searchResultsUnderTotalItems() throws Exception
|
|
||||||
{
|
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(4, 5))
|
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
|
||||||
|
|
||||||
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI(null).search(sqlRequest);
|
|
||||||
assertEquals(searchResponse.getPagination().getCount(), 4);
|
|
||||||
assertEquals(searchResponse.getPagination().getSkipCount(), 5);
|
|
||||||
assertTrue(searchResponse.getPagination().isHasMoreItems());
|
|
||||||
assertEquals(searchResponse.getEntries().size(), 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -38,30 +38,55 @@ import org.alfresco.rest.core.search.SearchRequestBuilder;
|
|||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||||
import org.alfresco.rest.search.SearchResponse;
|
import org.alfresco.rest.search.SearchResponse;
|
||||||
|
import org.alfresco.rest.v0.UserTrashcanAPI;
|
||||||
import org.alfresco.utility.Utility;
|
import org.alfresco.utility.Utility;
|
||||||
import org.alfresco.utility.model.FileModel;
|
import org.alfresco.utility.model.FileModel;
|
||||||
import org.alfresco.utility.model.FileType;
|
import org.alfresco.utility.model.FileType;
|
||||||
import org.alfresco.utility.model.SiteModel;
|
import org.alfresco.utility.model.SiteModel;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.testng.annotations.AfterClass;
|
||||||
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains the tests for v1 Search API with documents with CMIS query
|
* This class contains the tests for v1 Search API with documents with CMIS and AFTS queries
|
||||||
*
|
|
||||||
* @author Rodica Sutu
|
|
||||||
* @since 2.6.0.2
|
|
||||||
*/
|
*/
|
||||||
public class SearchDocumentsV1CmisTest extends BaseRMRestTest
|
public class SearchDocumentsV1Test extends BaseRMRestTest
|
||||||
{
|
{
|
||||||
private static final String SEARCH_TERM = generateTestPrefix(SearchDocumentsV1CmisTest.class);
|
private static final String SEARCH_TERM = generateTestPrefix(SearchDocumentsV1Test.class);
|
||||||
private SiteModel collaborationSite;
|
private SiteModel collaborationSite;
|
||||||
private FileModel fileModel;
|
private FileModel fileModel;
|
||||||
private RestRequestQueryModel queryModel;
|
|
||||||
|
@Autowired
|
||||||
|
private UserTrashcanAPI userTrashcanAPI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data Provider with: queries using CMIS and AFTS languages
|
||||||
|
*/
|
||||||
|
@DataProvider
|
||||||
|
public static Object[][] queryTypes()
|
||||||
|
{
|
||||||
|
RestRequestQueryModel cmisQueryModel = new RestRequestQueryModel();
|
||||||
|
cmisQueryModel.setQuery("select * from cmis:document WHERE cmis:name LIKE '%" + SEARCH_TERM + ".txt'");
|
||||||
|
cmisQueryModel.setLanguage("cmis");
|
||||||
|
|
||||||
|
RestRequestQueryModel aftsQueryModel = new RestRequestQueryModel();
|
||||||
|
aftsQueryModel.setQuery("cm:name:*" + SEARCH_TERM);
|
||||||
|
aftsQueryModel.setLanguage("afts");
|
||||||
|
|
||||||
|
return new RestRequestQueryModel[][] {
|
||||||
|
{ cmisQueryModel },
|
||||||
|
{ aftsQueryModel }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a collaboration site and some documents.
|
* Create a collaboration site and some documents.
|
||||||
*/
|
*/
|
||||||
@BeforeClass (alwaysRun = true)
|
@BeforeClass (alwaysRun = true)
|
||||||
public void setupSearchAPIWithCMIS() throws Exception
|
public void beforeClass() throws Exception
|
||||||
{
|
{
|
||||||
STEP("Create a collaboration site");
|
STEP("Create a collaboration site");
|
||||||
collaborationSite = dataSite.usingAdmin().createPrivateRandomSite();
|
collaborationSite = dataSite.usingAdmin().createPrivateRandomSite();
|
||||||
@@ -72,19 +97,24 @@ public class SearchDocumentsV1CmisTest extends BaseRMRestTest
|
|||||||
fileModel = new FileModel(String.format("%s.%s", "Doc" + i + SEARCH_TERM, FileType.TEXT_PLAIN.extention));
|
fileModel = new FileModel(String.format("%s.%s", "Doc" + i + SEARCH_TERM, FileType.TEXT_PLAIN.extention));
|
||||||
dataContent.usingAdmin().usingSite(collaborationSite).createContent(fileModel);
|
dataContent.usingAdmin().usingSite(collaborationSite).createContent(fileModel);
|
||||||
}
|
}
|
||||||
queryModel = new RestRequestQueryModel();
|
}
|
||||||
queryModel.setQuery("select * from cmis:document WHERE cmis:name LIKE '%" + SEARCH_TERM + ".txt'");
|
|
||||||
queryModel.setLanguage("cmis");
|
|
||||||
|
|
||||||
//do a cmis query to wait for solr indexing
|
/**
|
||||||
Utility.sleep(5000, 80000, () ->
|
* Do the query to wait for solr indexing
|
||||||
|
*
|
||||||
|
* @param queryType the query being executed
|
||||||
|
* @throws Exception when maximum retry period is reached
|
||||||
|
*/
|
||||||
|
private void waitIndexing(RestRequestQueryModel queryType) throws Exception
|
||||||
{
|
{
|
||||||
SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
Utility.sleep(1000, 80000, () ->
|
||||||
|
{
|
||||||
|
SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryType)
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(100, 0))
|
.setPagingBuilder(new SearchRequestBuilder().setPagination(100, 0))
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
.setFieldsBuilder(asList("id", "name"));
|
||||||
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI(null).search(sqlRequest);
|
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI(null).search(sqlRequest);
|
||||||
assertEquals(searchResponse.getPagination().getTotalItems().intValue(), 10,
|
assertEquals(searchResponse.getPagination().getTotalItems().intValue(), 10,
|
||||||
"Total number of items is not 10, got " + searchResponse.getPagination().getTotalItems() + " total items");
|
"Total number of items is not retrieved yet");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,18 +125,19 @@ public class SearchDocumentsV1CmisTest extends BaseRMRestTest
|
|||||||
* Then hasMoreItems will be set to false
|
* Then hasMoreItems will be set to false
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void searchWhenMaxItemReach () throws Exception
|
(dataProvider = "queryTypes")
|
||||||
|
public void searchWhenMaxItemsReach(RestRequestQueryModel queryType) throws Exception
|
||||||
{
|
{
|
||||||
|
waitIndexing(queryType);
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryType)
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 5))
|
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 5))
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
.setFieldsBuilder(asList("id", "name"));
|
||||||
|
|
||||||
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI().search(sqlRequest);
|
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI().search(sqlRequest);
|
||||||
assertEquals(searchResponse.getPagination().getCount(), 5);
|
assertEquals(searchResponse.getPagination().getCount(), 5, "Expected maxItems to be five");
|
||||||
assertEquals(searchResponse.getPagination().getSkipCount(), 5);
|
assertEquals(searchResponse.getPagination().getSkipCount(), 5, "Expected skip count to be five");
|
||||||
assertFalse(searchResponse.getPagination().isHasMoreItems());
|
assertFalse(searchResponse.getPagination().isHasMoreItems(), "Expected hasMoreItems to be false");
|
||||||
assertEquals(searchResponse.getEntries().size(), 5);
|
assertEquals(searchResponse.getEntries().size(), 5, "Expected total entries to be five");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,18 +147,19 @@ public class SearchDocumentsV1CmisTest extends BaseRMRestTest
|
|||||||
* Then hasMoreItems will be set to false
|
* Then hasMoreItems will be set to false
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void searchWhenTotalItemsExceed () throws Exception
|
(dataProvider = "queryTypes")
|
||||||
|
public void searchWhenTotalItemsExceed(RestRequestQueryModel queryType) throws Exception
|
||||||
{
|
{
|
||||||
|
waitIndexing(queryType);
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryType)
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 6))
|
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 6))
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
.setFieldsBuilder(asList("id", "name"));
|
||||||
|
|
||||||
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI().search(sqlRequest);
|
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI().search(sqlRequest);
|
||||||
assertEquals(searchResponse.getPagination().getCount(), 4);
|
assertEquals(searchResponse.getPagination().getCount(), 4, "Expected maxItems to be four");
|
||||||
assertEquals(searchResponse.getPagination().getSkipCount(), 6);
|
assertEquals(searchResponse.getPagination().getSkipCount(), 6, "Expected skip count to be six");
|
||||||
assertFalse(searchResponse.getPagination().isHasMoreItems());
|
assertFalse(searchResponse.getPagination().isHasMoreItems(), "Expected hasMoreItems to be false");
|
||||||
assertEquals(searchResponse.getEntries().size(), 4);
|
assertEquals(searchResponse.getEntries().size(), 4, "Expected total entries to be four");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,18 +169,27 @@ public class SearchDocumentsV1CmisTest extends BaseRMRestTest
|
|||||||
* Then hasMoreItems will be set to true
|
* Then hasMoreItems will be set to true
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void searchResultsUnderTotalItems() throws Exception
|
(dataProvider = "queryTypes")
|
||||||
|
public void searchResultsUnderTotalItems(RestRequestQueryModel queryType) throws Exception
|
||||||
{
|
{
|
||||||
|
waitIndexing(queryType);
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryType)
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(4, 5))
|
.setPagingBuilder(new SearchRequestBuilder().setPagination(4, 5))
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
.setFieldsBuilder(asList("id", "name"));
|
||||||
|
|
||||||
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI().search(sqlRequest);
|
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI().search(sqlRequest);
|
||||||
assertEquals(searchResponse.getPagination().getCount(), 4);
|
assertEquals(searchResponse.getPagination().getCount(), 4, "Expected maxItems to be four");
|
||||||
assertEquals(searchResponse.getPagination().getSkipCount(), 5);
|
assertEquals(searchResponse.getPagination().getSkipCount(), 5, "Expected skip count to be five");
|
||||||
assertTrue(searchResponse.getPagination().isHasMoreItems());
|
assertTrue(searchResponse.getPagination().isHasMoreItems(), "Expected hasMoreItems to be true");
|
||||||
assertEquals(searchResponse.getEntries().size(), 4);
|
assertEquals(searchResponse.getEntries().size(), 4, "Expected total entries to be four");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterTest
|
||||||
|
@AfterClass (alwaysRun = true)
|
||||||
|
public void tearDown()
|
||||||
|
{
|
||||||
|
dataSite.usingAdmin().deleteSite(collaborationSite);
|
||||||
|
userTrashcanAPI.emptyTrashcan(getAdminUser().getUsername(), getAdminUser().getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -46,8 +46,6 @@ import org.alfresco.utility.model.FileModel;
|
|||||||
import org.alfresco.utility.model.FileType;
|
import org.alfresco.utility.model.FileType;
|
||||||
import org.alfresco.utility.model.SiteModel;
|
import org.alfresco.utility.model.SiteModel;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@@ -66,7 +64,6 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
|||||||
private RestRequestQueryModel queryModel;
|
private RestRequestQueryModel queryModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a collaboration site and some in place records.
|
* Create a collaboration site and some in place records.
|
||||||
*/
|
*/
|
||||||
@@ -76,7 +73,7 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
|||||||
STEP("Create a collaboration site");
|
STEP("Create a collaboration site");
|
||||||
collaborationSite = dataSite.usingAdmin().createPrivateRandomSite();
|
collaborationSite = dataSite.usingAdmin().createPrivateRandomSite();
|
||||||
|
|
||||||
STEP("Create a collaborator user for the collaboration site");
|
STEP("Create a site manager user for the collaboration site");
|
||||||
nonRMUser = getDataUser().createRandomTestUser();
|
nonRMUser = getDataUser().createRandomTestUser();
|
||||||
getDataUser().addUserToSite(nonRMUser, collaborationSite, UserRole.SiteManager);
|
getDataUser().addUserToSite(nonRMUser, collaborationSite, UserRole.SiteManager);
|
||||||
|
|
||||||
@@ -103,6 +100,7 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
|||||||
queryModel.setQuery("select * from cmis:document WHERE cmis:name LIKE 'Record" + SEARCH_TERM + "%'");
|
queryModel.setQuery("select * from cmis:document WHERE cmis:name LIKE 'Record" + SEARCH_TERM + "%'");
|
||||||
queryModel.setLanguage("cmis");
|
queryModel.setLanguage("cmis");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given some documents with names starting with a particular test
|
* Given some documents with names starting with a particular test
|
||||||
* When executing the search query with paging
|
* When executing the search query with paging
|
||||||
@@ -110,7 +108,7 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
|||||||
* Then hasMoreItems will be set to false
|
* Then hasMoreItems will be set to false
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
private void searchWhenTotalItemsReach () throws Exception
|
public void searchWhenTotalItemsReach() throws Exception
|
||||||
{
|
{
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 15))
|
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 15))
|
||||||
@@ -124,10 +122,10 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
private void searchWhenTotalItemsReachWithNonRM () throws Exception
|
public void searchWhenTotalItemsReachWithNonRM() throws Exception
|
||||||
{
|
{
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 5))
|
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 0))
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
.setFieldsBuilder(asList("id", "name"));
|
||||||
|
|
||||||
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI(nonRMUser).search(sqlRequest);
|
SearchResponse searchResponse = getRestAPIFactory().getSearchAPI(nonRMUser).search(sqlRequest);
|
||||||
@@ -136,6 +134,7 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
|||||||
assertFalse(searchResponse.getPagination().isHasMoreItems());
|
assertFalse(searchResponse.getPagination().isHasMoreItems());
|
||||||
assertEquals(searchResponse.getEntries().size(), 5);
|
assertEquals(searchResponse.getEntries().size(), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given some documents with names starting with a particular text
|
* Given some documents with names starting with a particular text
|
||||||
* When executing the search query with paging
|
* When executing the search query with paging
|
||||||
@@ -143,9 +142,8 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
|||||||
* Then hasMoreItems will be set to false
|
* Then hasMoreItems will be set to false
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
private void searchWhenTotalItemsExceedRMUser () throws Exception
|
public void searchWhenTotalItemsExceedRMUser() throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 16))
|
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 16))
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
.setFieldsBuilder(asList("id", "name"));
|
||||||
@@ -158,9 +156,8 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
private void searchWhenTotalItemsExceedNonRMUser () throws Exception
|
public void searchWhenTotalItemsExceedNonRMUser() throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 6))
|
.setPagingBuilder(new SearchRequestBuilder().setPagination(5, 6))
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
.setFieldsBuilder(asList("id", "name"));
|
||||||
@@ -176,12 +173,11 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
|||||||
* Given some documents ending with a particular text
|
* Given some documents ending with a particular text
|
||||||
* When executing the search query with paging
|
* When executing the search query with paging
|
||||||
* And setting skipCount and maxItems under the number of total items
|
* And setting skipCount and maxItems under the number of total items
|
||||||
* Then hasMoreItems will be set to false
|
* Then hasMoreItems will be set to true
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
private void searchResultsUnderTotalItemsRMUser() throws Exception
|
public void searchResultsUnderTotalItemsRMUser() throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(4, 15))
|
.setPagingBuilder(new SearchRequestBuilder().setPagination(4, 15))
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
.setFieldsBuilder(asList("id", "name"));
|
||||||
@@ -192,10 +188,10 @@ public class SearchRecordsV1CmisTests extends BaseRMRestTest
|
|||||||
assertTrue(searchResponse.getPagination().isHasMoreItems());
|
assertTrue(searchResponse.getPagination().isHasMoreItems());
|
||||||
assertEquals(searchResponse.getEntries().size(), 4);
|
assertEquals(searchResponse.getEntries().size(), 4);
|
||||||
}
|
}
|
||||||
@Test
|
|
||||||
private void searchResultsUnderTotalItemsNonRMUser() throws Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void searchResultsUnderTotalItemsNonRMUser() throws Exception
|
||||||
|
{
|
||||||
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
final SearchRequestBuilder sqlRequest = new SearchRequestBuilder().setQueryBuilder(queryModel)
|
||||||
.setPagingBuilder(new SearchRequestBuilder().setPagination(4, 5))
|
.setPagingBuilder(new SearchRequestBuilder().setPagination(4, 5))
|
||||||
.setFieldsBuilder(asList("id", "name"));
|
.setFieldsBuilder(asList("id", "name"));
|
||||||
|
Reference in New Issue
Block a user