diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml
index f6f0c8256..12f4bfbb7 100644
--- a/e2e-test/pom.xml
+++ b/e2e-test/pom.xml
@@ -12,8 +12,8 @@
Test Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share
6.0.0.3
- 6.0.0.0
- 2.0.1
+ 6.0.0.1
+ 2.0.10
2.6.0
src/test/resources/SearchSuite.xml
@@ -22,6 +22,7 @@
${java.version}
${java.version}
3.8.0
+ 2.7.7
@@ -54,12 +55,24 @@
restapi-test
${tas.rest.api.version}
test
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
org.alfresco.tas
cmis-test
${tas.cmis.api.version}
test
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
org.alfresco
@@ -67,12 +80,23 @@
${rm.version}
test
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.databind.version}
+
org.alfresco
alfresco-rm-automation-community-rest-api
${rm.version}
tests
test
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
diff --git a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/AbstractCmisE2ETest.java b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/AbstractCmisE2ETest.java
index f301a63ec..89c190bc3 100644
--- a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/AbstractCmisE2ETest.java
+++ b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/AbstractCmisE2ETest.java
@@ -1,13 +1,13 @@
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.cmis.CmisProperties;
+import org.alfresco.cmis.CmisWrapper;
import org.alfresco.test.search.functional.searchServices.search.AbstractSearchServicesE2ETest;
-import org.alfresco.utility.LogFactory;
+import org.alfresco.utility.Utility;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@@ -25,7 +25,7 @@ import org.testng.annotations.BeforeMethod;
@Scope(value = "prototype")
public abstract class AbstractCmisE2ETest extends AbstractSearchServicesE2ETest
{
- private static Logger LOG = LogFactory.getLogger();
+ private static Logger LOGGER = LoggerFactory.getLogger(AbstractCmisE2ETest.class);
@Autowired
protected CmisWrapper cmisApi;
@@ -38,17 +38,50 @@ public abstract class AbstractCmisE2ETest extends AbstractSearchServicesE2ETest
@BeforeMethod(alwaysRun = true)
public void showStartTestInfo(Method method)
{
- LOG.info(String.format("*** STARTING Test: [%s] ***", method.getName()));
+ LOGGER.info(String.format("*** STARTING Test: [%s] ***", method.getName()));
}
@AfterMethod(alwaysRun = true)
public void showEndTestInfo(Method method)
{
- LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName()));
+ LOGGER.info(String.format("*** ENDING Test: [%s] ***", method.getName()));
}
public Integer getSolrWaitTimeInSeconds()
{
return cmisProperties.envProperty().getSolrWaitTimeInSeconds();
}
+
+ /**
+ * Repeat SOLR Query till results count returns expectedCountResults
+ * @param query CMIS Query to be executed
+ * @param expectedCountResults Number of results expected
+ * @return true when results count is equals to expectedCountResults
+ * @throws Exception
+ */
+ protected boolean waitForIndexing(String query, long expectedCountResults) throws Exception
+ {
+
+ for (int searchCount = 1; searchCount <= 3; searchCount++)
+ {
+
+ try
+ {
+ cmisApi.withQuery(query).assertResultsCount().equals(expectedCountResults);
+ return true;
+ }
+ catch (AssertionError ae)
+ {
+ LOGGER.debug(ae.toString());
+ }
+
+
+ Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing");
+
+ }
+
+ return false;
+ }
+
+
}
diff --git a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/SolrSearchScoreQueryTests.java b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/SolrSearchScoreQueryTests.java
new file mode 100644
index 000000000..5df0abd22
--- /dev/null
+++ b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/SolrSearchScoreQueryTests.java
@@ -0,0 +1,195 @@
+package org.alfresco.test.search.functional.searchServices.cmis;
+
+import java.math.BigDecimal;
+
+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.TestGroup;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+/**
+ * Testing SCORE function queries to solve issues related to
+ * https://issues.alfresco.com/jira/browse/ACE-2479
+ *
+ * @author aborroy
+ *
+ */
+public class SolrSearchScoreQueryTests extends AbstractCmisE2ETest
+{
+
+ private static Logger LOGGER = LoggerFactory.getLogger(SolrSearchScoreQueryTests.class);
+ private XMLTestData testData;
+
+ @AfterClass(alwaysRun = true)
+ public void cleanupEnvironment()
+ {
+ if (testData != null)
+ {
+ testData.cleanup(dataContent);
+ }
+ else
+ {
+ LOGGER.warn("testData is inexplicably null - skipping clean up.");
+ }
+ }
+
+ /* These tests does not require AbstractSearchServicesE2ETest common tests,
+ * as it's focused on testing scoring function features
+ * @see org.alfresco.test.search.functional.searchServices.search.AbstractSearchServicesE2ETest#searchServicesDataPreparation()
+ */
+ @Override
+ public void searchServicesDataPreparation() throws Exception
+ {
+ }
+
+ /* These tests does not require common data preparation from AbstractE2EFunctionalTest
+ * as it's including every test data required in search-score-funtion.xml
+ * @see org.alfresco.test.search.functional.AbstractE2EFunctionalTest#dataPreparation()
+ */
+ @Override
+ public void dataPreparation() throws Exception
+ {
+ }
+
+ @Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getAllData")
+ @XMLDataConfig(file = "src/test/resources/testdata/search-score-function.xml")
+ public void prepareDataForScoreSearch(XMLTestData testData) throws Exception
+ {
+ this.testData = testData;
+ this.testData.createUsers(dataUser);
+ this.testData.createSitesStructure(dataSite, dataContent, dataUser);
+ cmisApi.authenticateUser(dataUser.getCurrentUser());
+
+ }
+
+ /**
+ * Verify that results are ordered
+ * @throws Exception
+ */
+ @Test(groups = { TestGroup.ASS_14, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch")
+ public void scoreQueryOrdered() throws Exception
+ {
+
+ String query = "SELECT cmis:objectId, SCORE() AS orderCriteria "
+ + "FROM cmis:document "
+ + "WHERE CONTAINS('Quidditch') "
+ + "ORDER BY orderCriteria";
+
+ if (waitForIndexing(query, 3))
+ {
+ cmisApi
+ .withQuery(query)
+ .assertColumnIsOrdered().isOrderedAsc("orderCriteria");
+ }
+ else
+ {
+ throw new AssertionError("Wait for indexing has failed!");
+ }
+
+ }
+
+ /**
+ * Verify that results are inverse ordered
+ * @throws Exception
+ */
+ @Test(groups = { TestGroup.ASS_14, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch")
+ public void scoreQueryOrderedDesc() throws Exception
+ {
+
+ String query = "SELECT cmis:objectId, SCORE() AS orderCriteria "
+ + "FROM cmis:document "
+ + "WHERE CONTAINS('Quidditch') "
+ + "ORDER BY orderCriteria DESC";
+
+ if (waitForIndexing(query, 3))
+ {
+ cmisApi
+ .withQuery(query).assertColumnIsOrdered().isOrderedDesc("orderCriteria");
+ }
+ else
+ {
+ throw new AssertionError("Wait for indexing has failed!");
+ }
+
+ }
+
+ /**
+ * Verify that all SCORE results are between 0 and 1
+ * @throws Exception
+ */
+ @Test(groups = { TestGroup.ASS_14, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch")
+ public void scoreQueryInRange() throws Exception
+ {
+
+ String query = "SELECT cmis:objectId, SCORE() "
+ + "FROM cmis:document "
+ + "WHERE CONTAINS('Quidditch')";
+
+ if (waitForIndexing(query, 3))
+ {
+ cmisApi
+ .withQuery(query)
+ .assertColumnValuesRange().isReturningValuesInRange("SEARCH_SCORE", BigDecimal.ZERO, BigDecimal.ONE);
+ }
+ else
+ {
+ throw new AssertionError("Wait for indexing has failed!");
+ }
+
+ }
+
+ /**
+ * Verify that all SCORE results are between 0 and 1
+ * @throws Exception
+ */
+ @Test(groups = { TestGroup.ASS_14, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch")
+ public void scoreQueryAliasInRange() throws Exception
+ {
+
+ String query = "SELECT cmis:objectId, SCORE() AS orderCriteria "
+ + "FROM cmis:document "
+ + "WHERE CONTAINS('Quidditch')";
+
+ if (waitForIndexing(query, 3))
+ {
+ cmisApi
+ .withQuery(query)
+ .assertColumnValuesRange().isReturningValuesInRange("orderCriteria", BigDecimal.ZERO, BigDecimal.ONE);
+ }
+ else
+ {
+ throw new AssertionError("Wait for indexing has failed!");
+ }
+
+ }
+
+ /**
+ * Verify that SCORE is valid name for an alias
+ * Currently only supported with double quotes
+ * @throws Exception
+ */
+ @Test(groups = { TestGroup.ASS_14, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch")
+ public void scoreQueryScoreAsAlias() throws Exception
+ {
+
+ String query = "SELECT cmis:objectId, SCORE() AS \"score\" "
+ + "FROM cmis:document "
+ + "WHERE CONTAINS('Quidditch')";
+
+ if (waitForIndexing(query, 3))
+ {
+ cmisApi
+ .withQuery(query).assertResultsCount().equals(3);
+ }
+ else
+ {
+ throw new AssertionError("Wait for indexing has failed!");
+ }
+
+ }
+
+}
diff --git a/e2e-test/src/test/resources/testdata/search-score-function.xml b/e2e-test/src/test/resources/testdata/search-score-function.xml
new file mode 100644
index 000000000..9c9fdc33d
--- /dev/null
+++ b/e2e-test/src/test/resources/testdata/search-score-function.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Quidditch
+
+
+ Quidditch Quidditch
+
+
+ Quidditch Quidditch Quidditch
+
+
+ Some other words
+
+
+
+
+
+
+
+