mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch 'feature/Search_1485_phase2' into 'master'
Feature/search 1485 phase2 See merge request search_discovery/SearchAnalyticsE2ETest!38
This commit is contained in:
+1
-1
@@ -35,4 +35,4 @@ Search Services 1.2.0 or above or Insight Engine 1.0.0 or above
|
||||
|
||||
e.g.
|
||||
|
||||
`mvn clean install -Dtest=org.alfresco.service.search.e2e.insightEngine.sql.CustomModelTest`
|
||||
`mvn clean install -Dtest=CustomModelTest`
|
||||
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package org.alfresco.service.search.e2e.insightEngine.jdbc;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.utility.network.ServerHealth;
|
||||
import org.alfresco.utility.network.db.DatabaseOperationImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* This class is connecting via JDBC Driver (see default.properties)
|
||||
*
|
||||
* example:
|
||||
* db.url= jdbc:alfresco://${alfresco.server}:${alfresco.port}?collection=alfresco
|
||||
*
|
||||
* I am using the TAS DatabaseOperationImpl service to connect
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration("classpath:alfresco-search-e2e-context.xml")
|
||||
public class JDBCDriverTest extends AbstractTestNGSpringContextTests {
|
||||
|
||||
@Autowired
|
||||
protected ServerHealth serverHealth;
|
||||
|
||||
@Autowired
|
||||
DatabaseOperationImpl jdbcOperation;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void checkServerHealth() throws Exception {
|
||||
serverHealth.assertServerIsOnline();
|
||||
}
|
||||
|
||||
/**
|
||||
* In order to work start ACS + InsightEngine service
|
||||
* @throws SQLException
|
||||
*/
|
||||
@Test
|
||||
public void iCanConnectWithJDBCDriver() throws SQLException {
|
||||
assertTrue(jdbcOperation.connect(), "I can connect via JDBC Driver");
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods="iCanConnectWithJDBCDriver")
|
||||
public void iCanQueryTheTotalNumberOfDocumentsFromAlfresco() {
|
||||
List<Object> results = jdbcOperation.executeQuery("select cm_name from alfresco where cm_Name = 'presentation*'");
|
||||
assertEquals(results.size(), 3);
|
||||
}
|
||||
}
|
||||
-257
@@ -1,257 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Alfresco Software, Ltd. All rights reserved.
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
package org.alfresco.service.search.e2e.insightEngine.sql;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.stream.IntStream.range;
|
||||
|
||||
import org.alfresco.service.search.e2e.AbstractSearchServiceE2E;
|
||||
import org.alfresco.utility.LogFactory;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.slf4j.Logger;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Purpose of this TestClass is to test that the fields name follows a given case-sensitive rule in different part of the query.
|
||||
* Specifically:
|
||||
*
|
||||
* <ul>
|
||||
* <li>When a field is declared in the field list (e.g. SELECT *a,b,c*) the case matters because a field with
|
||||
* the exact case will be in the returned tuples.
|
||||
* </li>
|
||||
* <li>
|
||||
* When a field is part of the predicate (e.g. WHERE a=somevalue) the case doesn't matter
|
||||
* </li>
|
||||
* <li>
|
||||
* When a field is part of the expression (e.g. order by, group by) the case doesn't matter. However, specifically
|
||||
* for aggregation expressions (e.g. group by), the same field with the exact case needs to be in field list (and
|
||||
* here, see the first point, the case matters).
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author agazzarini
|
||||
* {@link https://issues.alfresco.com/jira/browse/SEARCH-1491}
|
||||
*/
|
||||
public class CaseSensitivityInFieldsNamesTest extends AbstractSearchServiceE2E
|
||||
{
|
||||
private static Logger LOG = LogFactory.getLogger();
|
||||
|
||||
/**
|
||||
* Creates the test dataset that will be used in this test case.
|
||||
*/
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
serverHealth.assertServerIsOnline();
|
||||
|
||||
super.springTestContextPrepareTestInstance();
|
||||
|
||||
try
|
||||
{
|
||||
deployCustomModel("model/expense-model.xml");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Error Loading Expense Model", e);
|
||||
}
|
||||
|
||||
FolderModel testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
|
||||
createAndAddNewFile(testFolder, 1, "Maidenhead", "GBP", 10.2);
|
||||
createAndAddNewFile(testFolder, 2, "London", "GBP", 100.4);
|
||||
createAndAddNewFile(testFolder, 3, "Manchester", "GBP", 1737.22);
|
||||
FileModel lastFile = createAndAddNewFile(testFolder, 4, "Liverpool", "GBP", 445.9);
|
||||
|
||||
waitForIndexing(lastFile.getName(), true);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.INSIGHT_11 })
|
||||
public void fieldsInSelectListAreCaseSensitive()
|
||||
{
|
||||
List<String> selectLists =
|
||||
asList("EXPENSE_LOCATION,cm_name,expense_Currency",
|
||||
"Expense_Currency,CM_NAME,ExPenSe_LOCATion",
|
||||
"expense_location,expense_currency,cM_NaMe");
|
||||
|
||||
int expectedNumberOfResults = 4;
|
||||
|
||||
selectLists.forEach(fields -> {
|
||||
String query = "select " + fields + " from alfresco where expense_Currency='GBP' and TYPE = 'expense:expenseReport'";
|
||||
|
||||
testSqlQuery(query, expectedNumberOfResults);
|
||||
|
||||
String[] expectedNames = fields.split(",");
|
||||
|
||||
range(0, expectedNames.length)
|
||||
.forEach(labelIndex -> {
|
||||
String expectedName = expectedNames[labelIndex];
|
||||
|
||||
for (int entryIndex = 0; entryIndex < expectedNumberOfResults; entryIndex++)
|
||||
restClient.onResponse()
|
||||
.assertThat()
|
||||
.body("list.entries.entry[" + entryIndex + "][" + labelIndex + "].label", Matchers.equalTo(expectedName));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.INSIGHT_11 })
|
||||
public void fieldsInCountListAreCaseInsensitive()
|
||||
{
|
||||
List<String> selectLists =
|
||||
asList("cm_name", "CM_NAME","cM_NaMe", "expense_Currency","EXPENSE_CURRENCY");
|
||||
|
||||
selectLists.forEach(field -> {
|
||||
String query = "select count(" + field + ") from alfresco where expense_Currency='GBP' and TYPE = 'expense:expenseReport'";
|
||||
|
||||
testSqlQuery(query, 1);
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalTo("EXPR$0"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalTo("4"));
|
||||
});
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.INSIGHT_11 })
|
||||
public void fieldsInPredicateAreCaseInsensitive()
|
||||
{
|
||||
List<String> queries =
|
||||
asList("select TYPE from alfresco where expense_Currency='GBP' and type = 'expense:expenseReport'",
|
||||
"select TYPE from alfresco where EXPENSE_CURRENCY='GBP' and TYPE = 'expense:expenseReport'",
|
||||
"select TYPE from alfresco where ExPeNsE_CurrENCY='GBP' and TyPe = 'expense:expenseReport'");
|
||||
|
||||
int expectedNumberOfResults = 4;
|
||||
|
||||
queries.forEach(query -> {
|
||||
testSqlQuery(query, expectedNumberOfResults);
|
||||
|
||||
range(0, expectedNumberOfResults)
|
||||
.forEach(entryIndex -> {
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[" + entryIndex + "][0].label", Matchers.equalTo("TYPE"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[" + entryIndex + "][0].value", Matchers.equalTo("{http://www.mycompany.com/model/expense/1.0}expenseReport"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.INSIGHT_11 })
|
||||
public void fieldsInExpressionsAreCaseInsensitive()
|
||||
{
|
||||
List<String> fieldNames = asList("expense_Currency", "EXPENSE_CURRENCY", "ExPeNsE_CurrENCY");
|
||||
List<String> queries = fieldNames.stream()
|
||||
.map(fieldName -> asList(
|
||||
"select " + fieldName + " from alfresco where TYPE = 'expense:expenseReport' group by " + fieldName + " having sum(EXPENSE_AMOUNT) > 0",
|
||||
"select " + fieldName + " from alfresco where TYPE = 'expense:expenseReport' group by " + fieldName + " having sum(expense_Amount) > 0",
|
||||
"select " + fieldName + " from alfresco where TYPE = 'expense:expenseReport' group by " + fieldName + " having sum(expense_amount) > 0"))
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
queries.forEach(query -> {
|
||||
testSqlQuery(query, 1);
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("expense_Currency"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalTo("GBP"));
|
||||
});
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.INSIGHT_11 })
|
||||
public void fieldsInSortExpressionAreCaseInsensitive_descendingOrder()
|
||||
{
|
||||
List<String> queries =
|
||||
asList("select expense_Id from alfresco where expense_Currency='GBP' and type = 'expense:expenseReport' order by expense_id desc",
|
||||
"select expense_Id from alfresco where expense_Currency='GBP' and TYPE = 'expense:expenseReport' order by expense_id desc",
|
||||
"select expense_Id from alfresco where expense_Currency='GBP' and TyPe = 'expense:expenseReport' order by expense_id desc");
|
||||
|
||||
int expectedNumberOfResults = 4;
|
||||
|
||||
queries.forEach(query -> {
|
||||
testSqlQuery(query, expectedNumberOfResults);
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("expense_Id"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalTo("4"));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][0].label", Matchers.equalToIgnoringCase("expense_Id"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][0].value", Matchers.equalTo("3"));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[2][0].label", Matchers.equalToIgnoringCase("expense_Id"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[2][0].value", Matchers.equalTo("2"));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[3][0].label", Matchers.equalToIgnoringCase("expense_Id"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[3][0].value", Matchers.equalTo("1"));
|
||||
});
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.INSIGHT_11 })
|
||||
public void fieldsInSortExpressionAreCaseInsensitive_ascendingOrder()
|
||||
{
|
||||
List<String> queries =
|
||||
asList("select expense_Id from alfresco where expense_Currency='GBP' and type = 'expense:expenseReport' order by expense_id asc",
|
||||
"select expense_Id from alfresco where expense_Currency='GBP' and TYPE = 'expense:expenseReport' order by expense_id asc",
|
||||
"select expense_Id from alfresco where expense_Currency='GBP' and TyPe = 'expense:expenseReport' order by expense_id asc",
|
||||
"select expense_Id from alfresco where expense_Currency='GBP' and TYPE = 'expense:expenseReport' order by expense_id asc");
|
||||
|
||||
int expectedNumberOfResults = 4;
|
||||
|
||||
queries.forEach(query -> {
|
||||
testSqlQuery(query, expectedNumberOfResults);
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("expense_Id"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalTo("1"));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][0].label", Matchers.equalToIgnoringCase("expense_Id"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][0].value", Matchers.equalTo("2"));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[2][0].label", Matchers.equalToIgnoringCase("expense_Id"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[2][0].value", Matchers.equalTo("3"));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[3][0].label", Matchers.equalToIgnoringCase("expense_Id"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[3][0].value", Matchers.equalTo("4"));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method used for creating a sample file, with some data used within the tests.
|
||||
*
|
||||
* @param parentFolder the parent folder.
|
||||
* @param id the file identifier.
|
||||
* @param location the location (a String property)
|
||||
* @param currency the currency (another String property)
|
||||
* @param amount the amount
|
||||
* @return the just created {@link FileModel} instance.
|
||||
*/
|
||||
private FileModel createAndAddNewFile(final FolderModel parentFolder, int id, String location, String currency, double amount) throws Exception
|
||||
{
|
||||
FileModel file = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content #" + System.currentTimeMillis());
|
||||
file.setName("file-"+ file.getName());
|
||||
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:expense:expenseReport");
|
||||
properties.put(PropertyIds.NAME, file.getName());
|
||||
properties.put("expense:id", id);
|
||||
properties.put("expense:Location", location);
|
||||
properties.put("expense:Currency", currency);
|
||||
properties.put("expense:Approved", true);
|
||||
properties.put("expense:Amount", amount);
|
||||
|
||||
cmisApi.authenticateUser(testUser)
|
||||
.usingSite(testSite)
|
||||
.usingResource(parentFolder)
|
||||
.createFile(file, properties, VersioningState.MAJOR)
|
||||
.assertThat()
|
||||
.existsInRepo();
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
-224
@@ -1,224 +0,0 @@
|
||||
package org.alfresco.service.search.e2e.insightEngine.sql;
|
||||
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.search.SearchSqlRequest;
|
||||
import org.alfresco.service.search.e2e.AbstractSearchServiceE2E;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.*;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CustoModelGroupByFacetableTest extends AbstractSearchServiceE2E
|
||||
{
|
||||
|
||||
protected SiteModel testSite;
|
||||
private UserModel testUser;
|
||||
private FolderModel testFolder;
|
||||
|
||||
private String filename1;
|
||||
private String filename2;
|
||||
private String filename3;
|
||||
private String filename4;
|
||||
|
||||
private String filecontent1;
|
||||
private String filecontent2;
|
||||
private String filecontent3;
|
||||
private String filecontent4;
|
||||
|
||||
private String author1;
|
||||
private String author2;
|
||||
|
||||
private Boolean exists;
|
||||
|
||||
private int quantity1;
|
||||
private int quantity2;
|
||||
private int quantity3;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
|
||||
serverHealth.assertServerIsOnline();
|
||||
deployCustomModel("model/facetable-aspect-model.xml");
|
||||
testSite = dataSite.createPublicRandomSite();
|
||||
|
||||
// Create test user and add the user as a SiteContributor
|
||||
testUser = dataUser.createRandomTestUser();
|
||||
dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor);
|
||||
testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
|
||||
filename1 = "file1";
|
||||
filename2 = "file2";
|
||||
filename3 = "file3";
|
||||
filename4 = "file4";
|
||||
|
||||
filecontent1 = "file content 1";
|
||||
filecontent2 = "content file 2";
|
||||
filecontent3 = "content file 3";
|
||||
filecontent4 = "content file 4";
|
||||
|
||||
author1 = "Giuseppe Verdi";
|
||||
author2 = "Mario Rossi";
|
||||
|
||||
exists = true;
|
||||
|
||||
quantity1 = 9;
|
||||
quantity2 = 10;
|
||||
quantity3 = 12;
|
||||
|
||||
FileModel customFile = new FileModel(filename1, FileType.TEXT_PLAIN, filecontent1);
|
||||
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
|
||||
properties.put(PropertyIds.NAME, customFile.getName());
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(customFile, properties, VersioningState.MAJOR).assertThat()
|
||||
.existsInRepo();
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile).addSecondaryTypes("P:csm:author").assertThat().secondaryTypeIsAvailable("P:csm:author");
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile).addSecondaryTypes("P:csm:nontexttypes").assertThat()
|
||||
.secondaryTypeIsAvailable("P:csm:nontexttypes");
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile).updateProperty("csm:author", author2);
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile).updateProperty("csm:quantity", quantity3);
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile).updateProperty("csm:exists", exists);
|
||||
|
||||
FileModel customFile2 = new FileModel(filename2, FileType.TEXT_PLAIN, filecontent2);
|
||||
properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
|
||||
properties.put(PropertyIds.NAME, customFile2.getName());
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(customFile2, properties, VersioningState.MAJOR).assertThat()
|
||||
.existsInRepo();
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile2).addSecondaryTypes("P:csm:author").assertThat().secondaryTypeIsAvailable("P:csm:author");
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile2).addSecondaryTypes("P:csm:nontexttypes").assertThat()
|
||||
.secondaryTypeIsAvailable("P:csm:nontexttypes");
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile2).updateProperty("csm:author", author1);
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile2).updateProperty("csm:quantity", quantity2);
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile2).updateProperty("csm:exists", exists);
|
||||
|
||||
FileModel customFile3 = new FileModel(filename3, FileType.TEXT_PLAIN, filecontent3);
|
||||
properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
|
||||
properties.put(PropertyIds.NAME, customFile3.getName());
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(customFile3, properties, VersioningState.MAJOR).assertThat()
|
||||
.existsInRepo();
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile3).addSecondaryTypes("P:csm:author").assertThat().secondaryTypeIsAvailable("P:csm:author");
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile3).addSecondaryTypes("P:csm:nontexttypes").assertThat()
|
||||
.secondaryTypeIsAvailable("P:csm:nontexttypes");
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile3).updateProperty("csm:author", author1);
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile3).updateProperty("csm:quantity", quantity2);
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile3).updateProperty("csm:exists", exists);
|
||||
|
||||
FileModel customFile4 = new FileModel(filename4, FileType.TEXT_PLAIN, filecontent4);
|
||||
properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
|
||||
properties.put(PropertyIds.NAME, customFile4.getName());
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(customFile4, properties, VersioningState.MAJOR).assertThat()
|
||||
.existsInRepo();
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile4).addSecondaryTypes("P:csm:nontexttypes").assertThat()
|
||||
.secondaryTypeIsAvailable("P:csm:nontexttypes");
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile4).updateProperty("csm:quantity", quantity1);
|
||||
cmisApi.authenticateUser(testUser).usingResource(customFile4).updateProperty("csm:exists", !exists);
|
||||
|
||||
// wait for indexing
|
||||
waitForIndexing("cm:name:'" + customFile4.getName() + "'", true);
|
||||
waitForIndexing("cm:name:'" + testFolder.getName() + "'", true);
|
||||
|
||||
}
|
||||
|
||||
@Test(priority = 1, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testGroupByTextFacetableModel() throws Exception
|
||||
{
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select cm_name, csm_author from alfresco group by cm_name, csm_author");
|
||||
|
||||
RestResponse response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("cm_name"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("csm_author"));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase(filename1));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][0].value", Matchers.equalToIgnoringCase(filename2));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[2][0].value", Matchers.equalToIgnoringCase(filename3));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.equalToIgnoringCase(author2));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][1].value", Matchers.equalToIgnoringCase(author1));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[2][1].value", Matchers.equalToIgnoringCase(author1));
|
||||
|
||||
// Test changing the order of fields.
|
||||
sqlRequest.setSql("select csm_author, cm_name from alfresco group by csm_author, cm_name");
|
||||
|
||||
response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("list.pagination.count", Matchers.equalTo(3));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("cm_name"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("csm_author"));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase(filename2));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][0].value", Matchers.equalToIgnoringCase(filename3));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[2][0].value", Matchers.equalToIgnoringCase(filename1));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.equalToIgnoringCase(author1));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][1].value", Matchers.equalToIgnoringCase(author1));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[2][1].value", Matchers.equalToIgnoringCase(author2));
|
||||
|
||||
}
|
||||
|
||||
@Test(priority = 2, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testGroupByTextInteger() throws Exception
|
||||
{
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select csm_quantity, csm_author from alfresco group by csm_quantity, csm_author");
|
||||
|
||||
RestResponse response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("list.pagination.count", Matchers.equalTo(2));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("csm_author"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("csm_quantity"));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.equalToIgnoringCase(Integer.toString(quantity2)));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase(author1));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][1].value", Matchers.equalToIgnoringCase(Integer.toString(quantity3)));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][0].value", Matchers.equalToIgnoringCase(author2));
|
||||
|
||||
}
|
||||
|
||||
@Test(priority = 3, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testGroupByBoolAggregation() throws Exception
|
||||
{
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select csm_exists, max(csm_quantity) from alfresco group by csm_exists");
|
||||
|
||||
RestResponse response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.onResponse().assertThat().body("list.pagination.count", Matchers.equalTo(2));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase(Boolean.toString(!exists)));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][0].value", Matchers.equalToIgnoringCase(Boolean.toString(exists)));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.equalToIgnoringCase(Integer.toString(quantity1)));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[1][1].value", Matchers.equalToIgnoringCase(Integer.toString(quantity3)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-126
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Alfresco Software, Ltd. All rights reserved.
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
package org.alfresco.service.search.e2e.insightEngine.sql;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.search.SearchSqlRequest;
|
||||
import org.alfresco.service.search.e2e.AbstractSearchServiceE2E;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
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.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Purpose of this TestClass is to test that the SQLs work after model changes
|
||||
*
|
||||
* @author meenal bhave
|
||||
*/
|
||||
public class CustomModelChangesTest extends AbstractSearchServiceE2E
|
||||
{
|
||||
protected SiteModel testSite;
|
||||
|
||||
private UserModel testUser;
|
||||
|
||||
private FolderModel testFolder;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
serverHealth.assertServerIsOnline();
|
||||
|
||||
deployCustomModel("model/flipStatus-model.xml");
|
||||
|
||||
testSite = dataSite.createPublicRandomSite();
|
||||
|
||||
// Create test user and add the user as a SiteContributor
|
||||
testUser = dataUser.createRandomTestUser();
|
||||
|
||||
dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor);
|
||||
|
||||
testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
|
||||
// Wait for the file to be indexed
|
||||
waitForIndexing(testFolder.getName(), true);
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun=true)
|
||||
public void deleteModel()
|
||||
{
|
||||
deleteCustomModel("flipStatus-model.xml");
|
||||
}
|
||||
|
||||
// SQL works after model is deactivated
|
||||
@Test(priority = 1, groups = { TestGroup.INSIGHT_10 })
|
||||
public void testSqlWorksAfterDeactivatingModel() throws Exception
|
||||
{
|
||||
FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:flipFlop:song");
|
||||
properties.put(PropertyIds.NAME, customFile.getName());
|
||||
properties.put("flipFlop:genre", "Pop");
|
||||
properties.put("flipFlop:lyricist", "SomeLyricist");
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
|
||||
.createFile(customFile, properties, VersioningState.MAJOR)
|
||||
.assertThat().existsInRepo();
|
||||
|
||||
// Wait for the file to be indexed
|
||||
waitForIndexing(customFile.getName(), true);
|
||||
|
||||
// Query custom model fields
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select cm_name, flipFlop_genre, flipFlop_lyricist from alfresco where cm_name = '" + customFile.getName() + "'");
|
||||
sqlRequest.setLimit(10);
|
||||
|
||||
RestResponse response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("list.pagination.count", Matchers.equalTo(1));
|
||||
|
||||
// Delete File and Delete from trash
|
||||
dataContent.usingSite(testSite).usingUser(testUser).usingResource(customFile).deleteContent();
|
||||
restClient.withCoreAPI().usingTrashcan().deleteNodeFromTrashcan(customFile);
|
||||
|
||||
// Wait for the file delete transaction to be indexed, until Search API returns no results
|
||||
Boolean fileFound = waitForIndexing("cm:name:'" + customFile.getName() + "'", false);
|
||||
Assert.assertTrue(fileFound, "File appears in the search results when deleted from trash");
|
||||
|
||||
// Query custom model fields: No matching content
|
||||
response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
// Deactivate the Model
|
||||
deactivateCustomModel("flipStatus-model.xml");
|
||||
|
||||
fileFound = waitForIndexing("TYPE:'" + "flipFlop:song" + "'", false);
|
||||
Assert.assertTrue(fileFound, "Indexes are not updated after deactivating a model");
|
||||
|
||||
// Query OOTB fields: Custom Model Deactivated
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select count(*) as TotalDocuments from alfresco where type = 'cm:content'");
|
||||
|
||||
response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("list.pagination.count", Matchers.equalTo(1));
|
||||
}
|
||||
}
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Alfresco Software, Ltd. All rights reserved.
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
package org.alfresco.service.search.e2e.insightEngine.sql;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.search.SearchSqlRequest;
|
||||
import org.alfresco.service.search.e2e.AbstractSearchServiceE2E;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Purpose of this TestClass is to test that the SQL end point works as expected with CustomModels
|
||||
*
|
||||
* @author meenal bhave
|
||||
*/
|
||||
|
||||
public class CustomModelTest extends AbstractSearchServiceE2E
|
||||
{
|
||||
@Autowired
|
||||
protected DataSite dataSite;
|
||||
|
||||
@Autowired
|
||||
protected DataContent dataContent;
|
||||
|
||||
protected SiteModel testSite;
|
||||
|
||||
private UserModel testUser;
|
||||
|
||||
private FolderModel testFolder;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
serverHealth.assertServerIsOnline();
|
||||
|
||||
testSite = dataSite.createPublicRandomSite();
|
||||
|
||||
// Create test user and add the user as a SiteContributor
|
||||
testUser = dataUser.createRandomTestUser();
|
||||
|
||||
dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor);
|
||||
|
||||
testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
}
|
||||
|
||||
// Content of Custom Type is added to the Repo
|
||||
@Test(priority = 1, groups = { TestGroup.INSIGHT_10 })
|
||||
public void testSqlListCustomFields() throws Exception
|
||||
{
|
||||
Long uniqueRef = System.currentTimeMillis();
|
||||
FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Receipt");
|
||||
properties.put(PropertyIds.NAME, customFile.getName());
|
||||
properties.put("finance:ReceiptNo", uniqueRef);
|
||||
properties.put("finance:ReceiptValue", 30);
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
|
||||
.createFile(customFile, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
|
||||
// Wait for the file to be indexed
|
||||
waitForIndexing(customFile.getName(), true);
|
||||
|
||||
// Select distinct site: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select finance_ReceiptNo, finance_ReceiptValue from alfresco where finance_ReceiptNo = " + uniqueRef);
|
||||
sqlRequest.setLimit(10);
|
||||
|
||||
RestResponse response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(10));
|
||||
response.assertThat().body("list.pagination.count", Matchers.equalTo(1));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("finance_ReceiptValue"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("finance_ReceiptNo"));
|
||||
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase("30.0"));
|
||||
restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.equalTo(uniqueRef.toString()));
|
||||
|
||||
// Select distinct cm_name: solr format
|
||||
sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select finance_ReceiptNo, finance_ReceiptValue from alfresco where finance_ReceiptNo = " + uniqueRef + " limit 10");
|
||||
sqlRequest.setFormat("solr");
|
||||
|
||||
response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].finance_ReceiptValue", Matchers.equalTo(30));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].finance_ReceiptNo", Matchers.equalTo(uniqueRef));
|
||||
}
|
||||
}
|
||||
-781
@@ -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.service.search.e2e.insightEngine.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.service.search.e2e.searchservices.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"));
|
||||
}
|
||||
}
|
||||
-256
@@ -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.service.search.e2e.insightEngine.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.service.search.e2e.searchservices.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()));
|
||||
}
|
||||
}
|
||||
-213
@@ -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.service.search.e2e.insightEngine.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.service.search.e2e.searchservices.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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
-218
@@ -1,218 +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.service.search.e2e.insightEngine.sql;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.alfresco.service.search.e2e.searchservices.AbstractSearchTest;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.CustomObjectTypeProperties;
|
||||
import org.alfresco.utility.model.ContentModel;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import org.alfresco.rest.RestTest;
|
||||
|
||||
/**
|
||||
* Tests for /sql end point Search API when a custom model contains identifiers that need to be quoted in queries.
|
||||
* While it seems there is not an ANSI standard for naming database objects, on the other side the most popular
|
||||
* databases don't like columns starting with a number.
|
||||
* In those cases, the column identifier need to be quoted. How to quote a given object identifier (a column name, in
|
||||
* this case) depends on the specific database lexicon: Oracle uses double quotes ("), MySQL uses back quotes(`).
|
||||
*
|
||||
* At time of writing, the lexicon used by the /sql endpoint is MySql so queries that use column names starting with
|
||||
* a number need to be quoted with back quotes.
|
||||
*
|
||||
*/
|
||||
public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest
|
||||
{
|
||||
|
||||
private String songName;
|
||||
private String genre;
|
||||
private String coProducer;
|
||||
|
||||
private String artistName;
|
||||
private String voiceType;
|
||||
|
||||
private String bassistName;
|
||||
private String drummerName;
|
||||
private String saxophonistName;
|
||||
|
||||
private FileModel file5;
|
||||
|
||||
/**
|
||||
* Setup fixture for this test case.
|
||||
* Overrides the superlayer method because the data preparation requires a bit different preconditions.
|
||||
* The method uses a transient test site created in the {@link RestTest#checkServerHealth()} and on top of that:
|
||||
*
|
||||
* <ul>
|
||||
* <li>It adds a user which is added to the site as contributor</li>
|
||||
* <li>
|
||||
* It deploys a custom model which declares a set of prefixes composed by a combination of digits, hyphens
|
||||
* and underscores. Those prefixes are associated with four entities (song, artist, bassist, drummer and
|
||||
* sax) with their corresponding attributes.
|
||||
* </li>
|
||||
* <li>
|
||||
* It creates a folder with 5 files associated with the types declared in the model.
|
||||
* That allows those files to have a value for the properties/attributes included in the model definition.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @see RestTest#checkServerHealth()
|
||||
* @throws Exception hopefully never, otherwise the test fails.
|
||||
*/
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void localDataPreparation() throws Exception
|
||||
{
|
||||
songName = "The Dry Cleaner from Des Moines ";
|
||||
genre = "Jazz, vocal jazz ";
|
||||
coProducer = "Roberta Joan Mitchell ";
|
||||
|
||||
artistName = "Joni Mitchell " + UUID.randomUUID();
|
||||
voiceType = "Blue Mezzo (1965-1984) / Cloudy Contralto (1985-present) ";
|
||||
|
||||
bassistName = "Jaco Pastorius";
|
||||
drummerName = "Peter Erskine";
|
||||
saxophonistName = "Wayne Shorter";
|
||||
|
||||
dataContent.usingAdmin().deployContentModel("model/search-1063-model.xml");
|
||||
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteContributor);
|
||||
|
||||
testSite = siteModel;
|
||||
|
||||
FolderModel testFolder = dataContent.usingSite(testSite).usingUser(userModel).createFolder();
|
||||
|
||||
file = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
file2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
file3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
file4 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
file5 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
|
||||
dataContent.usingUser(userModel)
|
||||
.usingResource(testFolder)
|
||||
.createCustomContent(
|
||||
file,
|
||||
"D:1:song",
|
||||
new CustomObjectTypeProperties()
|
||||
.addProperty("1:name", songName)
|
||||
.addProperty("1:genre", genre)
|
||||
.addProperty("1:co-producer", coProducer));
|
||||
|
||||
dataContent.usingUser(userModel)
|
||||
.usingResource(testFolder)
|
||||
.createCustomContent(
|
||||
file2,
|
||||
"D:123:artist",
|
||||
new CustomObjectTypeProperties()
|
||||
.addProperty("123:name", artistName)
|
||||
.addProperty("123:voice_type", voiceType));
|
||||
|
||||
dataContent.usingUser(userModel)
|
||||
.usingResource(testFolder)
|
||||
.createCustomContent(
|
||||
file3,
|
||||
"D:1_2_3:bassist",
|
||||
new CustomObjectTypeProperties()
|
||||
.addProperty("1_2_3:name", bassistName));
|
||||
|
||||
dataContent.usingUser(userModel)
|
||||
.usingResource(testFolder)
|
||||
.createCustomContent(
|
||||
file4,
|
||||
"D:1-2-3:drummer",
|
||||
new CustomObjectTypeProperties()
|
||||
.addProperty("1-2-3:name", drummerName));
|
||||
|
||||
ContentModel content =
|
||||
dataContent.usingUser(userModel)
|
||||
.usingResource(testFolder)
|
||||
.createCustomContent(
|
||||
file5,
|
||||
"D:1-2_3:saxophonist",
|
||||
new CustomObjectTypeProperties()
|
||||
.addProperty("1-2_3:name", saxophonistName));
|
||||
|
||||
waitForIndexing(content.getName(), true);
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
|
||||
@Bug(id = "SEARCH-1063")
|
||||
public void prefixIsComposedByOneNumber() throws Exception
|
||||
{
|
||||
executeSqlAsSolr("select cm_name, `1_name`, `1_genre`, `1_co-producer` from alfresco where TYPE='1:song' and SITE='" + testSite.getId() + "'");
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file.getName()));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].1_name", Matchers.equalTo(songName));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].1_genre", Matchers.equalTo(genre));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].1_co-producer", Matchers.equalTo(coProducer));
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
|
||||
@Bug(id = "SEARCH-1063")
|
||||
public void prefixIsComposedByMultipleNumbers() throws Exception
|
||||
{
|
||||
executeSqlAsSolr("select cm_name, `123_name`, `123_voice_type` from alfresco where TYPE='123:artist' and SITE='" + testSite.getId() + "'");
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file2.getName()));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].123_name", Matchers.equalTo(artistName));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].123_voice_type", Matchers.equalTo(voiceType));
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
|
||||
@Bug(id = "SEARCH-1063")
|
||||
public void prefixIncludesUnderscore() throws Exception
|
||||
{
|
||||
executeSqlAsSolr("select cm_name, `1_2_3_name` from alfresco where TYPE='1_2_3:bassist' and SITE='" + testSite.getId() + "'");
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file3.getName()));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].1_2_3_name", Matchers.equalTo(bassistName));
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
|
||||
@Bug(id = "SEARCH-1063")
|
||||
public void prefixIncludesHyphen() throws Exception
|
||||
{
|
||||
executeSqlAsSolr("select cm_name, `1-2-3_name` from alfresco where TYPE='1-2-3:drummer' and SITE='" + testSite.getId() + "'");
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file4.getName()));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].1-2-3_name", Matchers.equalTo(drummerName));
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
|
||||
@Bug(id = "SEARCH-1063")
|
||||
public void prefixIncludesHyphenAndUnderscore() throws Exception
|
||||
{
|
||||
executeSqlAsSolr("select cm_name, `1-2_3_name` from alfresco where TYPE='1-2_3:saxophonist' and SITE='" + testSite.getId() + "'");
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file5.getName()));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].1-2_3_name", Matchers.equalTo(saxophonistName));
|
||||
}
|
||||
}
|
||||
-584
@@ -1,584 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Alfresco Software, Ltd. All rights reserved.
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
package org.alfresco.service.search.e2e.insightEngine.sql;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.search.e2e.AbstractSearchServiceE2E;
|
||||
import org.alfresco.utility.LogFactory;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Purpose of this TestClass is to test that the variants of <select *> query works as expected with CustomModels
|
||||
*
|
||||
* @author meenal bhave
|
||||
* @see <a href="https://issues.alfresco.com/jira/browse/SEARCH-873>SEARCH-873</a>
|
||||
*/
|
||||
public class SelectStarTest extends AbstractSearchServiceE2E
|
||||
{
|
||||
private static Logger LOG = LogFactory.getLogger();
|
||||
|
||||
@Autowired
|
||||
protected DataSite dataSite;
|
||||
|
||||
@Autowired
|
||||
protected DataContent dataContent;
|
||||
|
||||
private FolderModel testFolder;
|
||||
|
||||
/**
|
||||
* expFile1: id=10, empNo=000001, Location = London,
|
||||
* CostCentre=750, amount = 100, ExchangeRate=10, Approved= true,
|
||||
* Recorded_At, ExpenseDate=now,
|
||||
* Notes='London is a busy city'
|
||||
*/
|
||||
private FileModel expFile1;
|
||||
|
||||
/**
|
||||
* expFile2: id=30, empNo= 1, Location = Paris,
|
||||
* CostCentre=950, amount = 60.5, ExchangeRate=12, Approved=false,
|
||||
* Recorded_At, ExpenseDate=now-1month,
|
||||
* Notes='london is a busy city'
|
||||
*/
|
||||
private FileModel expFile2;
|
||||
|
||||
/**
|
||||
* expFile3: id=50, empNo= 56, Location = london,
|
||||
* CostCentre=750, amount = 60, ExchangeRate=12.5, Approved=true,
|
||||
* Recorded_At, ExpenseDate=now-1year,
|
||||
* Notes='Paris is a busy city'
|
||||
*/
|
||||
private FileModel expFile3;
|
||||
|
||||
/**
|
||||
* expFile4: id=null, empNo=null, Location = null,
|
||||
* CostCentre=null, amount = null, ExchangeRate=null, Approved=false,
|
||||
* Recorded_At, ExpenseDate=null, Notes=null
|
||||
*/
|
||||
private FileModel expFile4;
|
||||
|
||||
/**
|
||||
* expFile5: No custom property is set
|
||||
*/
|
||||
private FileModel expFile5;
|
||||
|
||||
/**
|
||||
* TIME_NOW: Date Time now based on system clock
|
||||
*/
|
||||
private static ZonedDateTime TIME_NOW = ZonedDateTime.now();
|
||||
|
||||
/**
|
||||
* DATE_NOW: Today's date in ISO Date format
|
||||
*/
|
||||
private static final String DATE_NOW = TIME_NOW.format(DateTimeFormatter.ISO_DATE).replace("Z", "");
|
||||
|
||||
/**
|
||||
* DT_NOW: Date Time now, in ISO Instant format
|
||||
*/
|
||||
private static final String DT_NOW = TIME_NOW.format(DateTimeFormatter.ISO_INSTANT);
|
||||
|
||||
/**
|
||||
* DT_NOW_MINUS_1_MONTH: ISO Date a month ago, in ISO Instant format
|
||||
*/
|
||||
private static final String DT_NOW_MINUS_1_MONTH = TIME_NOW.minusMonths(1).format(DateTimeFormatter.ISO_INSTANT);
|
||||
|
||||
/**
|
||||
* DT_NOW_MINUS_1_YEAR: ISO Date a year ago, in ISO Instant format
|
||||
*/
|
||||
private static final String DT_NOW_MINUS_1_YEAR = TIME_NOW.minusYears(1).format(DateTimeFormatter.ISO_INSTANT);
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
serverHealth.assertServerIsOnline();
|
||||
|
||||
super.springTestContextPrepareTestInstance();
|
||||
|
||||
try
|
||||
{
|
||||
deployCustomModel("model/expense-model.xml");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Error Loading Expense Model", e);
|
||||
}
|
||||
|
||||
testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
|
||||
// Create 5 files with the following data:
|
||||
expFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "expense1");
|
||||
expFile1.setName("exp1-"+ expFile1.getName());
|
||||
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:expense:expenseReport");
|
||||
properties.put(PropertyIds.NAME, expFile1.getName());
|
||||
properties.put("expense:id", 10);
|
||||
properties.put("expense:EmpNo", 000001);
|
||||
properties.put("expense:Location", "London");
|
||||
properties.put("expense:CostCentre__1", "750");
|
||||
properties.put("expense:Amount", 100);
|
||||
properties.put("expense:Currency", "GBP");
|
||||
properties.put("expense:ExchangeRate", 10);
|
||||
properties.put("expense:Approved", true);
|
||||
properties.put("expense:Notes", "London is a busy city");
|
||||
properties.put("expense:Recorded_At", Date.from(LocalDateTime.now().toInstant(ZoneOffset.UTC)));
|
||||
properties.put("expense:ExpenseDate", Date.from(LocalDateTime.now().toInstant(ZoneOffset.UTC)));
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
|
||||
.createFile(expFile1, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
|
||||
expFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "expense2");
|
||||
expFile2.setName("exp2-"+ expFile2.getName());
|
||||
|
||||
properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:expense:expenseReport");
|
||||
properties.put(PropertyIds.NAME, expFile2.getName());
|
||||
properties.put("expense:id", 30);
|
||||
properties.put("expense:EmpNo", 1);
|
||||
properties.put("expense:Location", "Paris");
|
||||
properties.put("expense:CostCentre__1", "950");
|
||||
properties.put("expense:Amount", 60.5);
|
||||
properties.put("expense:Currency", "GBP");
|
||||
properties.put("expense:ExchangeRate", 12);
|
||||
properties.put("expense:Approved", false);
|
||||
properties.put("expense:Notes", "london is a busy city");
|
||||
properties.put("expense:Recorded_At", Date.from(LocalDateTime.now().minusMonths(1).toInstant(ZoneOffset.UTC)));
|
||||
properties.put("expense:ExpenseDate", Date.from(LocalDateTime.now().minusMonths(1).toInstant(ZoneOffset.UTC)));
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
|
||||
.createFile(expFile2, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
|
||||
expFile3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "expense3");
|
||||
expFile3.setName("exp3-"+ expFile3.getName());
|
||||
|
||||
properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:expense:expenseReport");
|
||||
properties.put(PropertyIds.NAME, expFile3.getName());
|
||||
properties.put("expense:id", 50);
|
||||
properties.put("expense:EmpNo", 56);
|
||||
properties.put("expense:Location", "london");
|
||||
properties.put("expense:CostCentre__1", "750");
|
||||
properties.put("expense:Amount", 60);
|
||||
properties.put("expense:Currency", "GBP");
|
||||
properties.put("expense:ExchangeRate", 12.5);
|
||||
properties.put("expense:Approved", true);
|
||||
properties.put("expense:Notes", "Paris is a busy city");
|
||||
properties.put("expense:Recorded_At", Date.from(LocalDateTime.now().minusYears(1).toInstant(ZoneOffset.UTC)));
|
||||
properties.put("expense:ExpenseDate", Date.from(LocalDateTime.now().minusYears(1).toInstant(ZoneOffset.UTC)));
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
|
||||
.createFile(expFile3, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
|
||||
expFile4 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "expense4");
|
||||
expFile4.setName("exp4-"+ expFile4.getName());
|
||||
|
||||
properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:expense:expenseReport");
|
||||
properties.put(PropertyIds.NAME, expFile4.getName());
|
||||
properties.put("expense:id", null);
|
||||
properties.put("expense:EmpNo", null);
|
||||
properties.put("expense:Location", null);
|
||||
properties.put("expense:CostCentre__1", null);
|
||||
properties.put("expense:Amount", null);
|
||||
properties.put("expense:Currency", "GBP");
|
||||
properties.put("expense:ExchangeRate", null);
|
||||
properties.put("expense:Approved", false);
|
||||
properties.put("expense:Notes", null);
|
||||
properties.put("expense:Recorded_At", null);
|
||||
properties.put("expense:ExpenseDate", null);
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
|
||||
.createFile(expFile4, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
|
||||
expFile5 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "expense5");
|
||||
expFile5.setName("exp5-"+ expFile4.getName());
|
||||
|
||||
properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:expense:expenseReport");
|
||||
properties.put(PropertyIds.NAME, expFile5.getName());
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
|
||||
.createFile(expFile5, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
|
||||
// Wait for the file to be indexed
|
||||
waitForIndexing(expFile4.getName(), true);
|
||||
}
|
||||
|
||||
@Test(priority = 1, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testTextField()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:Location` = 'london'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Location` >= 'London'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Location` >= 'london'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Location` <= 'London'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Location` <='london'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Location` <> 'london' and TYPE = 'expense:expenseReport'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Location` = 'Reading'", 0);
|
||||
testSqlQuery("select * from alfresco where `expense:Location` != 'Reading' and TYPE = 'expense:expenseReport'", 5);
|
||||
testSqlQuery("select * from alfresco where `expense:Location` not in ('Paris', 'Reading') and TYPE = 'expense:expenseReport'", 4);
|
||||
testSqlQuery("select * from alfresco where `expense:Location` not in ('Paris', 'Reading') and `expense:Location` in ('london')", 2);
|
||||
|
||||
// Field name with _
|
||||
testSqlQuery("select * from alfresco where expense_Location = 'london'", 2);
|
||||
}
|
||||
|
||||
// TODO: Enable when fixed: Bug: Search-1457
|
||||
@Test(priority = 2, groups = { TestGroup.INSIGHT_11 }, enabled = false)
|
||||
public void testTextFieldNullValues()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:Location` = '*' and TYPE = 'expense:expenseReport'", 3); //4 or 3
|
||||
testSqlQuery("select * from alfresco where `expense:Location` != '*' and TYPE = 'expense:expenseReport'", 2); //0 or 1 or 2
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:Location` in ('Paris', 'Reading', null) and TYPE = 'expense:expenseReport'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Location` not in ('Paris', 'Reading', null) and TYPE = 'expense:expenseReport'", 2); //0 or 2
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:Location` is null and TYPE = 'expense:expenseReport'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Location` is not null and TYPE = 'expense:expenseReport'", 3);
|
||||
}
|
||||
|
||||
@Test(priority = 3, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testMLTextField()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` = 'London is a busy'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` = 'london'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` >= 'London'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` >= 'london'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` <= 'London' and TYPE = 'expense:expenseReport'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` <= 'london*' and TYPE = 'expense:expenseReport'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` in ('Paris', 'london')", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` not in ('London', 'london') and TYPE = 'expense:expenseReport'", 3);
|
||||
|
||||
testSqlQuery("select * from alfresco where expense_Notes = 'Paris'", 1);
|
||||
}
|
||||
|
||||
// TODO: Update on fix: Search-1457
|
||||
@Test(priority = 4, groups = { TestGroup.INSIGHT_11 }, enabled=false)
|
||||
public void testMLTextFieldNullValues()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` = '*' and TYPE = 'expense:expenseReport'", 3); //4
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` != '*' and TYPE = 'expense:expenseReport'", 2); //0 or 1
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` in ('london', null) and TYPE = 'expense:expenseReport'", 4);
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` not in ('london', null) and TYPE = 'expense:expenseReport'", 1); //0 or 1
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` is Null and TYPE = 'expense:expenseReport'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Notes` is not null and TYPE = 'expense:expenseReport'", 3);
|
||||
}
|
||||
|
||||
@Test(priority = 5, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testIntegerField()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:id` >= '10'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:id` > 10", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:id` <= 30", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:id` >= 5", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:id`< 12 and TYPE = 'expense:expenseReport'", 1);
|
||||
testSqlQuery("select * from alfresco where `expense:id` = 50", 1);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:id` in (10, 30, 0)", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:id` not in (5, 10) and TYPE = 'expense:expenseReport'", 4);
|
||||
|
||||
testSqlQuery("select * from alfresco where expense_id = 50 and TYPE = 'expense:expenseReport'", 1);
|
||||
}
|
||||
|
||||
// TODO: Update on fix: Search-1457
|
||||
@Test(priority = 6, groups = { TestGroup.INSIGHT_11 }, enabled = false)
|
||||
public void testIntegerFieldNullValues()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:id` = '*' and TYPE = 'expense:expenseReport'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:id` != '*' and TYPE = 'expense:expenseReport'", 2);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:id` in (5, 10, null) and TYPE = 'expense:expenseReport'", 3); //0 or 3
|
||||
testSqlQuery("select * from alfresco where `expense:id` not in (5, 10, null) and TYPE = 'expense:expenseReport'", 2);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:id` is null and TYPE = 'expense:expenseReport'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:id` is not null and TYPE = 'expense:expenseReport'", 3);
|
||||
}
|
||||
|
||||
@Test(priority = 7, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testLongField()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` >= '000001'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` >=000001", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` <= 56 and TYPE = 'expense:expenseReport'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` >= 50", 1);
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` = 1", 2);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` in (00001, 1, 50)", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` not in (1, 50) and TYPE = 'expense:expenseReport'", 3);
|
||||
|
||||
testSqlQuery("select * from alfresco where expense_EmpNo = 56", 1);
|
||||
}
|
||||
|
||||
// TODO: Update on fix: Search-1457
|
||||
@Test(priority = 8, groups = { TestGroup.INSIGHT_11 }, enabled=false)
|
||||
public void testLongFieldNullValues()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` = '*' and TYPE = 'expense:expenseReport'", 3); //4
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` != '*' and TYPE = 'expense:expenseReport'", 1); //0
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` in (1, 56, null) and TYPE = 'expense:expenseReport'", 4); //0 or 1
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` not in (1, 56, null) and TYPE = 'expense:expenseReport'", 2);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` is null and TYPE = 'expense:expenseReport'", 1); //0 or 1
|
||||
testSqlQuery("select * from alfresco where `expense:EmpNo` is not null and TYPE = 'expense:expenseReport'", 1); //0 or 1
|
||||
}
|
||||
|
||||
@Test(priority = 9, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testDoubleField()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` >= '12'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` >= 12.5", 1);
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` <= 12 and TYPE = 'expense:expenseReport'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` >= 12.5", 1);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` in (12, 10)", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` not in (12.5, 100) and TYPE = 'expense:expenseReport'", 4);
|
||||
|
||||
testSqlQuery("select * from alfresco where expense_ExchangeRate = 12.5", 1);
|
||||
}
|
||||
|
||||
|
||||
// TODO: Update on fix: Search-1457
|
||||
@Test(priority = 10, groups = { TestGroup.INSIGHT_11 }, enabled = false)
|
||||
public void testDoubleFieldNullValues()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` = '*' and TYPE = 'expense:expenseReport'", 3); //4
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` != '*' and TYPE = 'expense:expenseReport'", 2); //0
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` in (12.5, 100, null) and TYPE = 'expense:expenseReport'", 4);
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` not in (12.5, 100, null) and TYPE = 'expense:expenseReport'", 1);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` is null and TYPE = 'expense:expenseReport'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:ExchangeRate` is not null and TYPE = 'expense:expenseReport'", 3);
|
||||
}
|
||||
|
||||
@Test(priority = 11, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testFloatField()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:amount` >= '60.50'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:amount` >= 60", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:amount` <= 60 and TYPE = 'expense:expenseReport'", 1);
|
||||
testSqlQuery("select * from alfresco where `expense:amount` = 60", 1);
|
||||
testSqlQuery("select * from alfresco where `expense:amount` in (60, 100)", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:amount` not in (60.5, 100) and TYPE = 'expense:expenseReport'", 3);
|
||||
// unsupported?
|
||||
// testSqlQuery("select * from alfresco where `expense:amount` not in (60.5, 100, null) and TYPE = 'expense:expenseReport'", 1);
|
||||
|
||||
testSqlQuery("select * from alfresco where expense_amount = 60", 1);
|
||||
}
|
||||
|
||||
// TODO: Update on fix: Search-1457
|
||||
@Test(priority = 12, groups = { TestGroup.INSIGHT_11 }, enabled=false)
|
||||
public void testFloatFieldNullValues()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:amount` >= '60.50'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:amount` >= 60", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:amount` <= 60 and TYPE = 'expense:expenseReport'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:amount` = 60", 21);
|
||||
testSqlQuery("select * from alfresco where `expense:amount` in (60, 100)", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:amount` not in (60.5, 100) and TYPE = 'expense:expenseReport'", 2);
|
||||
|
||||
testSqlQuery("select * from alfresco where expense_amount = 60", 1);
|
||||
}
|
||||
|
||||
@Test(priority = 13, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testBooleanField()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:Approved` = 'true'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Approved` = 'false'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Approved` <= 'false'", 2); //3 Include the one that's not set
|
||||
testSqlQuery("select * from alfresco where `expense:Approved` >= 'true'", 2);
|
||||
|
||||
testSqlQuery("select * from alfresco where expense_Approved = 'true' and `expense:Location` = 'Paris'", 0);
|
||||
}
|
||||
|
||||
// TODO: Update on fix: Search-1457
|
||||
@Test(priority = 14, groups = { TestGroup.INSIGHT_11 }, enabled = false)
|
||||
public void testBooleanFieldNullValues()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:Approved` = '*' and TYPE = 'expense:expenseReport'", 3); //4
|
||||
testSqlQuery("select * from alfresco where `expense:Approved` != '*' and TYPE = 'expense:expenseReport'", 1); //0
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:Approved` in ('true', null)", 4);
|
||||
testSqlQuery("select * from alfresco where `expense:Approved` not in ('true', null)", 1);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:Approved` is null", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Approved` is not null", 3);
|
||||
}
|
||||
|
||||
@Test(priority = 15, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testDateField()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` <'" + DT_NOW + "'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` < '" + DT_NOW + "'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` < '" + DT_NOW_MINUS_1_MONTH + "'", 1);
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` <='NOW-1MONTH/DAY'", 1);
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` <='" + DT_NOW_MINUS_1_MONTH + "'", 1);
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` >='NOW/DAY'", 1);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` >'" + DT_NOW_MINUS_1_YEAR + "'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` >'NOW-1YEAR'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` >'NOW-1YEAR/DAY'", 3);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` >'" + DATE_NOW + "'", 0);
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` >'" + DT_NOW + "'", 1);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` > 'NOW/DAY'", 1);
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` < ('NOW/DAY') AND `expense:ExpenseDate` >= ('NOW-1YEAR/DAY')", 2);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` in ('" + DATE_NOW + "') and TYPE = 'expense:expenseReport'", 1);
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` not in ('" + DT_NOW_MINUS_1_YEAR + "') and TYPE = 'expense:expenseReport'", 5);
|
||||
|
||||
testSqlQuery("select * from alfresco where expense_ExpenseDate >= '1970-02-01T01:01:01Z' and TYPE = 'expense:expenseReport'", 3);
|
||||
}
|
||||
|
||||
// TODO: Update on fix: Search-1457
|
||||
@Test(priority = 16, groups = { TestGroup.INSIGHT_11 }, enabled = false)
|
||||
public void testDateFieldNullValues()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` = '*' and TYPE = 'expense:expenseReport'", 3); //4
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` != '*' and TYPE = 'expense:expenseReport'", 2); //0
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` in (null, zdate) and TYPE = 'expense:expenseReport'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` not in (null, zdate) and TYPE = 'expense:expenseReport'", 2);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` is null and TYPE = 'expense:expenseReport'", 2); //4
|
||||
testSqlQuery("select * from alfresco where `expense:ExpenseDate` is not null and TYPE = 'expense:expenseReport'", 3); //0
|
||||
}
|
||||
|
||||
@Test(priority = 17, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testDateTimeField()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` <'NOW-1MONTH' and TYPE = 'expense:expenseReport'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` < 'NOW/DAY' and TYPE = 'expense:expenseReport'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` <='" + DT_NOW + "' and TYPE = 'expense:expenseReport'", 2);
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` >='NOW-1YEAR/YEAR'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` >'2018-01-01'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` > 'NOW-1MONTHS'", 1);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` <'" + DT_NOW + "' and TYPE = 'expense:expenseReport'", 2);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` in ('" + DATE_NOW + "') and TYPE = 'expense:expenseReport'", 1);
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` in ('" + DT_NOW + "') and TYPE = 'expense:expenseReport'", 0);
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` not in ('" + DT_NOW_MINUS_1_YEAR + "') and TYPE = 'expense:expenseReport'", 5);
|
||||
|
||||
testSqlQuery("select * from alfresco where expense_Recorded_At >= '1970-02-01T01:01:01Z' and TYPE = 'expense:expenseReport'", 3);
|
||||
}
|
||||
|
||||
// TODO: Update on fix: Search-1457
|
||||
@Test(priority = 18, groups = { TestGroup.INSIGHT_11 }, enabled = false)
|
||||
public void testDateTimeFieldNullValues()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` = '*' and TYPE = 'expense:expenseReport'", 3); //4
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` != '*' and TYPE = 'expense:expenseReport'", 1); //0
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` in (null, zdt) and TYPE = 'expense:expenseReport'", 3);
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` not in (null, zdt) and TYPE = 'expense:expenseReport'", 2);
|
||||
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` is null and TYPE = 'expense:expenseReport'", 2); //4
|
||||
testSqlQuery("select * from alfresco where `expense:Recorded_At` is not null and TYPE = 'expense:expenseReport'", 3); //0
|
||||
}
|
||||
|
||||
// TODO: Search-1477: Enable, Uncomment Tests when bug is fixed
|
||||
@Test(priority = 19, groups = { TestGroup.INSIGHT_11 }, enabled = false)
|
||||
public void testVirtualTimeDimensions()
|
||||
{
|
||||
testSqlQuery("select * from alfresco where TYPE = 'expense:expenseReport' order by cm_created desc", 5);
|
||||
|
||||
// OOTB fields: 400: cm_created_day not found in any table
|
||||
testSqlQuery("select cm_created_day, count(*) as total from alfresco"
|
||||
+ " where cm_created >= 'NOW/DAY' AND `cm:name` >= 'exp'"
|
||||
+ " group by cm_created_day", 5);
|
||||
|
||||
testSqlQuery("Select Site, cm_name, cm_created_day from alfresco "
|
||||
+ " where `cm:name` >= 'exp'"
|
||||
+ " group by cm_created "
|
||||
+ " having sum(`expense:amount`) > 10"
|
||||
+ " order by `cm:created_day` desc", 5);
|
||||
|
||||
//Custom fields
|
||||
testSqlQuery("Select Site, cm_name, expense_Recorded_At_day from alfresco "
|
||||
+ " where type = 'cm:content' and `cm:name` >= 'exp' "
|
||||
+ " group by expense_Recorded_At_day"
|
||||
+ " having sum(`cm:content.size`) > 1000"
|
||||
+ " order by expense_Recorded_At_day desc", 5);
|
||||
}
|
||||
|
||||
@Test(priority = 20, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testFieldNameWithUnderscore()
|
||||
{
|
||||
// Field name with _: in where clause
|
||||
testSqlQuery("select * from alfresco where `expense:CostCentre__1` = '750' AND TYPE = 'expense:expenseReport' order by cm_created desc", 2);
|
||||
|
||||
// TODO: Search-1478: Uncomment when fixed
|
||||
// testSqlQuery("select * from alfresco where TYPE = 'expense:expenseReport' order by `expense:Recorded_At` desc", 5);
|
||||
|
||||
// TODO: Search-1478: Uncomment when Fixed
|
||||
// testSqlQuery("select * from alfresco where TYPE = 'expense:expenseReport' order by expense_Recorded_At desc", 5);
|
||||
|
||||
// TODO: Search-1478: Uncomment when Fixed
|
||||
// testSqlQuery("select expense_Recorded_At_year, sum(expense_amount) from alfresco"
|
||||
// + " where TYPE = 'expense:expenseReport' "
|
||||
// + " group by expense_Recorded_At_year"
|
||||
// + " order by expense_Recorded_At desc", 5);
|
||||
}
|
||||
|
||||
/** Try adding a double space at each location throughout a wildcard query. */
|
||||
@Test(priority = 21, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testWildcardQueryContainingExtraSpaces()
|
||||
{
|
||||
String baseQuery = "select * from alfresco where `expense:Location` = 'london'";
|
||||
int wordCount = baseQuery.split(" ").length;
|
||||
for (int i = 1; i < wordCount; i++)
|
||||
{
|
||||
// Replace the ith space with a double space.
|
||||
String query = baseQuery.replaceFirst("(([^ ]+ ){" + i + "})", "$1 ");
|
||||
// Check the query still executes correctly.
|
||||
testSqlQuery(query, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/** Check that using different whitespace characters doesn't break the query. */
|
||||
@Test(priority = 22, groups = { TestGroup.INSIGHT_11 })
|
||||
public void testWildcardQueryContainingDifferentWhitespace()
|
||||
{
|
||||
List<String> whitespacesSequences = asList("\n\r", "\n", "\r", "\t", "\f");
|
||||
|
||||
whitespacesSequences.forEach(whitespaces -> {
|
||||
StringBuilder chars = new StringBuilder();
|
||||
for (int howManyWhiteSpaceChars = 1; howManyWhiteSpaceChars < 3; howManyWhiteSpaceChars++)
|
||||
{
|
||||
chars.append(whitespaces);
|
||||
String query = "select * from alfresco where `expense:id` in (10, 30, 0)".replace(" ", chars);
|
||||
testSqlQuery(query, 2);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
-682
@@ -1,682 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Alfresco Software, Ltd. All rights reserved.
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
package org.alfresco.service.search.e2e.insightEngine.sql;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonObject;
|
||||
|
||||
import org.alfresco.dataprep.SiteService.Visibility;
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.search.SearchSqlRequest;
|
||||
import org.alfresco.service.search.e2e.AbstractSearchServiceE2E;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.report.log.Step;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Purpose of this TestClass is to test that the TimeSeries Aggregation works with/out Nulls and when values are not available
|
||||
*
|
||||
* @author meenal bhave
|
||||
*/
|
||||
|
||||
public class TimeSeriesAggrTest extends AbstractSearchServiceE2E
|
||||
{
|
||||
@Autowired
|
||||
protected DataSite dataSite;
|
||||
|
||||
@Autowired
|
||||
protected DataContent dataContent;
|
||||
|
||||
protected SiteModel testSite;
|
||||
|
||||
private UserModel testExpenseUser1, testExpenseAdmin;
|
||||
|
||||
private FolderModel testFolderUser1, testFolderAdmin;
|
||||
|
||||
private FileModel expense1, expense2, expense3, expense4;
|
||||
|
||||
private Long uniqueRef;
|
||||
|
||||
/**
|
||||
* sql query to retrieve aggregated results based on Virtual Time Dimension _day
|
||||
*/
|
||||
private static final String VIRTUAL_TIME_DIMENSION_DAY = ""
|
||||
+ "select "
|
||||
+ "finance_CreatedAt_day, "
|
||||
+ "count(*) as ExpensesCount, "
|
||||
+ "sum(finance_amount) as TotalExpenses, avg(finance_amount) as AvgExpenses, "
|
||||
+ "min(finance_amount) as MinExpenses, max(finance_amount) as MaxExpenses "
|
||||
+ "from alfresco "
|
||||
+ "group by finance_CreatedAt_day";
|
||||
|
||||
/**
|
||||
* sql query to retrieve aggregated results based on Virtual Time Dimension _month
|
||||
*/
|
||||
private static final String VIRTUAL_TIME_DIMENSION_MONTH = ""
|
||||
+ "select "
|
||||
+ "finance_CreatedAt_month, "
|
||||
+ "count(*) as ExpensesCount, "
|
||||
+ "sum(finance_amount) as TotalExpenses, avg(finance_amount) as AvgExpenses, "
|
||||
+ "min(finance_amount) as MinExpenses, max(finance_amount) as MaxExpenses "
|
||||
+ "from alfresco "
|
||||
+ "group by finance_CreatedAt_month";
|
||||
|
||||
/**
|
||||
* sql query to retrieve aggregated results based on Virtual Time Dimension _year
|
||||
* Includes order by desc: order by virtual time dimension _year
|
||||
*/
|
||||
private static final String VIRTUAL_TIME_DIMENSION_YEAR = ""
|
||||
+ "select "
|
||||
+ "finance_CreatedAt_year, "
|
||||
+ "count(*) as ExpensesCount, "
|
||||
+ "sum(finance_amount) as TotalExpenses, avg(finance_amount) as AvgExpenses, "
|
||||
+ "min(finance_amount) as MinExpenses, max(finance_amount) as MaxExpenses "
|
||||
+ "from alfresco "
|
||||
+ "group by finance_CreatedAt_Year "
|
||||
+ "order by finance_CreatedAt_YEAR desc";
|
||||
|
||||
/**
|
||||
* String that adds having clause based on min amount to the query
|
||||
*/
|
||||
private static final String HAVING_MIN_AMOUNT = " having min(finance_amount) > 0";
|
||||
|
||||
/**
|
||||
* String that adds having clause based on count to the query
|
||||
*/
|
||||
private static final String HAVING_COUNT = " having count(*) >= 1";
|
||||
|
||||
/**
|
||||
* String that adds order by desc clause to the query
|
||||
*/
|
||||
private static final String ORDER_BY_DESC = " order by finance_CreatedAt_month desc";
|
||||
|
||||
/** The current date. */
|
||||
private static final LocalDateTime nowDate = LocalDateTime.now();
|
||||
/** LocalDateTime that represents date 1 month ago */
|
||||
private static final LocalDateTime dateLastMonth = nowDate.minusMonths(1);
|
||||
/** The day after one month ago. */
|
||||
private static final LocalDateTime lastMonthPlusOneDay = dateLastMonth.plusDays(1);
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
serverHealth.assertServerIsOnline();
|
||||
|
||||
// Create test users
|
||||
testExpenseUser1 = dataUser.createRandomTestUser();
|
||||
testExpenseAdmin = dataUser.createRandomTestUser();
|
||||
|
||||
// Create private test site as testExpenseUser1 and add testExpenseAdmin
|
||||
testSite = new SiteModel(RandomData.getRandomName("SiteFinance1"));
|
||||
testSite.setVisibility(Visibility.PRIVATE);
|
||||
|
||||
testSite = dataSite.usingUser(testExpenseUser1).createSite(testSite);
|
||||
|
||||
dataUser.addUserToSite(testExpenseAdmin, testSite, UserRole.SiteContributor);
|
||||
|
||||
// Create test folders for users
|
||||
testFolderUser1 = dataContent.usingSite(testSite).usingUser(testExpenseUser1).createFolder();
|
||||
testFolderAdmin = dataContent.usingSite(testSite).usingUser(testExpenseAdmin).createFolder();
|
||||
|
||||
// Set Node Permissions for testFolder2, to deny access to testExpenseUser1
|
||||
JsonObject userPermission = Json
|
||||
.createObjectBuilder()
|
||||
.add("permissions",
|
||||
Json.createObjectBuilder()
|
||||
.add("isInheritanceEnabled", false)
|
||||
.add("locallySet",
|
||||
Json.createObjectBuilder()
|
||||
.add("authorityId", testExpenseUser1.getUsername())
|
||||
.add("name", "SiteManager")
|
||||
.add("accessStatus", "DENIED")
|
||||
)).build();
|
||||
|
||||
String putBody = userPermission.toString();
|
||||
|
||||
restClient.authenticateUser(testExpenseAdmin).withCoreAPI().usingNode(testFolderAdmin).updateNode(putBody);
|
||||
|
||||
uniqueRef = System.currentTimeMillis();
|
||||
|
||||
createTestData();
|
||||
}
|
||||
|
||||
private void createTestData() throws Exception
|
||||
{
|
||||
// testExpenseUser1 has 2 expenses, testExpenseAdmin has 2 expense, userAdmin can see all expenses
|
||||
|
||||
// Expense1 for testExpenseUser1 dated today: Amount 100
|
||||
expense1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
expense1.setName("ex-"+ expense1.getName());
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Expense");
|
||||
properties.put(PropertyIds.NAME, expense1.getName());
|
||||
properties.put("finance:No", uniqueRef);
|
||||
properties.put("finance:Emp", testExpenseUser1.getUsername());
|
||||
properties.put("finance:amount", 100);
|
||||
properties.put("finance:CreatedAt", Date.from(nowDate.toInstant(ZoneOffset.UTC)));
|
||||
properties.put("finance:Location", "Reading");
|
||||
|
||||
cmisApi.authenticateUser(testExpenseUser1).usingSite(testSite).usingResource(testFolderUser1)
|
||||
.createFile(expense1, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
|
||||
// Expense2 for testExpenseUser1 dated <today - 1 month>: Amount 50
|
||||
expense2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
expense2.setName("ex-"+ expense2.getName());
|
||||
properties = new HashMap<>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Expense");
|
||||
properties.put(PropertyIds.NAME, expense2.getName());
|
||||
properties.put("finance:No", uniqueRef+1);
|
||||
properties.put("finance:Emp", testExpenseUser1.getUsername());
|
||||
properties.put("finance:amount", 50);
|
||||
properties.put("finance:CreatedAt", Date.from(dateLastMonth.toInstant(ZoneOffset.UTC)));
|
||||
properties.put("finance:Location", "London");
|
||||
|
||||
cmisApi.authenticateUser(testExpenseUser1).usingSite(testSite).usingResource(testFolderUser1)
|
||||
.createFile(expense2, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
|
||||
// Expense1 for testExpenseAdmin dated <today - 1 month>: Amount 400
|
||||
expense3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
expense3.setName("ex-"+ expense3.getName());
|
||||
properties = new HashMap<>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Expense");
|
||||
properties.put(PropertyIds.NAME, expense3.getName());
|
||||
properties.put("finance:No", uniqueRef+3);
|
||||
properties.put("finance:Emp", testExpenseAdmin.getUsername());
|
||||
properties.put("finance:amount", 400);
|
||||
properties.put("finance:CreatedAt", Date.from(dateLastMonth.toInstant(ZoneOffset.UTC)));
|
||||
properties.put("finance:Location", "London");
|
||||
|
||||
cmisApi.authenticateUser(testExpenseAdmin).usingSite(testSite).usingResource(testFolderAdmin)
|
||||
.createFile(expense3, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
|
||||
// Expense2 for testExpenseAdmin dated <today - 1 month>: Amount Not specified / Null
|
||||
expense4 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
expense4.setName("ex-"+ expense4.getName());
|
||||
properties = new HashMap<>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Expense");
|
||||
properties.put(PropertyIds.NAME, expense4.getName());
|
||||
properties.put("finance:No", uniqueRef+4);
|
||||
properties.put("finance:Emp", testExpenseAdmin.getUsername());
|
||||
properties.put("finance:CreatedAt", Date.from(lastMonthPlusOneDay.toInstant(ZoneOffset.UTC)));
|
||||
properties.put("finance:Location", "Maidenhead");
|
||||
|
||||
cmisApi.authenticateUser(testExpenseAdmin).usingSite(testSite).usingResource(testFolderAdmin)
|
||||
.createFile(expense4, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
|
||||
// Wait for the content to be indexed
|
||||
waitForIndexing(expense4.getName(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that Virtual time series aggregation works for _day
|
||||
* Format appears as yyyy
|
||||
* Data shows results for [Current full day - 1 month] as default
|
||||
* Values are correctly aggregated for _year dimension
|
||||
* Order is correct
|
||||
*/
|
||||
@Test(priority = 1, groups = { TestGroup.INSIGHT_10 })
|
||||
public void testBasicTimeSeriesAggrDay() throws Exception
|
||||
{
|
||||
// Select Data for TimeSeriesAggr: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(VIRTUAL_TIME_DIMENSION_DAY);
|
||||
sqlRequest.setFormat("json");
|
||||
|
||||
RestResponse response =
|
||||
restClient.authenticateUser(testExpenseUser1).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
// Check that response includes the details for expense dated <today - 1 month>
|
||||
int noOfDays = nowDate.getDayOfYear() - dateLastMonth.getDayOfYear();
|
||||
response.assertThat().body("list.pagination.count", Matchers.equalTo(noOfDays + 1));
|
||||
|
||||
// Execute in solr format
|
||||
sqlRequest.setFormat("solr");
|
||||
|
||||
response = restClient.authenticateUser(testExpenseUser1).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
response.assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
|
||||
// Check the results are in ascending order of date, starting with <today - 1 month>
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].finance_CreatedAt_day", Matchers
|
||||
.equalTo(dateLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
|
||||
// last date available in the results set is today
|
||||
restClient.onResponse().assertThat().body("result-set.docs[" + noOfDays + "].finance_CreatedAt_day", Matchers
|
||||
.equalTo(nowDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that Virtual time series aggregation works for _day
|
||||
* Format appears as yyyy
|
||||
* Data shows results for [Current full day - 1 month] as default
|
||||
* Values are correctly aggregated for _year dimension
|
||||
* Order is correct
|
||||
*/
|
||||
@Test(priority = 2, groups = { TestGroup.INSIGHT_10 })
|
||||
public void testBasicTimeSeriesAggrDayWithHavingClause() throws Exception
|
||||
{
|
||||
// Select Data for TimeSeriesAggr: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(VIRTUAL_TIME_DIMENSION_DAY + HAVING_MIN_AMOUNT);
|
||||
sqlRequest.setFormat("json");
|
||||
|
||||
RestResponse response =
|
||||
restClient.authenticateUser(testExpenseUser1).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
// Check Count
|
||||
response.assertThat().body("list.pagination.count", Matchers.equalTo(2));
|
||||
|
||||
// Execute in solr format
|
||||
sqlRequest.setFormat("solr");
|
||||
|
||||
response = restClient.authenticateUser(testExpenseUser1).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].finance_CreatedAt_day", Matchers
|
||||
.equalTo(dateLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].ExpensesCount", Matchers.equalTo(1));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MinExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MaxExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].TotalExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].AvgExpenses", Matchers.equalTo(50));
|
||||
|
||||
// Check that response includes the details for expense dated <today>
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].finance_CreatedAt_day", Matchers
|
||||
.equalTo(nowDate.minusMonths(0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].ExpensesCount", Matchers.equalTo(1));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MinExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MaxExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].TotalExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].AvgExpenses", Matchers.equalTo(100));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that Virtual time series aggregation works for _month
|
||||
* Format appears as yyyy-mm
|
||||
* Data shows results for [Current month - 24 months] as default
|
||||
* Values are correctly aggregated for _month dimension
|
||||
* Order is correct
|
||||
*/
|
||||
@Test(priority = 3, groups = { TestGroup.INSIGHT_10 })
|
||||
public void testBasicTimeSeriesAggrMonth() throws Exception
|
||||
{
|
||||
// Select Data for TimeSeriesAggr: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(VIRTUAL_TIME_DIMENSION_MONTH + ORDER_BY_DESC);
|
||||
sqlRequest.setFormat("json");
|
||||
|
||||
RestResponse response =
|
||||
restClient.authenticateUser(testExpenseUser1).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
// Check Count for Month Aggregation is 25: Current month minus 24 months
|
||||
response.assertThat().body("list.pagination.count", Matchers.equalTo(25));
|
||||
|
||||
// Execute in solr format
|
||||
sqlRequest.setFormat("solr");
|
||||
|
||||
response = restClient.authenticateUser(testExpenseUser1).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
|
||||
// Check that response includes the details for expense dated <today>: Order By desc
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].finance_CreatedAt_month", Matchers
|
||||
.equalTo(nowDate.minusMonths(0).format(DateTimeFormatter.ofPattern("yyyy-MM"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].ExpensesCount", Matchers.equalTo(1));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MinExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MaxExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].TotalExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].AvgExpenses", Matchers.equalTo(100));
|
||||
|
||||
// Check that response includes the details for expense dated <today - 1 month>
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].finance_CreatedAt_month", Matchers
|
||||
.equalTo(dateLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].ExpensesCount", Matchers.equalTo(1));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MinExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MaxExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].TotalExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].AvgExpenses", Matchers.equalTo(50));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that Virtual time series aggregation works for _year
|
||||
* Format appears as yyyy
|
||||
* Data shows results for [Current year - 5 years] as default
|
||||
* Values are correctly aggregated for _year dimension
|
||||
* Order is correct
|
||||
*/
|
||||
@Test(priority = 4, groups = { TestGroup.INSIGHT_10 })
|
||||
public void testBasicTimeSeriesAggrYear() throws Exception
|
||||
{
|
||||
// Select Data for TimeSeriesAggr: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(VIRTUAL_TIME_DIMENSION_YEAR);
|
||||
sqlRequest.setFormat("json");
|
||||
|
||||
RestResponse response =
|
||||
restClient.authenticateUser(testExpenseUser1).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
// Check Count for Year Aggregation is 25: Current year minus 5 years
|
||||
response.assertThat().body("list.pagination.count", Matchers.equalTo(6));
|
||||
|
||||
// Execute in solr format
|
||||
sqlRequest.setFormat("solr");
|
||||
|
||||
response = restClient.authenticateUser(testExpenseUser1).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
|
||||
// Check that response includes the details for expense dated <today>: Order By desc
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].finance_CreatedAt_year", Matchers
|
||||
.equalTo(nowDate.format(DateTimeFormatter.ofPattern("yyyy"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].ExpensesCount", Matchers.equalTo(2));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MinExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MaxExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].TotalExpenses", Matchers.equalTo(150));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].AvgExpenses", Matchers.equalTo(75));
|
||||
|
||||
// Check that response includes the details for expense dated <today - 1 year>
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].finance_CreatedAt_year", Matchers
|
||||
.equalTo(nowDate.minusYears(1).format(DateTimeFormatter.ofPattern("yyyy"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].ExpensesCount", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MinExpenses", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MaxExpenses", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].TotalExpenses", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].AvgExpenses", Matchers.equalTo(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that Aggregation Values appear as 0 when not available for a time dimension
|
||||
*/
|
||||
@Test(priority = 5, groups = { TestGroup.INSIGHT_10 })
|
||||
public void testNoValuesAggregateAsZero() throws Exception
|
||||
{
|
||||
// Select Data for TimeSeriesAggr: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(VIRTUAL_TIME_DIMENSION_DAY);
|
||||
sqlRequest.setFormat("json");
|
||||
|
||||
RestResponse response =
|
||||
restClient.authenticateUser(testExpenseUser1).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
// Check Count
|
||||
response.assertThat().body("list.pagination.count", Matchers.greaterThanOrEqualTo(28));
|
||||
|
||||
// Execute in solr format
|
||||
sqlRequest.setFormat("solr");
|
||||
|
||||
response = restClient.authenticateUser(testExpenseUser1).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
|
||||
// Check that response includes the details for expense dated <today - 1 month>
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].finance_CreatedAt_day", Matchers
|
||||
.equalTo(dateLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].ExpensesCount", Matchers.equalTo(1));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MinExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MaxExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].TotalExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].AvgExpenses", Matchers.equalTo(50));
|
||||
|
||||
// Check that response includes expense dated <today - 1 month + 1 day>: Aggregations = 0, when ! specified
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].finance_CreatedAt_day", Matchers
|
||||
.equalTo(dateLastMonth.plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].ExpensesCount", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MinExpenses", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MaxExpenses", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].TotalExpenses", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].AvgExpenses", Matchers.equalTo(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that Aggregation Values appear as 0 when null for any time dimension
|
||||
*/
|
||||
@Test(priority = 6, groups = { TestGroup.INSIGHT_10 })
|
||||
public void testNullValuesAggregateAsZero() throws Exception
|
||||
{
|
||||
// Select Data for TimeSeriesAggr: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(VIRTUAL_TIME_DIMENSION_DAY);
|
||||
sqlRequest.setFormat("json");
|
||||
|
||||
RestResponse response =
|
||||
restClient.authenticateUser(testExpenseAdmin).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
// Check Count
|
||||
response.assertThat().body("list.pagination.count", Matchers.greaterThanOrEqualTo(29));
|
||||
|
||||
// Execute in solr format
|
||||
sqlRequest.setFormat("solr");
|
||||
|
||||
response = restClient.authenticateUser(testExpenseUser1).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
|
||||
// Check that response includes the details for expense dated <today - 1 month>
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].finance_CreatedAt_day", Matchers
|
||||
.equalTo(dateLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].ExpensesCount", Matchers.equalTo(1));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MinExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MaxExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].TotalExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].AvgExpenses", Matchers.equalTo(50));
|
||||
|
||||
// Check that response includes expense dated <today - 1 month + 1 day>: Aggregations = 0, when ! specified
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].finance_CreatedAt_day", Matchers
|
||||
.equalTo(dateLastMonth.plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].ExpensesCount", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MinExpenses", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MaxExpenses", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].TotalExpenses", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].AvgExpenses", Matchers.equalTo(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that aggregation produces correct results in-spite of changing null to zeroes
|
||||
*/
|
||||
@Test(priority = 7, groups = { TestGroup.INSIGHT_10 })
|
||||
public void testAggregationsInclNulls() throws Exception
|
||||
{
|
||||
// This test only works when the four documents are split 3 last month/1 this month.
|
||||
if (lastMonthPlusOneDay.getMonth().equals(nowDate.getMonth()))
|
||||
{
|
||||
Step.STEP("Skipping testAggregationsInclNulls as it fails near the end of months.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Select Data for TimeSeriesAggr: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(VIRTUAL_TIME_DIMENSION_MONTH + HAVING_COUNT);
|
||||
sqlRequest.setFormat("solr");
|
||||
|
||||
// User2 can see aggr results for All 4 Content
|
||||
RestResponse response =
|
||||
restClient.authenticateUser(testExpenseAdmin).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].finance_CreatedAt_month", Matchers
|
||||
.equalTo(dateLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].ExpensesCount", Matchers.equalTo(3));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MinExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MaxExpenses", Matchers.equalTo(400));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].TotalExpenses", Matchers.equalTo(450));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].AvgExpenses", Matchers.equalTo(225));
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].finance_CreatedAt_month", Matchers
|
||||
.equalTo(nowDate.format(DateTimeFormatter.ofPattern("yyyy-MM"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].ExpensesCount", Matchers.equalTo(1));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MinExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].MaxExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].TotalExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].AvgExpenses", Matchers.equalTo(100));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that aggregation produces correct results for admin, aggregating data from different users
|
||||
* Aggregated Values appear as 0 when actual values include a mix of null and non null values
|
||||
* Results don't show 0 entries: when having clause filters them out
|
||||
*/
|
||||
@Bug(id = "Search-927", status=Bug.Status.OPENED)
|
||||
@Test(priority = 8, groups = { TestGroup.INSIGHT_10 })
|
||||
public void testAggregationsForOtherUser() throws Exception
|
||||
{
|
||||
String timeSeriesSqlDayAdmin = ""
|
||||
+ "select "
|
||||
+ "finance_CreatedAt_day, "
|
||||
+ "count(*) as ExpensesCount, "
|
||||
+ "sum(finance_amount) as TotalExpenses, avg(finance_amount) as AvgExpenses, "
|
||||
+ "min(finance_amount) as MinExpenses, max(finance_amount) as MaxExpenses "
|
||||
+ "from alfresco "
|
||||
+ "where SITE = '" + testSite.getId() + "'"
|
||||
+ "group by finance_CreatedAt_day";
|
||||
|
||||
// Select Data for TimeSeriesAggr: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(timeSeriesSqlDayAdmin + HAVING_COUNT);
|
||||
sqlRequest.setFormat("solr");
|
||||
|
||||
// admin can see aggregation results for All 4 Content added to the Site
|
||||
RestResponse response =
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].finance_CreatedAt_day", Matchers
|
||||
.equalTo(dateLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].ExpensesCount", Matchers.equalTo(2));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MinExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MaxExpenses", Matchers.equalTo(400));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].TotalExpenses", Matchers.equalTo(450));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].AvgExpenses", Matchers.equalTo(225));
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].finance_CreatedAt_day", Matchers
|
||||
.equalTo(lastMonthPlusOneDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].ExpensesCount", Matchers.equalTo(1));
|
||||
|
||||
// TODO: Search-927: NaN: Uncomment the following steps when Search-927 is resolved
|
||||
// restClient.onResponse().assertThat().body("result-set.docs[1].MinExpenses", Matchers.equalTo(0));
|
||||
// restClient.onResponse().assertThat().body("result-set.docs[1].MaxExpenses", Matchers.equalTo(0));
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].TotalExpenses", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].AvgExpenses", Matchers.equalTo(0));
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].finance_CreatedAt_day", Matchers
|
||||
.equalTo(nowDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].ExpensesCount", Matchers.equalTo(1));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].MinExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].MaxExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].TotalExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].AvgExpenses", Matchers.equalTo(100));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that aggregation produces correct results for admin, aggregating data from different users
|
||||
* Aggregated Values appear as 0 when actual values include a mix of null and non nul values
|
||||
* Results show 0 entries: when having clause does not filter them out
|
||||
* Order by desc shows the same results as above query in a desc order
|
||||
*/
|
||||
@Bug(id = "Search-927", status=Bug.Status.OPENED)
|
||||
@Test(priority = 9, groups = { TestGroup.INSIGHT_10 })
|
||||
public void testAggregationsForOtherUserOrderByDesc() throws Exception
|
||||
{
|
||||
String timeSeriesSqlDayAdmin = ""
|
||||
+ "select "
|
||||
+ "finance_CreatedAt_day, "
|
||||
+ "count(*) as ExpensesCount, "
|
||||
+ "sum(finance_amount) as TotalExpenses, avg(finance_amount) as AvgExpenses, "
|
||||
+ "min(finance_amount) as MinExpenses, max(finance_amount) as MaxExpenses "
|
||||
+ "from alfresco "
|
||||
+ "where SITE = '" + testSite.getId() + "'"
|
||||
+ "group by finance_CreatedAt_day "
|
||||
+ "having count(*) >= 1 "
|
||||
+ "order by finance_CreatedAt_day desc";
|
||||
|
||||
// Select Data for TimeSeriesAggr: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(timeSeriesSqlDayAdmin);
|
||||
sqlRequest.setFormat("solr");
|
||||
|
||||
// admin can see aggregation results for All 4 Content added to the Site
|
||||
RestResponse response =
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
response.assertThat().body("result-set.docs", Matchers.notNullValue());
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].finance_CreatedAt_day", Matchers
|
||||
.equalTo(nowDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].ExpensesCount", Matchers.equalTo(1));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MinExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].MaxExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].TotalExpenses", Matchers.equalTo(100));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[0].AvgExpenses", Matchers.equalTo(100));
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].finance_CreatedAt_day", Matchers
|
||||
.equalTo(lastMonthPlusOneDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].ExpensesCount", Matchers.equalTo(1));
|
||||
|
||||
// TODO: Search-927: NaN: Uncomment the following steps when Search-927 is resolved
|
||||
// restClient.onResponse().assertThat().body("result-set.docs[1].MinExpenses", Matchers.equalTo(0));
|
||||
// restClient.onResponse().assertThat().body("result-set.docs[1].MaxExpenses", Matchers.equalTo(0));
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].TotalExpenses", Matchers.equalTo(0));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[1].AvgExpenses", Matchers.equalTo(0));
|
||||
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].finance_CreatedAt_day", Matchers
|
||||
.equalTo(dateLastMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].ExpensesCount", Matchers.equalTo(2));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].MinExpenses", Matchers.equalTo(50));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].MaxExpenses", Matchers.equalTo(400));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].TotalExpenses", Matchers.equalTo(450));
|
||||
restClient.onResponse().assertThat().body("result-set.docs[2].AvgExpenses", Matchers.equalTo(225));
|
||||
}
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Alfresco Software, Ltd. All rights reserved.
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
package org.alfresco.service.search.unit;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.dataprep.SiteService.Visibility;
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.search.SearchSqlJDBCRequest;
|
||||
import org.alfresco.rest.search.SearchSqlRequest;
|
||||
import org.alfresco.service.search.e2e.AbstractSearchServiceE2E;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
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.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Purpose of this Test is to test that the dependencies have been wired correctly and work well
|
||||
*
|
||||
* @author meenal bhave
|
||||
*/
|
||||
public class SetupTest extends AbstractSearchServiceE2E
|
||||
{
|
||||
@Autowired
|
||||
protected DataSite dataSite;
|
||||
|
||||
@Autowired
|
||||
protected DataContent dataContent;
|
||||
|
||||
protected SiteModel testSite;
|
||||
|
||||
protected FolderModel targetFolder;
|
||||
|
||||
private UserModel testUser;
|
||||
|
||||
private FolderModel testFolder;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
serverHealth.assertServerIsOnline();
|
||||
|
||||
testSite = dataSite.createPublicRandomSite();
|
||||
targetFolder = dataContent.usingSite(testSite).createFolder(FolderModel.getRandomFolderModel());
|
||||
|
||||
// Create test user and add the user as a SiteContributor
|
||||
testUser = dataUser.createRandomTestUser();
|
||||
|
||||
dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor);
|
||||
|
||||
testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
}
|
||||
|
||||
// Test CMIS API works
|
||||
@Test(priority = 1, groups = { TestGroup.SANITY })
|
||||
public void testCMISFileCreation() throws Exception
|
||||
{
|
||||
// Create document in a folder in a collaboration site
|
||||
FileModel testFile = new FileModel("TestFile");
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(testFile).assertThat().existsInRepo();
|
||||
}
|
||||
|
||||
// Test Custom Model: Music can be used
|
||||
@Test(priority = 2, groups = { TestGroup.SANITY })
|
||||
public void testModelMusicCanBeUsed() throws Exception
|
||||
{
|
||||
// Create document of custom type
|
||||
FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "searchContent-music");
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:music:song");
|
||||
properties.put(PropertyIds.NAME, customFile.getName());
|
||||
properties.put("music:genre", "pop");
|
||||
properties.put("music:lyricist", "Me");
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite)
|
||||
.usingResource(testFolder)
|
||||
.createFile(customFile, properties, VersioningState.MAJOR)
|
||||
.assertThat().existsInRepo();
|
||||
}
|
||||
|
||||
// Test Custom Model: Finance can be used
|
||||
@Test(priority = 3, groups = { TestGroup.SANITY })
|
||||
public void testModelFinanceCanBeUsed() throws Exception
|
||||
{
|
||||
// Create document of custom type
|
||||
|
||||
FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "searchContent-finance");
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Receipt");
|
||||
properties.put(PropertyIds.NAME, customFile.getName());
|
||||
properties.put("finance:ReceiptNo", 1);
|
||||
properties.put("finance:ReceiptValue", 30);
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite)
|
||||
.usingResource(testFolder)
|
||||
.createFile(customFile, properties, VersioningState.MAJOR)
|
||||
.assertThat().existsInRepo();
|
||||
|
||||
Assert.assertTrue(waitForIndexing("cm:name:" + customFile.getName(),true),"New content could not be found");
|
||||
}
|
||||
|
||||
// Test sql API can be used
|
||||
@Test(priority = 4, groups = { TestGroup.SANITY, TestGroup.INSIGHT_10 })
|
||||
public void testSQLAPICanBeUsed() throws Exception
|
||||
{
|
||||
FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "searchContent-finance2");
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Receipt");
|
||||
properties.put(PropertyIds.NAME, customFile.getName());
|
||||
properties.put("finance:ReceiptNo", 2);
|
||||
properties.put("finance:ReceiptValue", 50);
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite)
|
||||
.usingResource(testFolder)
|
||||
.createFile(customFile, properties, VersioningState.MAJOR)
|
||||
.assertThat().existsInRepo();
|
||||
|
||||
// Select distinct site: json format
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql("select cm_name from alfresco where TYPE = 'financeReceipt'");
|
||||
sqlRequest.setLimit(10);
|
||||
|
||||
RestResponse response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertTrue(HttpStatus.OK.toString().matches(response.getStatusCode()), "Check ACS Version is 6.0 or above and if Insight Engine is running. Response received is: " + response.getStatusCode());
|
||||
}
|
||||
|
||||
// Test sql can be executed via jdbc
|
||||
@Test(priority = 5, groups = { TestGroup.SANITY, TestGroup.INSIGHT_10 })
|
||||
public void testSQLViaJDBC() throws Exception
|
||||
{
|
||||
SiteModel publicSite = new SiteModel(RandomData.getRandomName("SiteSearch"));
|
||||
publicSite.setVisibility(Visibility.PUBLIC);
|
||||
|
||||
publicSite = dataSite.usingUser(testUser).createSite(publicSite);
|
||||
|
||||
String sql = "select SITE,CM_OWNER from alfresco where SITE ='" + publicSite.getTitle() + "' group by SITE,CM_OWNER";
|
||||
SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setAuthUser(testUser);
|
||||
|
||||
ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest);
|
||||
|
||||
if (rs != null)
|
||||
{
|
||||
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(testUser.getUsername()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.fail("Result Set is null, Check ACS Version is 6.0 or above and if Insight Engine is running");
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
-65
@@ -1,11 +1,10 @@
|
||||
package org.alfresco.service.search.e2e;
|
||||
|
||||
/*
|
||||
* Copyright 2019 Alfresco Software, Ltd. All rights reserved.
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
package org.alfresco.test.search.functional;
|
||||
|
||||
import org.alfresco.cmis.CmisWrapper;
|
||||
import org.alfresco.dataprep.ContentService;
|
||||
@@ -13,6 +12,7 @@ import org.alfresco.dataprep.SiteService.Visibility;
|
||||
import org.alfresco.rest.core.RestProperties;
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.search.RestRequestHighlightModel;
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
import org.alfresco.rest.search.SearchNodeModel;
|
||||
import org.alfresco.rest.search.SearchRequest;
|
||||
@@ -21,6 +21,7 @@ import org.alfresco.rest.search.SearchSqlRequest;
|
||||
import org.alfresco.utility.LogFactory;
|
||||
import org.alfresco.utility.TasProperties;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
@@ -42,7 +43,6 @@ import org.testng.annotations.BeforeSuite;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import static java.util.Optional.ofNullable;
|
||||
import static lombok.AccessLevel.PROTECTED;
|
||||
|
||||
import java.util.List;
|
||||
@@ -50,9 +50,8 @@ import java.util.List;
|
||||
/**
|
||||
* @author meenal bhave
|
||||
*/
|
||||
|
||||
@ContextConfiguration("classpath:alfresco-search-e2e-context.xml")
|
||||
public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringContextTests
|
||||
public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringContextTests
|
||||
{
|
||||
private static Logger LOG = LogFactory.getLogger();
|
||||
|
||||
@@ -87,7 +86,6 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte
|
||||
|
||||
protected UserModel testUser, adminUserModel;
|
||||
protected SiteModel testSite;
|
||||
protected UserModel searchedUser;
|
||||
|
||||
protected static String unique_searchString;
|
||||
|
||||
@@ -98,15 +96,8 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte
|
||||
{
|
||||
super.springTestContextPrepareTestInstance();
|
||||
|
||||
try
|
||||
{
|
||||
deployCustomModel("model/music-model.xml");
|
||||
deployCustomModel("model/finance-model.xml");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Error Loading Custom Model", e);
|
||||
}
|
||||
deployCustomModel("model/music-model.xml");
|
||||
deployCustomModel("model/finance-model.xml");
|
||||
}
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
@@ -123,6 +114,8 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte
|
||||
testSite = dataSite.usingUser(testUser).createSite(testSite);
|
||||
|
||||
unique_searchString = testSite.getTitle().replace("SiteSearch", "Unique");
|
||||
|
||||
dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
public boolean deployCustomModel(String path)
|
||||
@@ -233,24 +226,15 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte
|
||||
return customModel;
|
||||
}
|
||||
|
||||
protected SearchRequest createQuery(String term)
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
queryReq.setQuery(term);
|
||||
query.setQuery(queryReq);
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Helper method which create an http post request to Search API end point.
|
||||
* Executes the given search request without throwing checked exceptions (a {@link RuntimeException} will be thrown in case).
|
||||
*
|
||||
* @param query the search request.
|
||||
* @return {@link SearchResponse} response.
|
||||
*
|
||||
* @return the query execution response.
|
||||
*/
|
||||
protected SearchResponse query(SearchRequest query) throws Exception
|
||||
protected SearchResponse query(SearchRequest query)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -262,33 +246,6 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a SQL query and optionally asserts the response cardinality.
|
||||
*
|
||||
* @param sql the SQL query.
|
||||
* @param expectedCardinality if present an additional check is done in order to assert the expected response cardinality.
|
||||
* @return the {@link RestResponse} instance as result of the query execution.
|
||||
*/
|
||||
protected RestResponse testSqlQuery(String sql, Integer expectedCardinality)
|
||||
{
|
||||
try {
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
|
||||
RestResponse response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
if (ofNullable(expectedCardinality).isPresent()) {
|
||||
restClient.onResponse().assertThat().body("list.pagination.count", Matchers.equalTo(expectedCardinality));
|
||||
}
|
||||
|
||||
return response;
|
||||
} catch (Exception exception) {
|
||||
throw new AssertionError(exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for Solr to finish indexing and search to return appropriate results
|
||||
*
|
||||
@@ -431,9 +388,8 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte
|
||||
*
|
||||
* @param queryString: string to search for, unique search string will guarantee accurate results
|
||||
* @return the search response from the API
|
||||
* @throws Exception
|
||||
*/
|
||||
public SearchResponse query(String queryString) throws Exception
|
||||
public SearchResponse query(String queryString)
|
||||
{
|
||||
return queryAsUser(dataUser.getAdminUser(), queryString);
|
||||
}
|
||||
@@ -444,15 +400,19 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte
|
||||
* @param user: UserModel for the user you wish to run the query as
|
||||
* @param queryString: string to search for, unique search string will guarantee accurate results
|
||||
* @return the search response from the API
|
||||
* @throws Exception
|
||||
*/
|
||||
public SearchResponse queryAsUser(UserModel user, String queryString) throws Exception
|
||||
protected SearchResponse queryAsUser(UserModel user, String queryString)
|
||||
{
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
RestRequestQueryModel queryModel = new RestRequestQueryModel();
|
||||
queryModel.setQuery(queryString);
|
||||
searchRequest.setQuery(queryModel);
|
||||
return restClient.authenticateUser(user).withSearchAPI().search(searchRequest);
|
||||
try {
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
RestRequestQueryModel queryModel = new RestRequestQueryModel();
|
||||
queryModel.setQuery(queryString);
|
||||
searchRequest.setQuery(queryModel);
|
||||
return restClient.authenticateUser(user).withSearchAPI().search(searchRequest);
|
||||
} catch (final Exception exception)
|
||||
{
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,13 +421,35 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte
|
||||
* @param user: UserModel for the user you wish to run the query as
|
||||
* @param queryModel: The queryModel to search for, containing the query
|
||||
* @return the search response from the API
|
||||
* @throws Exception
|
||||
*/
|
||||
public SearchResponse queryAsUser(UserModel user, RestRequestQueryModel queryModel) throws Exception
|
||||
protected SearchResponse queryAsUser(UserModel user, RestRequestQueryModel queryModel) throws Exception
|
||||
{
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
searchRequest.setQuery(queryModel);
|
||||
|
||||
return restClient.authenticateUser(user).withSearchAPI().search(searchRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method which create an http post request to Search API end point.
|
||||
*
|
||||
* @return {@link SearchResponse} response.
|
||||
* @throws Exception if error
|
||||
*
|
||||
*/
|
||||
protected SearchResponse query(RestRequestQueryModel queryReq, RestRequestHighlightModel highlight) throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest(queryReq);
|
||||
query.setHighlight(highlight);
|
||||
return restClient.authenticateUser(testUser).withSearchAPI().search(query);
|
||||
}
|
||||
|
||||
protected SearchRequest createQuery(String term)
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
queryReq.setQuery(term);
|
||||
query.setQuery(queryReq);
|
||||
return query;
|
||||
}
|
||||
}
|
||||
+8
-27
@@ -1,29 +1,29 @@
|
||||
package org.alfresco.service.search.cmis;
|
||||
package org.alfresco.test.search.functional.searchServices.cmis;
|
||||
|
||||
import org.alfresco.cmis.CmisProperties;
|
||||
import org.alfresco.cmis.CmisWrapper;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.alfresco.test.search.functional.searchServices.search.AbstractSearchServicesE2ETest;
|
||||
import org.alfresco.utility.LogFactory;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.network.ServerHealth;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
|
||||
/**
|
||||
* Supertype layer for all InsightEngine E2E tests.
|
||||
*
|
||||
* @author agazzarini
|
||||
*/
|
||||
@ContextConfiguration("classpath:alfresco-search-e2e-context.xml")
|
||||
@Component
|
||||
@Scope(value = "prototype")
|
||||
public abstract class CmisTest extends AbstractTestNGSpringContextTests
|
||||
public abstract class AbstractCmisE2ETest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
private static Logger LOG = LogFactory.getLogger();
|
||||
|
||||
@@ -33,27 +33,8 @@ public abstract class CmisTest extends AbstractTestNGSpringContextTests
|
||||
@Autowired
|
||||
protected CmisProperties cmisProperties;
|
||||
|
||||
@Autowired
|
||||
protected DataUser dataUser;
|
||||
|
||||
@Autowired
|
||||
protected DataSite dataSite;
|
||||
|
||||
@Autowired
|
||||
protected DataContent dataContent;
|
||||
|
||||
@Autowired
|
||||
ServerHealth serverHealth;
|
||||
|
||||
public String documentContent = "CMIS document content";
|
||||
|
||||
@BeforeSuite(alwaysRun = true)
|
||||
public void checkServerHealth() throws Exception
|
||||
{
|
||||
super.springTestContextPrepareTestInstance();
|
||||
serverHealth.assertServerIsOnline();
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void showStartTestInfo(Method method)
|
||||
{
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.service.search.cmis;
|
||||
package org.alfresco.test.search.functional.searchServices.cmis;
|
||||
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.data.provider.XMLDataConfig;
|
||||
@@ -13,7 +13,7 @@ import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class SolrSearchByAspectTests extends CmisTest
|
||||
public class SolrSearchByAspectTests extends AbstractCmisE2ETest
|
||||
{
|
||||
/** Logger for the class. */
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(SolrSearchByAspectTests.class);
|
||||
@@ -22,7 +22,7 @@ public class SolrSearchByAspectTests extends CmisTest
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void deployCustomModel() throws TestConfigurationException
|
||||
{
|
||||
dataContent.deployContentModel("model/tas-model.xml");
|
||||
deployCustomModel("model/tas-model.xml");
|
||||
cmisApi.authenticateUser(dataUser.getAdminUser());
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.service.search.cmis;
|
||||
package org.alfresco.test.search.functional.searchServices.cmis;
|
||||
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.data.provider.XMLDataConfig;
|
||||
@@ -13,7 +13,7 @@ import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class SolrSearchByIdTests extends CmisTest
|
||||
public class SolrSearchByIdTests extends AbstractCmisE2ETest
|
||||
{
|
||||
/** Logger for the class. */
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(SolrSearchByIdTests.class);
|
||||
@@ -22,7 +22,7 @@ public class SolrSearchByIdTests extends CmisTest
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void deployCustomModel() throws TestConfigurationException
|
||||
{
|
||||
dataContent.deployContentModel("model/tas-model.xml");
|
||||
deployCustomModel("model/tas-model.xml");
|
||||
cmisApi.authenticateUser(dataUser.getAdminUser());
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.service.search.cmis;
|
||||
package org.alfresco.test.search.functional.searchServices.cmis;
|
||||
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.data.provider.XMLDataConfig;
|
||||
@@ -12,7 +12,7 @@ import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class SolrSearchByPathTests extends CmisTest
|
||||
public class SolrSearchByPathTests extends AbstractCmisE2ETest
|
||||
{
|
||||
/** Logger for the class. */
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(SolrSearchByPathTests.class);
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.service.search.cmis;
|
||||
package org.alfresco.test.search.functional.searchServices.cmis;
|
||||
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.data.provider.XMLDataConfig;
|
||||
@@ -13,7 +13,7 @@ import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class SolrSearchByPropertyTests extends CmisTest
|
||||
public class SolrSearchByPropertyTests extends AbstractCmisE2ETest
|
||||
{
|
||||
/** Logger for the class. */
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(SolrSearchByPropertyTests.class);
|
||||
@@ -22,7 +22,7 @@ public class SolrSearchByPropertyTests extends CmisTest
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void deployCustomModel() throws TestConfigurationException
|
||||
{
|
||||
dataContent.deployContentModel("model/tas-model.xml");
|
||||
deployCustomModel("model/tas-model.xml");
|
||||
cmisApi.authenticateUser(dataUser.getAdminUser());
|
||||
}
|
||||
|
||||
+3
-10
@@ -1,24 +1,19 @@
|
||||
package org.alfresco.service.search.cmis;
|
||||
package org.alfresco.test.search.functional.searchServices.cmis;
|
||||
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.data.provider.XMLDataConfig;
|
||||
import org.alfresco.utility.data.provider.XMLTestData;
|
||||
import org.alfresco.utility.data.provider.XMLTestDataProvider;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.QueryModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class SolrSearchInFolderTests extends CmisTest
|
||||
public class SolrSearchInFolderTests extends AbstractCmisE2ETest
|
||||
{
|
||||
private UserModel testUser;
|
||||
private SiteModel testSite;
|
||||
private FolderModel parentFolder, subFolder1, subFolder2, subFolder3;
|
||||
private FileModel subFile1, subFile2, subFile3, subFile4, subFile5;
|
||||
|
||||
@@ -35,9 +30,7 @@ public class SolrSearchInFolderTests extends CmisTest
|
||||
subFile2 = FileModel.getRandomFileModel(FileType.MSPOWERPOINT2007);
|
||||
subFile3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
subFile4 = new FileModel("fourthFile", "fourthFileTitle", "fourthFileDescription", FileType.MSWORD2007);
|
||||
|
||||
testUser = dataUser.createRandomTestUser();
|
||||
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(parentFolder)
|
||||
.then().usingResource(parentFolder)
|
||||
.createFile(subFile5).assertThat().contentIs("fifthFile content")
|
||||
+3
-10
@@ -1,24 +1,19 @@
|
||||
package org.alfresco.service.search.cmis;
|
||||
package org.alfresco.test.search.functional.searchServices.cmis;
|
||||
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.data.provider.XMLDataConfig;
|
||||
import org.alfresco.utility.data.provider.XMLTestData;
|
||||
import org.alfresco.utility.data.provider.XMLTestDataProvider;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.QueryModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class SolrSearchInTreeTests extends CmisTest
|
||||
public class SolrSearchInTreeTests extends AbstractCmisE2ETest
|
||||
{
|
||||
private UserModel testUser;
|
||||
private SiteModel testSite;
|
||||
private FolderModel parentFolder, subFolder1, subFolder2, subFolder3;
|
||||
private FileModel subFile1, subFile2, subFile3, subFile4, subFile5, subFile6;
|
||||
|
||||
@@ -36,9 +31,7 @@ public class SolrSearchInTreeTests extends CmisTest
|
||||
subFile3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
subFile4 = new FileModel("fourthFile", "fourthFileTitle", "fourthFileDescription", FileType.MSWORD2007);
|
||||
subFile6 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
|
||||
testUser = dataUser.createRandomTestUser();
|
||||
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(parentFolder)
|
||||
.then().usingResource(parentFolder)
|
||||
.createFile(subFile5).assertThat().contentIs("fifthFile content")
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.alfresco.service.search.cmis;
|
||||
package org.alfresco.test.search.functional.searchServices.cmis;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class SorlSearchSimpleQueryTests extends CmisTest
|
||||
public class SorlSearchSimpleQueryTests extends AbstractCmisE2ETest
|
||||
{
|
||||
@Test
|
||||
public void simpleQueryOnFolderDesc() throws Exception
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2018 Alfresco Software, Ltd. All rights reserved.
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
package org.alfresco.test.search.functional.searchServices.sanity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.test.search.functional.AbstractE2EFunctionalTest;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Purpose of this Test is to test that the dependencies have been wired correctly and work well.
|
||||
*
|
||||
* @author meenal bhave
|
||||
*/
|
||||
public class SetupTest extends AbstractE2EFunctionalTest
|
||||
{
|
||||
@Autowired
|
||||
protected DataSite dataSite;
|
||||
|
||||
@Autowired
|
||||
protected DataContent dataContent;
|
||||
|
||||
private FolderModel testFolder;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
dataContent.usingSite(testSite).createFolder(FolderModel.getRandomFolderModel());
|
||||
|
||||
dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor);
|
||||
|
||||
testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
}
|
||||
|
||||
// Test CMIS API works
|
||||
@Test(priority = 1, groups = { TestGroup.SANITY })
|
||||
public void testCMISFileCreation() throws Exception
|
||||
{
|
||||
// Create document in a folder in a collaboration site
|
||||
FileModel testFile = new FileModel("TestFile");
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(testFile).assertThat().existsInRepo();
|
||||
}
|
||||
|
||||
// Test Custom Model: Music can be used
|
||||
@Test(priority = 2, groups = { TestGroup.SANITY })
|
||||
public void testModelMusicCanBeUsed() throws Exception
|
||||
{
|
||||
// Create document of custom type
|
||||
FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "searchContent-music");
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:music:song");
|
||||
properties.put(PropertyIds.NAME, customFile.getName());
|
||||
properties.put("music:genre", "pop");
|
||||
properties.put("music:lyricist", "Me");
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite)
|
||||
.usingResource(testFolder)
|
||||
.createFile(customFile, properties, VersioningState.MAJOR)
|
||||
.assertThat().existsInRepo();
|
||||
}
|
||||
|
||||
// Test Custom Model: Finance can be used
|
||||
@Test(priority = 3, groups = { TestGroup.SANITY })
|
||||
public void testModelFinanceCanBeUsed() throws Exception
|
||||
{
|
||||
// Create document of custom type
|
||||
|
||||
FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "searchContent-finance");
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Receipt");
|
||||
properties.put(PropertyIds.NAME, customFile.getName());
|
||||
properties.put("finance:ReceiptNo", 1);
|
||||
properties.put("finance:ReceiptValue", 30);
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite)
|
||||
.usingResource(testFolder)
|
||||
.createFile(customFile, properties, VersioningState.MAJOR)
|
||||
.assertThat().existsInRepo();
|
||||
|
||||
Assert.assertTrue(waitForIndexing("cm:name:" + customFile.getName(),true),"New content could not be found");
|
||||
}
|
||||
}
|
||||
+31
-113
@@ -16,25 +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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import org.alfresco.dataprep.SiteService.Visibility;
|
||||
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.test.search.functional.AbstractE2EFunctionalTest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.alfresco.rest.RestTest;
|
||||
|
||||
import javax.naming.AuthenticationException;
|
||||
|
||||
@@ -49,30 +41,15 @@ import javax.naming.AuthenticationException;
|
||||
* @author Meenal Bhave
|
||||
*
|
||||
*/
|
||||
public class AbstractSearchTest extends RestTest
|
||||
public abstract class AbstractSearchServicesE2ETest extends AbstractE2EFunctionalTest
|
||||
{
|
||||
|
||||
protected static final String SEARCH_DATA_SAMPLE_FOLDER = "FolderSearch";
|
||||
protected UserModel userModel, adminUserModel;
|
||||
protected SiteModel siteModel;
|
||||
protected UserModel searchedUser;
|
||||
protected FileModel file, file2, file3, file4;
|
||||
private static final String SEARCH_DATA_SAMPLE_FOLDER = "FolderSearch";
|
||||
|
||||
protected FileModel file, file2, file4;
|
||||
|
||||
protected static String unique_searchString;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
public void searchServicesDataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
userModel = dataUser.createRandomTestUser("UserSearch");
|
||||
|
||||
siteModel = new SiteModel(RandomData.getRandomName("SiteSearch"));
|
||||
siteModel.setVisibility(Visibility.PRIVATE);
|
||||
|
||||
siteModel = dataSite.usingUser(userModel).createSite(siteModel);
|
||||
|
||||
unique_searchString = siteModel.getTitle().replace("SiteSearch", "Unique");
|
||||
|
||||
/*
|
||||
* Create the following file structure for preconditions :
|
||||
* |- folder
|
||||
@@ -83,108 +60,49 @@ public class AbstractSearchTest extends RestTest
|
||||
*/
|
||||
|
||||
FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER);
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).createFolder(folder);
|
||||
|
||||
//Create files
|
||||
String title = "Title: " + unique_searchString;
|
||||
String description = "Description: File is created for search tests by Author: " + unique_searchString + " . ";
|
||||
|
||||
|
||||
file = new FileModel("pangram.txt", "pangram" + title, description, FileType.TEXT_PLAIN, description + " The quick brown fox jumps over the lazy dog");
|
||||
|
||||
|
||||
file2 = new FileModel("cars.txt", "cars" + title, description, FileType.TEXT_PLAIN, "The landrover discovery is not a sports car ");
|
||||
|
||||
file3 = new FileModel("alfresco.txt", "alfresco", "alfresco", FileType.TEXT_PLAIN, "Alfresco text file for search ");
|
||||
|
||||
FileModel file3 = new FileModel("alfresco.txt", "alfresco", "alfresco", FileType.TEXT_PLAIN, "Alfresco text file for search ");
|
||||
|
||||
file4 = new FileModel(unique_searchString + ".txt", "uniquee" + title, description, FileType.TEXT_PLAIN, "Unique text file for search ");
|
||||
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file);
|
||||
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);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).usingResource(folder).createContent(file);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).usingResource(folder).createContent(file2);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).usingResource(folder).createContent(file3);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).usingResource(folder).createContent(file4);
|
||||
|
||||
waitForMetadataIndexing(file4.getName(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method which create an http post request to Search API end point.
|
||||
* @param term String search term
|
||||
* @return {@link SearchResponse} response.
|
||||
* @throws Exception if error
|
||||
*
|
||||
*/
|
||||
protected SearchResponse query(String term) throws Exception
|
||||
{
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
queryReq.setLanguage("afts");
|
||||
queryReq.setQuery(term);
|
||||
SearchRequest query = new SearchRequest(queryReq);
|
||||
return restClient.authenticateUser(userModel).withSearchAPI().search(query);
|
||||
}
|
||||
/**
|
||||
* Helper method which create an http post request to Search API end point.
|
||||
*
|
||||
* @return {@link SearchResponse} response.
|
||||
* @throws Exception if error
|
||||
*
|
||||
*/
|
||||
protected SearchResponse query(RestRequestQueryModel queryReq, RestRequestHighlightModel highlight) throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest(queryReq);
|
||||
query.setHighlight(highlight);
|
||||
return restClient.authenticateUser(userModel).withSearchAPI().search(query);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Helper method which create an http post request to Search API end point.
|
||||
* Executes the given search request without throwing checked exceptions (a {@link RuntimeException} will be thrown in case).
|
||||
* @param query the search request.
|
||||
* @return {@link SearchResponse} response.
|
||||
*
|
||||
*/
|
||||
protected SearchResponse query(SearchRequest query)
|
||||
{
|
||||
try
|
||||
{
|
||||
return restClient.authenticateUser(userModel).withSearchAPI().search(query);
|
||||
}
|
||||
catch (final Exception exception)
|
||||
{
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes an SQL Query using "solr" as output format.
|
||||
*
|
||||
* @param sql the SQL statement.
|
||||
*/
|
||||
protected RestResponse executeSqlAsSolr(String sql) throws Exception
|
||||
{
|
||||
SearchSqlRequest sqlRequest = new SearchSqlRequest();
|
||||
sqlRequest.setSql(sql);
|
||||
sqlRequest.setFormat("solr");
|
||||
return searchSql(sqlRequest);
|
||||
}
|
||||
|
||||
protected SearchRequest createQuery(String term)
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
queryReq.setQuery(term);
|
||||
query.setQuery(queryReq);
|
||||
return query;
|
||||
}
|
||||
// /**
|
||||
// * Helper method which create an http post request to Search API end point.
|
||||
// * @param term String search term
|
||||
// * @return {@link SearchResponse} response.
|
||||
// * @throws Exception if error
|
||||
// *
|
||||
// */
|
||||
// protected SearchResponse query(String term) throws Exception
|
||||
// {
|
||||
// RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
// queryReq.setLanguage("afts");
|
||||
// queryReq.setQuery(term);
|
||||
// SearchRequest query = new SearchRequest(queryReq);
|
||||
// return restClient.authenticateUser(testUser).withSearchAPI().search(query);
|
||||
// }
|
||||
|
||||
protected SearchRequest carsQuery()
|
||||
{
|
||||
return createQuery("cars");
|
||||
}
|
||||
|
||||
protected RestResponse searchSql(SearchSqlRequest searchSqlRequest) throws Exception
|
||||
{
|
||||
return restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(searchSqlRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results
|
||||
*
|
||||
+15
-17
@@ -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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -48,12 +48,10 @@ import org.testng.annotations.Test;
|
||||
* @author Meenal Bhave
|
||||
*
|
||||
*/
|
||||
public class FacetFieldsSearchTest extends AbstractSearchTest
|
||||
public class FacetFieldsSearchTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
private UserModel userWithNoAccess, userCanAccessTextFile;
|
||||
private SiteModel testSite;
|
||||
private FolderModel testFolder;
|
||||
private FileModel textFile, htmlFile;
|
||||
private String fname;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
@@ -66,21 +64,21 @@ public class FacetFieldsSearchTest extends AbstractSearchTest
|
||||
testSite = new SiteModel(RandomData.getRandomName("SiteSearch"));
|
||||
testSite.setVisibility(Visibility.PRIVATE);
|
||||
|
||||
testSite = dataSite.usingUser(userModel).createSite(testSite);
|
||||
testSite = dataSite.usingUser(testUser).createSite(testSite);
|
||||
|
||||
// Create another user who would not have access to the Private Site created by userModel
|
||||
// Create another user who would not have access to the Private Site created by testUser
|
||||
userWithNoAccess = dataUser.createRandomTestUser("UserSearch2");
|
||||
userCanAccessTextFile = dataUser.createRandomTestUser("UserSearch3");
|
||||
|
||||
// Create a folder and a file as test User
|
||||
testFolder = new FolderModel(fname);
|
||||
dataContent.usingUser(userModel).usingSite(testSite).createFolder(testFolder);
|
||||
FolderModel testFolder = new FolderModel(fname);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).createFolder(testFolder);
|
||||
|
||||
textFile = new FileModel(fname + "-1.txt", fname, fname, FileType.TEXT_PLAIN, fname + " file for search ");
|
||||
dataContent.usingUser(userModel).usingSite(testSite).createContent(textFile);
|
||||
FileModel textFile = new FileModel(fname + "-1.txt", fname, fname, FileType.TEXT_PLAIN, fname + " file for search ");
|
||||
dataContent.usingUser(testUser).usingSite(testSite).createContent(textFile);
|
||||
|
||||
htmlFile = new FileModel(fname + "-2.html", FileType.HTML, fname + " file 2 for search ");
|
||||
dataContent.usingUser(userModel).usingSite(testSite).createContent(htmlFile);
|
||||
FileModel htmlFile = new FileModel(fname + "-2.html", FileType.HTML, fname + " file 2 for search ");
|
||||
dataContent.usingUser(testUser).usingSite(testSite).createContent(htmlFile);
|
||||
|
||||
// Set Node Permissions to allow access for user for text File
|
||||
JsonObject userPermission = Json.createObjectBuilder()
|
||||
@@ -90,7 +88,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest
|
||||
.build();
|
||||
String putBody = userPermission.toString();
|
||||
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingNode(textFile).updateNode(putBody);
|
||||
restClient.authenticateUser(testUser).withCoreAPI().usingNode(textFile).updateNode(putBody);
|
||||
|
||||
// Wait for the file to be indexed
|
||||
waitForIndexing(htmlFile.getName(), true);
|
||||
@@ -106,7 +104,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest
|
||||
query.setQuery(queryReq);
|
||||
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<RestRequestFacetFieldModel>();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<>();
|
||||
|
||||
facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELDS.SITE", 0)); // MinCount = 0
|
||||
facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "Mimetype", 2)); // MinCount = 2
|
||||
@@ -141,7 +139,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest
|
||||
query.setQuery(queryReq);
|
||||
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<RestRequestFacetFieldModel>();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<>();
|
||||
|
||||
// MinCount not set
|
||||
facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set
|
||||
@@ -192,7 +190,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest
|
||||
query.setQuery(queryReq);
|
||||
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<RestRequestFacetFieldModel>();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<>();
|
||||
|
||||
facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set
|
||||
facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1
|
||||
@@ -216,7 +214,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest
|
||||
query.setQuery(queryReq);
|
||||
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<RestRequestFacetFieldModel>();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<>();
|
||||
|
||||
facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set
|
||||
facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1
|
||||
+9
-9
@@ -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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.search.FacetInterval;
|
||||
@@ -35,12 +35,13 @@ import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Faceted Intervals Search Test
|
||||
* @author Gethin James
|
||||
*/
|
||||
public class FacetIntervalSearchTest extends AbstractSearchTest
|
||||
public class FacetIntervalSearchTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
@@ -57,7 +58,7 @@ public class FacetIntervalSearchTest extends AbstractSearchTest
|
||||
|
||||
RestRequestFacetIntervalsModel facetIntervalsModel = new RestRequestFacetIntervalsModel();
|
||||
FacetInterval facetInterval = new FacetInterval(null, null, null);
|
||||
facetIntervalsModel.setIntervals(Arrays.asList(facetInterval));
|
||||
facetIntervalsModel.setIntervals(Collections.singletonList(facetInterval));
|
||||
query.setFacetIntervals(facetIntervalsModel);
|
||||
|
||||
query(query);
|
||||
@@ -70,7 +71,7 @@ public class FacetIntervalSearchTest extends AbstractSearchTest
|
||||
|
||||
RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel();
|
||||
restFacetSetModel.setLabel("theRest");
|
||||
facetInterval.setSets(Arrays.asList(restFacetSetModel));
|
||||
facetInterval.setSets(Collections.singletonList(restFacetSetModel));
|
||||
query(query);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets start"));
|
||||
@@ -91,16 +92,15 @@ public class FacetIntervalSearchTest extends AbstractSearchTest
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsSummary("duplicate set interval label [theRest=2]");
|
||||
|
||||
facetInterval.setSets(Arrays.asList(restFacetSetModel));
|
||||
facetInterval.setSets(Collections.singletonList(restFacetSetModel));
|
||||
facetInterval.setLabel("thesame");
|
||||
FacetInterval duplicateLabel = new FacetInterval("creator", "thesame", Arrays.asList(duplicate));
|
||||
FacetInterval duplicateLabel = new FacetInterval("creator", "thesame", Collections.singletonList(duplicate));
|
||||
facetIntervalsModel.setIntervals(Arrays.asList(facetInterval, duplicateLabel));
|
||||
query.setFacetIntervals(facetIntervalsModel);
|
||||
|
||||
query(query);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsSummary("duplicate interval label [thesame=2]");
|
||||
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@@ -123,7 +123,7 @@ public class FacetIntervalSearchTest extends AbstractSearchTest
|
||||
restFacetSetModel.setLabel("theRest");
|
||||
|
||||
FacetInterval facetInterval = new FacetInterval("creator", null, Arrays.asList(restRequestFacetSetModel, restFacetSetModel));
|
||||
facetIntervalsModel.setIntervals(Arrays.asList(facetInterval));
|
||||
facetIntervalsModel.setIntervals(Collections.singletonList(facetInterval));
|
||||
query.setFacetIntervals(facetIntervalsModel);
|
||||
|
||||
SearchResponse response = query(query);
|
||||
@@ -166,7 +166,7 @@ public class FacetIntervalSearchTest extends AbstractSearchTest
|
||||
restFacetSetModel.setLabel("From2016");
|
||||
|
||||
FacetInterval facetInterval = new FacetInterval("cm:modified", "modified", Arrays.asList(restRequestFacetSetModel, restFacetSetModel));
|
||||
facetIntervalsModel.setIntervals(Arrays.asList(facetInterval));
|
||||
facetIntervalsModel.setIntervals(Collections.singletonList(facetInterval));
|
||||
query.setFacetIntervals(facetIntervalsModel);
|
||||
|
||||
SearchResponse response = query(query);
|
||||
+11
-7
@@ -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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
@@ -67,7 +67,7 @@ import org.testng.annotations.Test;
|
||||
* @author Michael Suzuki
|
||||
*
|
||||
*/
|
||||
public class FacetRangeSearchTest extends AbstractSearchTest
|
||||
public class FacetRangeSearchTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION,
|
||||
@@ -117,9 +117,10 @@ public class FacetRangeSearchTest extends AbstractSearchTest
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Check basic facet range search api")
|
||||
@SuppressWarnings("unchecked")
|
||||
public void searchWithRange()
|
||||
{
|
||||
SearchRequest query = createQuery("* AND SITE:'" + siteModel.getId() + "'");
|
||||
SearchRequest query = createQuery("* AND SITE:'" + testSite.getId() + "'");
|
||||
|
||||
RestRequestRangesModel facetRangeModel = new RestRequestRangesModel();
|
||||
facetRangeModel.setField("content.size");
|
||||
@@ -171,9 +172,10 @@ public class FacetRangeSearchTest extends AbstractSearchTest
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Check date facet intervals search api")
|
||||
@SuppressWarnings("unchecked")
|
||||
public void searchWithRangeHardend()
|
||||
{
|
||||
SearchRequest query = createQuery("* AND SITE:'" + siteModel.getId() + "'");
|
||||
SearchRequest query = createQuery("* AND SITE:'" + testSite.getId() + "'");
|
||||
|
||||
RestRequestRangesModel facetRangeModel = new RestRequestRangesModel();
|
||||
facetRangeModel.setField("content.size");
|
||||
@@ -230,6 +232,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Check date facet intervals search api")
|
||||
@SuppressWarnings("unchecked")
|
||||
public void searchDateRange()
|
||||
{
|
||||
SearchRequest query = createQuery("name:A*");
|
||||
@@ -267,7 +270,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest
|
||||
description = "Check date facet intervals search api")
|
||||
public void searchDateAndSizeRanges()
|
||||
{
|
||||
SearchRequest query = createQuery("* AND SITE:'" + siteModel.getId() + "'");
|
||||
SearchRequest query = createQuery("* AND SITE:'" + testSite.getId() + "'");
|
||||
List<RestRequestRangesModel> ranges = new ArrayList<>();
|
||||
RestRequestRangesModel facetRangeModel = new RestRequestRangesModel();
|
||||
facetRangeModel.setField("created");
|
||||
@@ -287,9 +290,10 @@ public class FacetRangeSearchTest extends AbstractSearchTest
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Check basic facet range search api")
|
||||
@SuppressWarnings("unchecked")
|
||||
public void searchWithRangeAndIncludeUpperBound()
|
||||
{
|
||||
SearchRequest query = createQuery("* AND SITE:'" + siteModel.getId() + "'");
|
||||
SearchRequest query = createQuery("* AND SITE:'" + testSite.getId() + "'");
|
||||
|
||||
RestRequestRangesModel facetRangeModel = new RestRequestRangesModel();
|
||||
facetRangeModel.setField("content.size");
|
||||
@@ -341,4 +345,4 @@ public class FacetRangeSearchTest extends AbstractSearchTest
|
||||
assertEquals(info.get("startInclusive"),"false");
|
||||
assertEquals(info.get("endInclusive"),"true");
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
-33
@@ -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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -41,12 +41,11 @@ import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Faceted search test.
|
||||
* @author Michael Suzuki
|
||||
*
|
||||
* @author Michael Suzuki
|
||||
*/
|
||||
public class FacetedSearchTest extends AbstractSearchTest
|
||||
public class FacetedSearchTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
|
||||
/**
|
||||
* Perform the below facet query.
|
||||
* {
|
||||
@@ -95,9 +94,7 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
* ]
|
||||
* },
|
||||
* }}
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
@@ -114,7 +111,7 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
queryReq.setQuery("cars");
|
||||
query.setQuery(queryReq);
|
||||
|
||||
List<FacetQuery> facets = new ArrayList<FacetQuery>();
|
||||
List<FacetQuery> facets = new ArrayList<>();
|
||||
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"));
|
||||
@@ -144,9 +141,7 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
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.
|
||||
* {
|
||||
@@ -161,7 +156,7 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
* ],
|
||||
* "facetFields": {"facets": [{"field": "'content.size'"}]}
|
||||
* }
|
||||
*
|
||||
*
|
||||
* Expected response
|
||||
* {"list": {
|
||||
* "entries": [... All the results],
|
||||
@@ -185,10 +180,10 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
* }
|
||||
* }
|
||||
* }}
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@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 searchQueryFacetingWithGroup() throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
@@ -196,7 +191,7 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
queryReq.setQuery("cars");
|
||||
query.setQuery(queryReq);
|
||||
|
||||
List<FacetQuery> facets = new ArrayList<FacetQuery>();
|
||||
List<FacetQuery> facets = new ArrayList<>();
|
||||
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"));
|
||||
@@ -211,7 +206,7 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
SearchResponse response = query(query);
|
||||
|
||||
// We don't expect to see the FacetQueries if group is being used.
|
||||
Assert.assertTrue(response.getContext().getFacetQueries() == null);
|
||||
Assert.assertNull(response.getContext().getFacetQueries());
|
||||
// Validate the facet field structure is correct.
|
||||
Assert.assertFalse(response.getContext().getFacets().isEmpty());
|
||||
Assert.assertEquals(response.getContext().getFacets().get(0).getLabel(), "foo");
|
||||
@@ -240,10 +235,7 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@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": {
|
||||
@@ -254,6 +246,9 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
@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 searchWithFactedFields() throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
@@ -262,7 +257,7 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
query.setQuery(queryReq);
|
||||
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<RestRequestFacetFieldModel>();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<>();
|
||||
facets.add(new RestRequestFacetFieldModel("cm:mimetype"));
|
||||
facets.add(new RestRequestFacetFieldModel("modifier"));
|
||||
facetFields.setFacets(facets);
|
||||
@@ -279,15 +274,12 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
|
||||
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("label").is(testUser.getUsername());
|
||||
bucket1.assertThat().field("display").is(testUser.getUsername() + " FirstName LN-" + testUser.getUsername());
|
||||
bucket1.assertThat().field("filterQuery").is("modifier:\"" + testUser.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.
|
||||
* {
|
||||
@@ -300,6 +292,9 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
* "facetFormat":"V2"
|
||||
* }
|
||||
*/
|
||||
@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 searchWithFactedFieldsFacetFormatV2() throws Exception
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
@@ -308,7 +303,7 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
query.setQuery(queryReq);
|
||||
query.setFacetFormat("V2");
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<RestRequestFacetFieldModel>();
|
||||
List<RestRequestFacetFieldModel> facets = new ArrayList<>();
|
||||
facets.add(new RestRequestFacetFieldModel("cm:mimetype"));
|
||||
facets.add(new RestRequestFacetFieldModel("modifier"));
|
||||
facetFields.setFacets(facets);
|
||||
@@ -324,9 +319,9 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
|
||||
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("label").is(testUser.getUsername());
|
||||
bucket1.assertThat().field("display").is(testUser.getUsername() + " FirstName LN-" + testUser.getUsername());
|
||||
bucket1.assertThat().field("filterQuery").is("modifier:\"" + testUser.getUsername() + "\"");
|
||||
bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=1}}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-23
@@ -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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import org.alfresco.rest.search.SearchNodeModel;
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
@@ -30,17 +30,17 @@ import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Search end point Public API test with finger print.
|
||||
*
|
||||
* @author Michael Suzuki
|
||||
*
|
||||
*/
|
||||
public class FingerPrintTest extends AbstractSearchTest
|
||||
public class FingerPrintTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
private FileModel file1, file2, file3, file4;
|
||||
private FileModel file1;
|
||||
private FileModel file2;
|
||||
|
||||
@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
|
||||
@@ -51,19 +51,21 @@ public class FingerPrintTest extends AbstractSearchTest
|
||||
*/
|
||||
|
||||
FolderModel folder = new FolderModel("The quick brown fox jumps over");
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).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);
|
||||
FileModel file3 = new FileModel("pangram-cat.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy cat");
|
||||
FileModel file4 = new FileModel("dog.txt", FileType.TEXT_PLAIN, "The quick brown fox ate the lazy dog");
|
||||
|
||||
dataContent.usingUser(testUser).usingSite(testSite).usingResource(folder).createContent(file1);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).usingResource(folder).createContent(file2);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).usingResource(folder).createContent(file3);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).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);
|
||||
@@ -74,11 +76,9 @@ public class FingerPrintTest extends AbstractSearchTest
|
||||
* 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
|
||||
public void search()
|
||||
{
|
||||
String uuid = file1.getNodeRefWithoutVersion();
|
||||
Assert.assertNotNull(uuid);
|
||||
@@ -92,11 +92,8 @@ public class FingerPrintTest extends AbstractSearchTest
|
||||
switch (match)
|
||||
{
|
||||
case "pangram.txt":
|
||||
break;
|
||||
case "pangram-banana.txt":
|
||||
break;
|
||||
case "pangram-taco.txt":
|
||||
break;
|
||||
case "pangram-cat.txt":
|
||||
break;
|
||||
default:
|
||||
@@ -108,7 +105,7 @@ public class FingerPrintTest extends AbstractSearchTest
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
public void searchSimilar() throws Exception
|
||||
public void searchSimilar()
|
||||
{
|
||||
String uuid = file2.getNodeRefWithoutVersion();
|
||||
Assert.assertNotNull(uuid);
|
||||
@@ -125,7 +122,6 @@ public class FingerPrintTest extends AbstractSearchTest
|
||||
switch (m.getModel().getName())
|
||||
{
|
||||
case "pangram.txt":
|
||||
break;
|
||||
case "pangram-taco.txt":
|
||||
break;
|
||||
default:
|
||||
@@ -139,7 +135,7 @@ public class FingerPrintTest extends AbstractSearchTest
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
public void searchSimilar67Percent() throws Exception
|
||||
public void searchSimilar67Percent()
|
||||
{
|
||||
String uuid = file2.getNodeRefWithoutVersion();
|
||||
Assert.assertNotNull(uuid);
|
||||
@@ -152,9 +148,7 @@ public class FingerPrintTest extends AbstractSearchTest
|
||||
switch (m.getModel().getName())
|
||||
{
|
||||
case "pangram.txt":
|
||||
break;
|
||||
case "pangram-taco.txt":
|
||||
break;
|
||||
case "pangram-cat.txt":
|
||||
break;
|
||||
default:
|
||||
+14
-13
@@ -16,12 +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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
@@ -47,7 +48,7 @@ import org.testng.annotations.Test;
|
||||
* @author Gethin James
|
||||
*
|
||||
*/
|
||||
public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
public class PivotFacetedSearchTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
@@ -59,7 +60,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks errors with pivot using Search api")
|
||||
public void searchWithPivotingErrors() throws Exception
|
||||
public void searchWithPivotingErrors()
|
||||
{
|
||||
SearchRequest query = carsQuery();
|
||||
|
||||
@@ -92,7 +93,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks with pivot using Search api")
|
||||
public void searchWithPivoting() throws Exception
|
||||
public void searchWithPivoting()
|
||||
{
|
||||
SearchRequest query = carsQuery();
|
||||
|
||||
@@ -121,7 +122,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks nested pivot using Search api")
|
||||
public void searchWithNestedPivoting() throws Exception
|
||||
public void searchWithNestedPivoting()
|
||||
{
|
||||
SearchRequest query = carsQuery();
|
||||
|
||||
@@ -147,7 +148,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
pivotModelList.add(sitepivots);
|
||||
query.setPivots(pivotModelList);
|
||||
|
||||
SearchResponse response = query(query);
|
||||
query(query);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary("invalid argument was received")
|
||||
.containsSummary("Currently only 1 nested pivot is supported, you have 2");
|
||||
@@ -155,12 +156,12 @@ public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
pivotModelList = new ArrayList<>();
|
||||
sitepivots = new RestRequestPivotModel();
|
||||
sitepivots.setKey("site");
|
||||
sitepivots.setPivots(Arrays.asList(modifierpivot));
|
||||
sitepivots.setPivots(Collections.singletonList(modifierpivot));
|
||||
pivotModelList.add(sitepivots);
|
||||
pivotModelList.add(creatorpivot);
|
||||
query.setPivots(pivotModelList);
|
||||
|
||||
response = query(query);
|
||||
SearchResponse response = query(query);
|
||||
assertPivotResponse(response, "SITE", "site");
|
||||
|
||||
RestGenericFacetResponseModel siteResponse = response.getContext().getFacets().get(0);
|
||||
@@ -178,7 +179,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks range pivots using Search api")
|
||||
public void searchWithRangePivoting() throws Exception
|
||||
public void searchWithRangePivoting()
|
||||
{
|
||||
SearchRequest query = carsQuery();
|
||||
|
||||
@@ -201,7 +202,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
facetRangeModel.setEnd(endDate);
|
||||
facetRangeModel.setGap("+280DAY");
|
||||
facetRangeModel.setLabel("aRange");
|
||||
List<RestRequestRangesModel> ranges = new ArrayList<RestRequestRangesModel>();
|
||||
List<RestRequestRangesModel> ranges = new ArrayList<>();
|
||||
ranges.add(facetRangeModel);
|
||||
query.setRanges(ranges);
|
||||
|
||||
@@ -210,7 +211,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
creatorpivot.setKey("creator");
|
||||
RestRequestPivotModel rangepivot = new RestRequestPivotModel();
|
||||
rangepivot.setKey("aRange");
|
||||
creatorpivot.setPivots(Arrays.asList(rangepivot));
|
||||
creatorpivot.setPivots(Collections.singletonList(rangepivot));
|
||||
pivotModelList.add(creatorpivot);
|
||||
query.setPivots(pivotModelList);
|
||||
|
||||
@@ -223,7 +224,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
rangeResponse.assertThat().field("type").is("range");
|
||||
}
|
||||
|
||||
private void assertPivotResponse(SearchResponse response, String field, String alabel) throws Exception
|
||||
private void assertPivotResponse(SearchResponse response, String field, String alabel)
|
||||
{
|
||||
String label = alabel!=null?alabel:field;
|
||||
response.getContext().assertThat().field("facetsFields").isNull();
|
||||
@@ -242,7 +243,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks with pivot using Search api and a label as a key")
|
||||
public void searchWithPivotingUsingLabel() throws Exception
|
||||
public void searchWithPivotingUsingLabel()
|
||||
{
|
||||
SearchRequest query = carsQuery();
|
||||
RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
+6
-6
@@ -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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -44,10 +44,9 @@ import org.testng.annotations.Test;
|
||||
* @author Michael Suzuki
|
||||
*
|
||||
*/
|
||||
public class SearchAPATHTest extends AbstractSearchTest
|
||||
public class SearchAPATHTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
|
||||
/**
|
||||
* {
|
||||
* "query": {
|
||||
@@ -87,7 +86,8 @@ public class SearchAPATHTest extends AbstractSearchTest
|
||||
*}}
|
||||
*
|
||||
*/
|
||||
public void searchLevel0() throws Exception
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
|
||||
public void searchLevel0()
|
||||
{
|
||||
SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "0");
|
||||
SearchResponse response = query(searchQuery);
|
||||
@@ -99,7 +99,7 @@ public class SearchAPATHTest extends AbstractSearchTest
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
|
||||
public void searchLevel0andIncludeSubLevel1() throws Exception
|
||||
public void searchLevel0andIncludeSubLevel1()
|
||||
{
|
||||
SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "1/");
|
||||
SearchResponse response = query(searchQuery);
|
||||
@@ -111,7 +111,7 @@ public class SearchAPATHTest extends AbstractSearchTest
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1})
|
||||
public void searchLevel2() throws Exception
|
||||
public void searchLevel2()
|
||||
{
|
||||
String queryString = "name:cars";
|
||||
|
||||
+4
-4
@@ -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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -35,7 +35,7 @@ import org.testng.annotations.Test;
|
||||
* @author Michael Suzuki
|
||||
*
|
||||
*/
|
||||
public class SearchHighLightTest extends AbstractSearchTest
|
||||
public class SearchHighLightTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
@Test(groups={TestGroup.SEARCH,TestGroup.REST_API})
|
||||
@Bug(id = "TAS-3220")
|
||||
@@ -51,7 +51,7 @@ public class SearchHighLightTest extends AbstractSearchTest
|
||||
highlight.setPrefix("¿");
|
||||
highlight.setPostfix("?");
|
||||
highlight.setMergeContiguous(true);
|
||||
List<RestRequestFieldsModel> fields = new ArrayList<RestRequestFieldsModel>();
|
||||
List<RestRequestFieldsModel> fields = new ArrayList<>();
|
||||
fields.add(new RestRequestFieldsModel("cm:content"));
|
||||
highlight.setFields(fields);
|
||||
SearchResponse nodes = query(queryReq, highlight);
|
||||
@@ -71,7 +71,7 @@ public class SearchHighLightTest extends AbstractSearchTest
|
||||
highlight.setPrefix("¿");
|
||||
highlight.setPostfix("?");
|
||||
highlight.setMergeContiguous(true);
|
||||
List<RestRequestFieldsModel> fields = new ArrayList<RestRequestFieldsModel>();
|
||||
List<RestRequestFieldsModel> fields = new ArrayList<>();
|
||||
fields.add(new RestRequestFieldsModel("cm:title"));
|
||||
highlight.setFields(fields);
|
||||
SearchResponse nodes = query(queryReq, highlight);
|
||||
+8
-11
@@ -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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import org.alfresco.rest.model.RestRequestSpellcheckModel;
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
@@ -30,12 +30,12 @@ import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Search end point Public API test with spell checking enabled.
|
||||
*
|
||||
* @author Michael Suzuki
|
||||
* @author Meenal Bhave
|
||||
*/
|
||||
public class SearchSpellCheckTest extends AbstractSearchTest
|
||||
public class SearchSpellCheckTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
|
||||
/**
|
||||
* Perform the below query
|
||||
* {
|
||||
@@ -64,8 +64,6 @@ public class SearchSpellCheckTest extends AbstractSearchTest
|
||||
* },
|
||||
* "entries": [...]
|
||||
* }
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=1)
|
||||
public void testSearchMissSpelled() throws Exception
|
||||
@@ -103,7 +101,7 @@ public class SearchSpellCheckTest extends AbstractSearchTest
|
||||
assertResponse(query(searchReq));
|
||||
}
|
||||
|
||||
private void assertResponse(SearchResponse nodes) throws Exception
|
||||
private void assertResponse(SearchResponse nodes)
|
||||
{
|
||||
nodes.assertThat().entriesListIsNotEmpty();
|
||||
nodes.getContext().assertThat().field("spellCheck").isNotEmpty();
|
||||
@@ -121,10 +119,9 @@ public class SearchSpellCheckTest extends AbstractSearchTest
|
||||
* },
|
||||
* "spellcheck": {"query": "alfrezco"}
|
||||
* }
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=2)
|
||||
public void testSearchMissSpelledVersion2() throws Exception
|
||||
public void testSearchMissSpelledVersion2()
|
||||
{
|
||||
SearchRequest searchReq = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
@@ -138,7 +135,7 @@ public class SearchSpellCheckTest extends AbstractSearchTest
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=3)
|
||||
public void testSearchWithSpellcheckerAndCorrectSpelling() throws Exception
|
||||
public void testSearchWithSpellcheckerAndCorrectSpelling()
|
||||
{
|
||||
SearchRequest searchReq = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
@@ -156,7 +153,7 @@ public class SearchSpellCheckTest extends AbstractSearchTest
|
||||
{
|
||||
// Create a file with mis-spelt name, expect spellcheck type = didYouMean
|
||||
FileModel file = new FileModel(unique_searchString + "-1.txt", "uniquee" + "uniquee", "uniquee", FileType.TEXT_PLAIN, "Unique text file for search ");
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).createContent(file);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).createContent(file);
|
||||
|
||||
waitForIndexing(file.getName(), true);
|
||||
|
||||
@@ -174,4 +171,4 @@ public class SearchSpellCheckTest extends AbstractSearchTest
|
||||
nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("unique");
|
||||
nodes.getContext().getSpellCheck().assertThat().field("type").is("didYouMean");
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-14
@@ -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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.singletonList;
|
||||
@@ -54,7 +54,7 @@ import org.testng.annotations.Test;
|
||||
* @author Michael Suzuki
|
||||
*
|
||||
*/
|
||||
public class SearchTest extends AbstractSearchTest
|
||||
public class SearchTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
@@ -76,7 +76,7 @@ public class SearchTest extends AbstractSearchTest
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH,TestGroup.REST_API})
|
||||
public void searchNonIndexedData() throws Exception
|
||||
public void searchNonIndexedData()
|
||||
{
|
||||
SearchResponse nodes = query("yeti");
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -86,7 +86,7 @@ public class SearchTest extends AbstractSearchTest
|
||||
@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
|
||||
public void searchWithRequest()
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
@@ -103,7 +103,7 @@ public class SearchTest extends AbstractSearchTest
|
||||
@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
|
||||
public void searchWithOneSortClause()
|
||||
{
|
||||
// Tests the ascending order first
|
||||
List<String> expectedOrder = asList("alfresco.txt", "cars.txt", "pangram.txt");
|
||||
@@ -112,7 +112,7 @@ public class SearchTest extends AbstractSearchTest
|
||||
searchRequest.addSortClause("FIELD", "name", true);
|
||||
|
||||
RestRequestFilterQueryModel filters = new RestRequestFilterQueryModel();
|
||||
filters.setQuery("SITE:'" + siteModel.getId() + "'");
|
||||
filters.setQuery("SITE:'" + testSite.getId() + "'");
|
||||
searchRequest.setFilterQueries(filters);
|
||||
|
||||
SearchResponse responseWithAscendingOrder = query(searchRequest);
|
||||
@@ -150,7 +150,7 @@ public class SearchTest extends AbstractSearchTest
|
||||
@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
|
||||
public void searchWithTwoSortClauses()
|
||||
{
|
||||
// Tests the ascending order first
|
||||
List<String> expectedOrder = asList("alfresco.txt", "cars.txt", "pangram.txt");
|
||||
@@ -160,7 +160,7 @@ public class SearchTest extends AbstractSearchTest
|
||||
searchRequest.addSortClause("FIELD", "createdByUser.id", true);
|
||||
|
||||
RestRequestFilterQueryModel filters = new RestRequestFilterQueryModel();
|
||||
filters.setQuery("SITE:'" + siteModel.getId() + "'");
|
||||
filters.setQuery("SITE:'" + testSite.getId() + "'");
|
||||
searchRequest.setFilterQueries(filters);
|
||||
|
||||
SearchResponse responseWithAscendingOrder = query(searchRequest);
|
||||
@@ -193,8 +193,8 @@ public class SearchTest extends AbstractSearchTest
|
||||
|
||||
@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
|
||||
TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, description = "Checks the \"include\" request parameter support the 'permissions' option")
|
||||
public void searchQuery_includePermissions_shouldReturnNodeWithPermissionsInformation()
|
||||
{
|
||||
String query = "fox";
|
||||
String include = "permissions";
|
||||
@@ -234,7 +234,7 @@ public class SearchTest extends AbstractSearchTest
|
||||
lockBodyModel.setLifetime("EPHEMERAL");
|
||||
lockBodyModel.setTimeToExpire(20);
|
||||
lockBodyModel.setType("FULL");
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).usingParams("include=isLocked").lockNode(lockBodyModel);
|
||||
restClient.authenticateUser(testUser).withCoreAPI().usingNode(file).usingParams("include=isLocked").lockNode(lockBodyModel);
|
||||
|
||||
query(retrievalQueryIncludingLockInformation);
|
||||
|
||||
@@ -252,7 +252,7 @@ public class SearchTest extends AbstractSearchTest
|
||||
@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
|
||||
public void searchQuery_includeInvalid_shouldReturnBadResponse()
|
||||
{
|
||||
String query = "fox";
|
||||
String notValidInclude = "notValid";
|
||||
@@ -269,7 +269,7 @@ public class SearchTest extends AbstractSearchTest
|
||||
|
||||
// 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
|
||||
public void searchWithFields()
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
@@ -298,7 +298,7 @@ public class SearchTest extends AbstractSearchTest
|
||||
String specialCharfileName = "è¥äæ§ç§-åæ.pdf";
|
||||
FileModel file = new FileModel(specialCharfileName, "è¥äæ§ç§-忬¯¸" + "è¥äæ§ç§-忬¯¸", "è¥äæ§ç§-忬¯¸", FileType.TEXT_PLAIN,
|
||||
"Text file with Special Characters: " + specialCharfileName);
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).createContent(file);
|
||||
dataContent.usingUser(testUser).usingSite(testSite).createContent(file);
|
||||
|
||||
waitForIndexing(file.getName(), true);
|
||||
|
||||
+15
-19
@@ -5,13 +5,13 @@
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
package org.alfresco.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
import org.alfresco.service.search.e2e.AbstractSearchServiceE2E;
|
||||
import org.alfresco.test.search.functional.AbstractE2EFunctionalTest;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
@@ -34,7 +34,7 @@ import org.testng.annotations.Test;
|
||||
* @author meenal bhave
|
||||
*/
|
||||
|
||||
public class SearchWithCustomModelTest extends AbstractSearchServiceE2E
|
||||
public class SearchWithCustomModelTest extends AbstractE2EFunctionalTest
|
||||
{
|
||||
@Autowired
|
||||
protected DataSite dataSite;
|
||||
@@ -42,10 +42,6 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E
|
||||
@Autowired
|
||||
protected DataContent dataContent;
|
||||
|
||||
private FolderModel testFolder;
|
||||
|
||||
private FileModel expenseLondon, expenseParis, expenseNoLocation;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
@@ -53,14 +49,14 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E
|
||||
|
||||
dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor);
|
||||
|
||||
testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
FolderModel testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
|
||||
Long uniqueRef = System.currentTimeMillis();
|
||||
|
||||
expenseLondon = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Expense");
|
||||
FileModel expenseLondon = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Expense");
|
||||
expenseLondon.setName("fin1-" + expenseLondon.getName());
|
||||
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Expense");
|
||||
properties.put(PropertyIds.NAME, expenseLondon.getName());
|
||||
properties.put("finance:No", uniqueRef);
|
||||
@@ -74,10 +70,10 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E
|
||||
.secondaryTypeIsAvailable("P:finance:ParkEx");
|
||||
cmisApi.authenticateUser(testUser).usingResource(expenseLondon).updateProperty("finance:ParkingLocation", "London");
|
||||
|
||||
expenseParis = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Expense");
|
||||
FileModel expenseParis = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Expense");
|
||||
expenseParis.setName("fin2-" + expenseParis.getName());
|
||||
|
||||
properties = new HashMap<String, Object>();
|
||||
properties = new HashMap<>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Expense");
|
||||
properties.put(PropertyIds.NAME, expenseParis.getName());
|
||||
properties.put("finance:No", uniqueRef + 1);
|
||||
@@ -94,10 +90,10 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E
|
||||
.secondaryTypeIsAvailable("P:finance:ParkEx");
|
||||
cmisApi.authenticateUser(testUser).usingResource(expenseParis).updateProperty("finance:ParkingLocation", "Paris");
|
||||
|
||||
expenseNoLocation = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "receipt");
|
||||
FileModel expenseNoLocation = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "receipt");
|
||||
expenseNoLocation.setName("fin3-" + expenseNoLocation.getName());
|
||||
|
||||
properties = new HashMap<String, Object>();
|
||||
properties = new HashMap<>();
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Expense");
|
||||
properties.put(PropertyIds.NAME, expenseNoLocation.getName());
|
||||
properties.put("finance:No", uniqueRef + 2);
|
||||
@@ -119,7 +115,7 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E
|
||||
|
||||
// Search-1359: Search AFTS Query with Range
|
||||
@Test(priority = 1, groups = { TestGroup.ASS_14 })
|
||||
public void testRangeQueryTextField() throws Exception
|
||||
public void testRangeQueryTextField()
|
||||
{
|
||||
// Search Range Query
|
||||
SearchResponse response = queryAsUser(testUser, "finance_ParkingLocation:[* TO London]");
|
||||
@@ -143,7 +139,7 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E
|
||||
}
|
||||
|
||||
@Test(priority = 2, groups = { TestGroup.ASS_14 })
|
||||
public void testRangeQueryTextFieldWhiteSpace() throws Exception
|
||||
public void testRangeQueryTextFieldWhiteSpace()
|
||||
{
|
||||
SearchResponse response = queryAsUser(testUser, "finance:Emp:[* TO Daniel]");
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -164,7 +160,7 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E
|
||||
}
|
||||
|
||||
@Test(priority = 3, groups = { TestGroup.ASS_14 })
|
||||
public void testRangeQueryTextFieldNonFacetable() throws Exception
|
||||
public void testRangeQueryTextFieldNonFacetable()
|
||||
{
|
||||
// Search Range Query
|
||||
SearchResponse response = queryAsUser(testUser, "finance:Title:[* TO H]");
|
||||
@@ -191,7 +187,7 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E
|
||||
}
|
||||
|
||||
@Test(priority = 4, groups = { TestGroup.ASS_14 })
|
||||
public void testRangeQueryTextFieldNotTockenised() throws Exception
|
||||
public void testRangeQueryTextFieldNotTockenised()
|
||||
{
|
||||
SearchResponse response = queryAsUser(testUser, "finance:Desc:[* TO David]");
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -212,7 +208,7 @@ public class SearchWithCustomModelTest extends AbstractSearchServiceE2E
|
||||
}
|
||||
|
||||
@Test(priority = 5, groups = { TestGroup.ASS_14 })
|
||||
public void testRangeQueryDoubleField() throws Exception
|
||||
public void testRangeQueryDoubleField()
|
||||
{
|
||||
// Search Range Query
|
||||
SearchResponse response = queryAsUser(testUser, "finance:amount:[* TO 100]");
|
||||
+9
-6
@@ -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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
@@ -27,7 +27,6 @@ import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import org.alfresco.rest.exception.EmptyRestModelCollectionException;
|
||||
import org.alfresco.rest.search.RestInstanceModel;
|
||||
import org.alfresco.rest.search.RestShardInfoModel;
|
||||
import org.alfresco.rest.search.RestShardInfoModelCollection;
|
||||
@@ -41,10 +40,10 @@ import org.testng.annotations.Test;
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
*/
|
||||
public class ShardInfoTest extends AbstractSearchTest
|
||||
public class ShardInfoTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n})
|
||||
public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException
|
||||
public void getShardInfoWithAdminAuthority() throws JsonProcessingException
|
||||
{
|
||||
RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -62,7 +61,9 @@ public class ShardInfoTest extends AbstractSearchTest
|
||||
assertEquals(model.getMode(), "MASTER");
|
||||
assertEquals(model.getShardMethod(), "DB_ID");
|
||||
assertTrue(model.getHasContent());
|
||||
stores.contains(model.getStores());
|
||||
|
||||
assertTrue(stores.contains(model.getStores()));
|
||||
|
||||
List<RestShardModel> shards = model.getShards();
|
||||
assertNotNull(shards);
|
||||
RestShardModel shard = shards.iterator().next();
|
||||
@@ -71,7 +72,9 @@ public class ShardInfoTest extends AbstractSearchTest
|
||||
assertNotNull(instances);
|
||||
RestInstanceModel instance = instances.iterator().next();
|
||||
assertNotNull(instance);
|
||||
baseUrls.contains(instance.getBaseUrl());
|
||||
|
||||
assertTrue(baseUrls.contains(instance.getBaseUrl()));
|
||||
|
||||
// TODO: Ideally Solr Host and Port should be Parameterised
|
||||
assertEquals(instance.getHost(), "search");
|
||||
assertEquals(instance.getPort().intValue(), 8983);
|
||||
+18
-20
@@ -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.service.search.e2e.searchservices;
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
@@ -24,6 +24,7 @@ import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -54,7 +55,7 @@ import org.testng.annotations.Test;
|
||||
* @author Gethin James
|
||||
*
|
||||
*/
|
||||
public class StatsSearchTest extends AbstractSearchTest
|
||||
public class StatsSearchTest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
@@ -66,7 +67,7 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks errors with stats using Search api")
|
||||
public void searchWithBasicStats() throws Exception
|
||||
public void searchWithBasicStats()
|
||||
{
|
||||
SearchRequest query = carsQuery();
|
||||
Pagination pagination = new Pagination();
|
||||
@@ -77,12 +78,12 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
query.setStats(statsModels);
|
||||
query.setPaging(pagination);
|
||||
|
||||
SearchResponse response = query(query);
|
||||
query(query);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "stats field"));
|
||||
|
||||
statsModel1.setField("DBID");
|
||||
response = query(query);
|
||||
SearchResponse response = query(query);
|
||||
//8 metrics by default for a numeric field
|
||||
Set<String> metricTypes = assertStatsFacetedResponse(response, "DBID", 8);
|
||||
assertTrue(metricTypes.containsAll(Arrays.asList("missing", "countValues", "sum","min","max", "sumOfSquares", "mean", "stddev")));
|
||||
@@ -150,7 +151,7 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks errors with stats labels using Search api")
|
||||
public void searchWithStatsLabel() throws Exception
|
||||
public void searchWithStatsLabel()
|
||||
{
|
||||
SearchRequest query = carsQuery();
|
||||
Pagination pagination = new Pagination();
|
||||
@@ -170,7 +171,7 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks errors with stats fitlers using Search api")
|
||||
public void searchWithStatsFilters() throws Exception
|
||||
public void searchWithStatsFilters()
|
||||
{
|
||||
SearchRequest query = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
@@ -183,7 +184,7 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
statsModel1.setMax(false);
|
||||
statsModel1.setMissing(false);
|
||||
statsModels.add(statsModel1);
|
||||
query.setFilterQueries(new RestRequestFilterQueryModel("cars", Arrays.asList("justCars")));
|
||||
query.setFilterQueries(new RestRequestFilterQueryModel("cars", Collections.singletonList("justCars")));
|
||||
query.setStats(statsModels);
|
||||
SearchResponse response = query(query);
|
||||
assertStatsFacetedResponse(response, "creator", 1);
|
||||
@@ -192,7 +193,7 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
Map<?, ?> metricCount = (Map<?, ?>) countMetric.getValue();
|
||||
assertEquals(count, metricCount.get("countValues"));
|
||||
|
||||
statsModel1.setExcludeFilters(Arrays.asList("justCars"));
|
||||
statsModel1.setExcludeFilters(Collections.singletonList("justCars"));
|
||||
response = query(query);
|
||||
assertStatsFacetedResponse(response, "creator", 1);
|
||||
countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0);
|
||||
@@ -205,7 +206,7 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks errors with stats with Pivot using Search api")
|
||||
public void searchWithStatsAndMutlilevelPivot() throws Exception
|
||||
public void searchWithStatsAndMutlilevelPivot()
|
||||
{
|
||||
SearchRequest query = carsQuery();
|
||||
|
||||
@@ -233,8 +234,8 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
RestRequestPivotModel pivot2 = new RestRequestPivotModel();
|
||||
pivot2.setKey("aNumber");
|
||||
|
||||
pivotn.setPivots(Arrays.asList(pivot2));
|
||||
pivots.setPivots(Arrays.asList(pivotn));
|
||||
pivotn.setPivots(Collections.singletonList(pivot2));
|
||||
pivots.setPivots(Collections.singletonList(pivotn));
|
||||
pivotModelList.add(pivots);
|
||||
query.setPivots(pivotModelList);
|
||||
|
||||
@@ -261,7 +262,6 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
created.assertThat().field("label").is("created");
|
||||
//Another nested stats
|
||||
assertEquals(created.getBuckets().get(0).getMetrics().size(), 9, "Metrics are on the end of a pivot bucket");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
executionType = ExecutionType.REGRESSION,
|
||||
description = "Checks errors with stats with Pivot using Search api")
|
||||
public void searchWithStatsAndPivot() throws Exception
|
||||
public void searchWithStatsAndPivot()
|
||||
{
|
||||
SearchRequest query = carsQuery();
|
||||
|
||||
@@ -292,7 +292,7 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
RestRequestPivotModel pivotn = new RestRequestPivotModel();
|
||||
pivotn.setKey("numericId");
|
||||
|
||||
pivots.setPivots(Arrays.asList(pivotn));
|
||||
pivots.setPivots(Collections.singletonList(pivotn));
|
||||
pivotModelList.add(pivots);
|
||||
query.setPivots(pivotModelList);
|
||||
|
||||
@@ -314,10 +314,9 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
RestGenericFacetResponseModel statsFacet = response.getContext().getFacets().get(1);
|
||||
statsFacet.assertThat().field("type").is("stats");
|
||||
statsFacet.assertThat().field("label").is("numericId");
|
||||
|
||||
}
|
||||
|
||||
private Set<String> assertStatsFacetedResponse(SearchResponse response, String label, int metricsCount) throws Exception
|
||||
private Set<String> assertStatsFacetedResponse(SearchResponse response, String label, int metricsCount)
|
||||
{
|
||||
response.getContext().assertThat().field("facets").isNotEmpty();
|
||||
RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0);
|
||||
@@ -326,7 +325,6 @@ public class StatsSearchTest extends AbstractSearchTest
|
||||
RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0);
|
||||
List<RestGenericMetricModel> metrics = bucket.getMetrics();
|
||||
assertEquals(metrics.size(),metricsCount);
|
||||
return metrics.stream().map(m -> m.getType()).collect(Collectors.toSet());
|
||||
return metrics.stream().map(RestGenericMetricModel::getType).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -5,7 +5,7 @@
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
package org.alfresco.service.search.e2e;
|
||||
package org.alfresco.test.search.functional.searchServices.search.rm;
|
||||
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
|
||||
@@ -20,6 +20,7 @@ import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
|
||||
import org.alfresco.test.search.functional.searchServices.search.AbstractSearchServicesE2ETest;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
@@ -33,7 +34,7 @@ import org.testng.annotations.BeforeClass;
|
||||
*
|
||||
* @author Cristina Diaconu
|
||||
*/
|
||||
public class AbstractRMSearchServiceE2E extends AbstractSearchServiceE2E
|
||||
public abstract class AbstractRmE2ETest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
protected static final String FILE_PLAN_ALIAS = "-filePlan-";
|
||||
protected static final String RECORD_TYPE = "rma:record";
|
||||
@@ -57,7 +58,7 @@ public class AbstractRMSearchServiceE2E extends AbstractSearchServiceE2E
|
||||
protected RestAPIFactory restAPIFactory;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
public void rmDataPreparation() throws Exception
|
||||
{
|
||||
serverHealth.assertServerIsOnline();
|
||||
|
||||
+2
-4
@@ -5,11 +5,10 @@
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
package org.alfresco.service.search.e2e.rm.searchServices;
|
||||
package org.alfresco.test.search.functional.searchServices.search.rm;
|
||||
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
import org.alfresco.service.search.e2e.AbstractRMSearchServiceE2E;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
@@ -20,13 +19,12 @@ import org.testng.annotations.Test;
|
||||
*
|
||||
* @author Cristina Diaconu
|
||||
*/
|
||||
public class SearchServicesRME2ETest extends AbstractRMSearchServiceE2E
|
||||
public class SearchServicesRME2ETest extends AbstractRmE2ETest
|
||||
{
|
||||
|
||||
@Test(priority = 1, groups = { TestGroup.ASS_14 })
|
||||
public void testBasicSearch() throws Exception
|
||||
{
|
||||
|
||||
// Search for a folder name
|
||||
String query = "select * from cmis:folder where cmis:name='" + FOLDER1 + "'";
|
||||
|
||||
+13
-16
@@ -4,12 +4,12 @@
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
package org.alfresco.service.search.e2e.searchservices.tracker;
|
||||
package org.alfresco.test.search.functional.searchServices.search.tracker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.search.e2e.AbstractSearchServiceE2E;
|
||||
import org.alfresco.test.search.functional.AbstractE2EFunctionalTest;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.model.ContentModel;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
@@ -28,22 +28,19 @@ import org.testng.annotations.Test;
|
||||
* @author Alessandro Benedetti
|
||||
* @author Meenal Bhave
|
||||
*/
|
||||
public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E
|
||||
public class CascadingTrackerIntegrationTest extends AbstractE2EFunctionalTest
|
||||
{
|
||||
@Autowired
|
||||
protected DataContent dataContent;
|
||||
|
||||
private FolderModel parentFolder, grandParentFolder, childFolder;
|
||||
private FileModel childFile, grandChildFile;
|
||||
|
||||
|
||||
@Test(priority = 1, groups = { TestGroup.ASS_13 })
|
||||
public void testChildPathWhenParentRenamed() throws Exception
|
||||
{
|
||||
// Create Parent folder
|
||||
parentFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
FolderModel parentFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
|
||||
// Create a file in the parent folder
|
||||
childFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
FileModel childFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(PropertyIds.NAME, childFile.getName());
|
||||
@@ -66,11 +63,11 @@ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E
|
||||
|
||||
// Find nodes where Path with new folder name matches
|
||||
String parentQueryAfterRename = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + parentNewName + "\"";
|
||||
Boolean indexingInProgress = !waitForContent(parentQueryAfterRename, childFile.getName(), true);
|
||||
boolean indexingInProgress = !waitForContent(parentQueryAfterRename, childFile.getName(), true);
|
||||
|
||||
// Query using new parent name: Expect parent folder and child file
|
||||
int descendantCountOfNewName = query(parentQueryAfterRename).getPagination().getCount();
|
||||
Assert.assertEquals(descendantCountOfNewName, 2, String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s", indexingInProgress.toString(), parentQueryAfterRename));
|
||||
Assert.assertEquals(descendantCountOfNewName, 2, String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s", indexingInProgress, parentQueryAfterRename));
|
||||
|
||||
// Query using old parent name: Expect no descendant after rename
|
||||
int descendantCountOfOriginalName = query(parentQuery).getPagination().getCount();
|
||||
@@ -81,13 +78,13 @@ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E
|
||||
public void testGrandChildPathWhenGrandParentRenamed() throws Exception
|
||||
{
|
||||
// Create grand parent folder
|
||||
grandParentFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
FolderModel grandParentFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
||||
|
||||
// Create child folder
|
||||
childFolder = dataContent.usingUser(testUser).usingResource(grandParentFolder).createFolder();
|
||||
FolderModel childFolder = dataContent.usingUser(testUser).usingResource(grandParentFolder).createFolder();
|
||||
|
||||
// Create grand child file
|
||||
grandChildFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
FileModel grandChildFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(PropertyIds.NAME, grandChildFile.getName());
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
|
||||
@@ -110,11 +107,11 @@ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E
|
||||
|
||||
// Find nodes where Path with new folder name matches
|
||||
String parentQueryAfterRename = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + grandParentNewName + "\"";
|
||||
Boolean indexingInProgress = !waitForContent(parentQueryAfterRename, grandChildFile.getName(), true);
|
||||
boolean indexingInProgress = !waitForContent(parentQueryAfterRename, grandChildFile.getName(), true);
|
||||
|
||||
// Query using new parent name: Expect grand parent, child folder, grand child file
|
||||
int descendantCountOfNewName = query(parentQueryAfterRename).getPagination().getCount();
|
||||
Assert.assertEquals(descendantCountOfNewName, 3, String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s", indexingInProgress.toString(), parentQueryAfterRename));
|
||||
Assert.assertEquals(descendantCountOfNewName, 3, String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s", indexingInProgress, parentQueryAfterRename));
|
||||
|
||||
// Query using old parent name: Expect no descendant after rename
|
||||
int descendantCountOfOriginalName = query(parentQuery).getPagination().getCount();
|
||||
+8
-8
@@ -12,7 +12,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.service.search.e2e.searchservices.solr;
|
||||
package org.alfresco.test.search.functional.searchServices.solr;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.json.JsonArrayBuilder;
|
||||
|
||||
import org.alfresco.rest.core.JsonBodyGenerator;
|
||||
import org.alfresco.rest.model.RestTextResponse;
|
||||
import org.alfresco.service.search.e2e.searchservices.AbstractSearchTest;
|
||||
import org.alfresco.test.search.functional.searchServices.search.AbstractSearchServicesE2ETest;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -32,9 +32,9 @@ import org.testng.annotations.Test;
|
||||
*
|
||||
* @author Meenal Bhave
|
||||
*/
|
||||
public class SearchSolrAPITest extends AbstractSearchTest
|
||||
public class SearchSolrAPITest extends AbstractSearchServicesE2ETest
|
||||
{
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 01)
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 1)
|
||||
public void testGetSolrConfig() throws Exception
|
||||
{
|
||||
RestTextResponse response = restClient.authenticateUser(adminUserModel).withSolrAPI().getConfig();
|
||||
@@ -54,7 +54,7 @@ public class SearchSolrAPITest extends AbstractSearchTest
|
||||
// restClient.onResponse().assertThat().body("config.requestHandler",Matchers.notNullValue());
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 02)
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 2)
|
||||
public void testEditSolrConfig() throws Exception
|
||||
{
|
||||
String expectedError = "solrconfig editing is not enabled due to disable.configEdit";
|
||||
@@ -86,7 +86,7 @@ public class SearchSolrAPITest extends AbstractSearchTest
|
||||
// response.assertThat().body("error.msg", Matchers.contains(expectedError));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 03)
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 3)
|
||||
public void testGetSolrConfigOverlay() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigOverlay();
|
||||
@@ -95,7 +95,7 @@ public class SearchSolrAPITest extends AbstractSearchTest
|
||||
restClient.onResponse().assertThat().content(Matchers.containsString("overlay"));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 04)
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 4)
|
||||
public void testGetSolrConfigParams() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigParams();
|
||||
@@ -104,7 +104,7 @@ public class SearchSolrAPITest extends AbstractSearchTest
|
||||
restClient.onResponse().assertThat().content(Matchers.containsString("response"));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 05)
|
||||
@Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 5)
|
||||
public void testGetSolrSelect() throws Exception
|
||||
{
|
||||
String queryParams = "{!xmlparser v='<!DOCTYPE a SYSTEM \"http://localhost:4444/executed\"><a></a>'}";
|
||||
+3
-4
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.service.search.backup;
|
||||
package org.alfresco.test.search.nonFunctional.backup;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
@@ -28,8 +28,8 @@ import com.jayway.restassured.RestAssured;
|
||||
|
||||
@Configuration
|
||||
@ContextConfiguration("classpath:alfresco-search-e2e-context.xml")
|
||||
public abstract class AbstractBackupTest extends AbstractTestNGSpringContextTests {
|
||||
|
||||
public abstract class AbstractBackupE2ETest extends AbstractTestNGSpringContextTests
|
||||
{
|
||||
protected SiteModel testSite = new SiteModel("siteForBackupTesting");
|
||||
protected FolderModel folder = new FolderModel("folderBackedUp");
|
||||
protected FileModel file = new FileModel("fileBackedUp.txt", FileType.TEXT_PLAIN, "uber important file");
|
||||
@@ -74,7 +74,6 @@ public abstract class AbstractBackupTest extends AbstractTestNGSpringContextTest
|
||||
* {"responseHeader":{"status":0,"QTime":5},"exception":"org.apache.solr.common.SolrException:org.apache.solr.common.SolrException:
|
||||
* Directory does not exist:
|
||||
* file:///nop/snapshot.20190212152339023","status":"OK"}
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
protected RestHtmlResponse executeSolrBackupRequest(String core, String dockerVolume, int numberToKeep)
|
||||
throws InterruptedException {
|
||||
+4
-5
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.service.search.backup;
|
||||
package org.alfresco.test.search.nonFunctional.backup;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -9,18 +9,17 @@ import org.testng.annotations.Test;
|
||||
* @author Paul Brodner
|
||||
*
|
||||
*/
|
||||
public class SearchServiceOnBackupTests extends AbstractBackupTest {
|
||||
|
||||
public class SearchServicesOnBackupTests extends AbstractBackupE2ETest
|
||||
{
|
||||
@Test
|
||||
public void deleteBackupFolder() throws Exception {
|
||||
|
||||
/**
|
||||
/*
|
||||
* Site: siteForBackupTesting
|
||||
* > documentLibrary
|
||||
* | siteForBackupTesting
|
||||
* |- fileBackedUp.txt
|
||||
*/
|
||||
|
||||
cmisWrapper.authenticateUser(dataSite.getAdminUser())
|
||||
.usingSite(testSite).setLastContentModel(folder);
|
||||
cmisWrapper.deleteFolderTree().and().assertThat().doesNotExistInRepo();
|
||||
+3
-4
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.service.search.backup;
|
||||
package org.alfresco.test.search.nonFunctional.backup;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -9,9 +9,8 @@ import org.testng.annotations.Test;
|
||||
* @author Paul Brodner
|
||||
*
|
||||
*/
|
||||
public class SearchServicePostBackupTests extends AbstractBackupTest {
|
||||
|
||||
|
||||
public class SearchServicesPostBackupTests extends AbstractBackupE2ETest
|
||||
{
|
||||
@Test
|
||||
public void testIFBackupDataExist() throws Exception {
|
||||
cmisWrapper.authenticateUser(dataSite.getAdminUser())
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.service.search.backup;
|
||||
package org.alfresco.test.search.nonFunctional.backup;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.StringContains.containsString;
|
||||
@@ -14,8 +14,8 @@ import org.testng.annotations.Test;
|
||||
* @author Paul Brodner
|
||||
*
|
||||
*/
|
||||
public class SearchServicePreBackupTests extends AbstractBackupTest {
|
||||
|
||||
public class SearchServicesPreBackupTests extends AbstractBackupE2ETest
|
||||
{
|
||||
/**
|
||||
* {"responseHeader":{"status":0,"QTime":1},"exception":"org.apache.solr.common.SolrException:org.apache.solr.common.SolrException:
|
||||
* Directory does not exist:
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.service.search.upgrade;
|
||||
package org.alfresco.test.search.nonFunctional.upgrade;
|
||||
|
||||
import org.alfresco.cmis.CmisWrapper;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
@@ -12,13 +12,13 @@ import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
||||
/**
|
||||
* @author Paul Brodner
|
||||
* We can use this class for both SearchService and InsightEngine
|
||||
* We can use this class for both SearchService and InsightEngine.
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
@ContextConfiguration("classpath:alfresco-search-e2e-context.xml")
|
||||
public abstract class UpgradeTestCase extends AbstractTestNGSpringContextTests {
|
||||
|
||||
public abstract class AbstractUpgradeE2ETest extends AbstractTestNGSpringContextTests
|
||||
{
|
||||
@Autowired
|
||||
protected ServerHealth serverHealth;
|
||||
|
||||
@@ -41,4 +41,4 @@ public abstract class UpgradeTestCase extends AbstractTestNGSpringContextTests {
|
||||
{
|
||||
serverHealth.assertServerIsOnline();
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package org.alfresco.service.search.upgrade;
|
||||
package org.alfresco.test.search.nonFunctional.upgrade;
|
||||
|
||||
import org.alfresco.utility.LogFactory;
|
||||
import org.alfresco.utility.Utility;
|
||||
@@ -9,8 +9,8 @@ import org.alfresco.utility.model.QueryModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class SearchServiceUpgradeTests extends UpgradeTestCase {
|
||||
|
||||
public class SearchServiceUpgradeTests extends AbstractUpgradeE2ETest
|
||||
{
|
||||
private static Logger LOG = LogFactory.getLogger();
|
||||
|
||||
@Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getAllData")
|
||||
@@ -7,39 +7,6 @@
|
||||
<listener class-name="org.alfresco.utility.report.HtmlReportListener"/>
|
||||
</listeners>
|
||||
|
||||
<test name="SearchFaceted">
|
||||
<classes>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.FacetIntervalSearchTest"/>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.FacetRangeSearchTest"/>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.PivotFacetedSearchTest"/>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.FacetedSearchTest"/>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.FacetFieldsSearchTest"/>
|
||||
</classes>
|
||||
</test>
|
||||
|
||||
<test name="SearchFeatures">
|
||||
<classes>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.FingerPrintTest"/>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.SearchAPATHTest"/>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.SearchHighLightTest"/>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.SearchSpellCheckTest"/>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.SearchTest"/>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.StatsSearchTest"/>
|
||||
</classes>
|
||||
</test>
|
||||
|
||||
<test name="SearchPrivateAPIs">
|
||||
<classes>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.ShardInfoTest"/>
|
||||
</classes>
|
||||
</test>
|
||||
|
||||
<test name="SolrAPIs">
|
||||
<classes>
|
||||
<class name="org.alfresco.service.search.e2e.searchservices.solr.SearchSolrAPITest" />
|
||||
</classes>
|
||||
</test>
|
||||
|
||||
<test name="Smoke">
|
||||
<groups>
|
||||
<run>
|
||||
@@ -49,7 +16,7 @@
|
||||
</run>
|
||||
</groups>
|
||||
<classes>
|
||||
<class name="org.alfresco.service.search.unit.SetupTest" />
|
||||
<class name="org.alfresco.test.search.functional.searchServices.sanity.SetupTest" />
|
||||
</classes>
|
||||
</test>
|
||||
|
||||
@@ -63,8 +30,10 @@
|
||||
</run>
|
||||
</groups>
|
||||
<packages>
|
||||
<package name="org.alfresco.service.search.e2e.searchservices" />
|
||||
<package name="org.alfresco.service.search.e2e.searchservices.tracker" />
|
||||
<package name="org.alfresco.test.search.functional.searchServices.*">
|
||||
<exclude name="org.alfresco.test.search.functional.searchServices.cmis"/>
|
||||
<exclude name="org.alfresco.test.search.functional.searchServices.search.rm"/>
|
||||
</package>
|
||||
</packages>
|
||||
<classes>
|
||||
</classes>
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
http://www.springframework.org/schema/data/mongo
|
||||
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
<context:annotation-config />
|
||||
<context:component-scan base-package="org.alfresco" />
|
||||
<import resource="classpath:dataprep-context.xml" />
|
||||
<import resource="classpath*:alfresco-tester-context.xml" />
|
||||
</beans>
|
||||
|
||||
|
||||
@@ -2,20 +2,14 @@
|
||||
|
||||
<suite name="CMISSearchSuite" verbose="6" preserve-order="true">
|
||||
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.utility.report.log.LogsListener"/>
|
||||
<listener class-name="org.alfresco.utility.report.HtmlReportListener"/>
|
||||
</listeners>
|
||||
|
||||
<test name="Search">
|
||||
<classes>
|
||||
<class name="org.alfresco.service.search.cmis.SolrSearchByAspectTests" />
|
||||
<class name="org.alfresco.service.search.cmis.SolrSearchByIdTests" />
|
||||
<class name="org.alfresco.service.search.cmis.SolrSearchByPathTests" />
|
||||
<class name="org.alfresco.service.search.cmis.SolrSearchByPropertyTests" />
|
||||
<class name="org.alfresco.service.search.cmis.SolrSearchInFolderTests" />
|
||||
<class name="org.alfresco.service.search.cmis.SolrSearchInTreeTests" />
|
||||
<class name="org.alfresco.service.search.cmis.SorlSearchSimpleQueryTests" />
|
||||
</classes>
|
||||
<packages>
|
||||
<package name="org.alfresco.test.search.functional.searchServices.cmis" />
|
||||
</packages>
|
||||
</test>
|
||||
|
||||
</suite>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<classes>
|
||||
<!-- execute this before backup -->
|
||||
<class
|
||||
name="org.alfresco.service.search.backup.SearchServiceOnBackupTests" />
|
||||
name="org.alfresco.test.search.nonFunctional.backup.SearchServicesOnBackupTests" />
|
||||
</classes>
|
||||
</test>
|
||||
</suite>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<classes>
|
||||
<!-- execute this after backup -->
|
||||
<class
|
||||
name="org.alfresco.service.search.backup.SearchServicePostBackupTests" />
|
||||
name="org.alfresco.test.search.nonFunctional.backup.SearchServicesPostBackupTests" />
|
||||
</classes>
|
||||
</test>
|
||||
</suite>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<!-- this class depends on data produce and validated by search-pre-upgrade-suite.xml.
|
||||
Execute it after upgrading product to new version -->
|
||||
<class
|
||||
name="org.alfresco.service.search.upgrade.SearchServiceUpgradeTests">
|
||||
name="org.alfresco.test.search.nonFunctional.upgrade.SearchServiceUpgradeTests">
|
||||
<methods>
|
||||
<include name="checkDataIsSearchable" />
|
||||
</methods>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<classes>
|
||||
<!-- execute this before backup -->
|
||||
<class
|
||||
name="org.alfresco.service.search.backup.SearchServicePreBackupTests" />
|
||||
name="org.alfresco.test.search.nonFunctional.backup.SearchServicesPreBackupTests" />
|
||||
</classes>
|
||||
</test>
|
||||
</suite>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<classes>
|
||||
<!-- execute this before upgrade -->
|
||||
<class
|
||||
name="org.alfresco.service.search.upgrade.SearchServiceUpgradeTests">
|
||||
name="org.alfresco.test.search.nonFunctional.upgrade.SearchServiceUpgradeTests">
|
||||
<methods>
|
||||
<include name="prepareData" />
|
||||
<include name="checkDataIsSearchable" />
|
||||
|
||||
Reference in New Issue
Block a user