mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-10-08 14:51:20 +00:00
Moved CMIS Search Score tests from alfresco-tas-cmis-test project.
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
<description>Test Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share</description>
|
||||
<properties>
|
||||
<tas.rest.api.version>6.0.0.3</tas.rest.api.version>
|
||||
<tas.cmis.api.version>6.0.0.0</tas.cmis.api.version>
|
||||
<tas.utility.version>2.0.1</tas.utility.version>
|
||||
<tas.cmis.api.version>6.0.0.1</tas.cmis.api.version>
|
||||
<tas.utility.version>2.0.9</tas.utility.version>
|
||||
<rm.version>2.6.0</rm.version>
|
||||
<suiteXmlFile>src/test/resources/SearchSuite.xml</suiteXmlFile>
|
||||
<test.exclude></test.exclude>
|
||||
@@ -54,12 +54,24 @@
|
||||
<artifactId>restapi-test</artifactId>
|
||||
<version>${tas.rest.api.version}</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>cmis-test</artifactId>
|
||||
<version>${tas.cmis.api.version}</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
@@ -73,6 +85,12 @@
|
||||
<version>${rm.version}</version>
|
||||
<classifier>tests</classifier>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- alfresco tester settings -->
|
||||
<dependency>
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -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 SorlSearchScoreQueryTests extends AbstractCmisE2ETest
|
||||
{
|
||||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(SorlSearchScoreQueryTests.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.CMIS, 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.CMIS, 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.CMIS, 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.CMIS, 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.CMIS, 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!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
30
e2e-test/src/test/resources/testdata/search-score-function.xml
vendored
Normal file
30
e2e-test/src/test/resources/testdata/search-score-function.xml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="https://gitlab.alfresco.com/tas/tas-namespaces/raw/master/input-test-data.xsd">
|
||||
<users>
|
||||
<user id="userSearchProperties" name="userSearchProperties" password="password" />
|
||||
</users>
|
||||
|
||||
<sites>
|
||||
<site name="siteSearchScoreFunction" createdBy="userSearchProperties" visibility="PUBLIC">
|
||||
<folders>
|
||||
<folder name="test-folder" createdBy="userSearchProperties">
|
||||
<files>
|
||||
<file name="test-1.txt" createdBy="userSearchProperties">
|
||||
<content>Quidditch</content>
|
||||
</file>
|
||||
<file name="test-2.txt" createdBy="userSearchProperties">
|
||||
<content>Quidditch Quidditch</content>
|
||||
</file>
|
||||
<file name="test-3.txt" createdBy="userSearchProperties">
|
||||
<content>Quidditch Quidditch Quidditch</content>
|
||||
</file>
|
||||
<file name="no-test.txt" createdBy="userSearchProperties">
|
||||
<content>Some other words</content>
|
||||
</file>
|
||||
</files>
|
||||
</folder>
|
||||
</folders>
|
||||
</site>
|
||||
</sites>
|
||||
|
||||
</testData>
|
Reference in New Issue
Block a user