diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/AbstractSearchServiceE2E.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/AbstractSearchServiceE2E.java
index 5334bb8ab..1ebf33835 100644
--- a/e2e-test/src/test/java/org/alfresco/service/search/e2e/AbstractSearchServiceE2E.java
+++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/AbstractSearchServiceE2E.java
@@ -11,11 +11,13 @@ import org.alfresco.cmis.CmisWrapper;
import org.alfresco.dataprep.ContentService;
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.RestRequestQueryModel;
import org.alfresco.rest.search.SearchNodeModel;
import org.alfresco.rest.search.SearchRequest;
import org.alfresco.rest.search.SearchResponse;
+import org.alfresco.rest.search.SearchSqlRequest;
import org.alfresco.utility.LogFactory;
import org.alfresco.utility.TasProperties;
import org.alfresco.utility.Utility;
@@ -29,6 +31,7 @@ import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.network.ServerHealth;
import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.Session;
+import org.hamcrest.Matchers;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -38,6 +41,8 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import lombok.Getter;
+
+import static java.util.Optional.ofNullable;
import static lombok.AccessLevel.PROTECTED;
import java.util.List;
@@ -257,6 +262,33 @@ 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
*
diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/CaseSensitivityInFieldsNamesTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/CaseSensitivityInFieldsNamesTest.java
new file mode 100644
index 000000000..2a0aedae2
--- /dev/null
+++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/CaseSensitivityInFieldsNamesTest.java
@@ -0,0 +1,257 @@
+/*
+ * 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.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:
+ *
+ *
+ * - 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.
+ *
+ * -
+ * When a field is part of the predicate (e.g. WHERE a=somevalue) the case doesn't matter
+ *
+ * -
+ * 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).
+ *
+ *
+ *
+ * @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 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 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 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 fieldNames = asList("expense_Currency", "EXPENSE_CURRENCY", "ExPeNsE_CurrENCY");
+ List 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 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 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 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;
+ }
+}
\ No newline at end of file
diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SelectStarTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SelectStarTest.java
index d21bb6b0b..a9b96a00a 100644
--- a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SelectStarTest.java
+++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SelectStarTest.java
@@ -15,8 +15,6 @@ import java.util.Date;
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.LogFactory;
import org.alfresco.utility.data.DataContent;
@@ -27,10 +25,8 @@ 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.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -231,7 +227,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 1, groups = { TestGroup.INSIGHT_11 })
- public void testTextField() throws Exception
+ public void testTextField()
{
testSqlQuery("select * from alfresco where `expense:Location` = 'london'", 2);
testSqlQuery("select * from alfresco where `expense:Location` >= 'London'", 3);
@@ -241,7 +237,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
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 TYPE = 'expense:expenseReport'", 4);
testSqlQuery("select * from alfresco where `expense:Location` not in ('Paris', 'Reading') and `expense:Location` in ('london')", 2);
// Field name with _
@@ -250,7 +246,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
// TODO: Enable when fixed: Bug: Search-1457
@Test(priority = 2, groups = { TestGroup.INSIGHT_11 }, enabled = false)
- public void testTextFieldNullValues() throws Exception
+ 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
@@ -263,7 +259,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 3, groups = { TestGroup.INSIGHT_11 })
- public void testMLTextField() throws Exception
+ public void testMLTextField()
{
testSqlQuery("select * from alfresco where `expense:Notes` = 'London is a busy'", 2);
testSqlQuery("select * from alfresco where `expense:Notes` = 'london'", 2);
@@ -278,7 +274,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 4, groups = { TestGroup.INSIGHT_11 }, enabled=false)
- public void testMLTextFieldNullValues() throws Exception
+ 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
@@ -291,7 +287,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 5, groups = { TestGroup.INSIGHT_11 })
- public void testIntegerField() throws Exception
+ public void testIntegerField()
{
testSqlQuery("select * from alfresco where `expense:id` >= '10'", 3);
testSqlQuery("select * from alfresco where `expense:id` > 10", 2);
@@ -308,7 +304,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 6, groups = { TestGroup.INSIGHT_11 }, enabled = false)
- public void testIntegerFieldNullValues() throws Exception
+ 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);
@@ -321,7 +317,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 7, groups = { TestGroup.INSIGHT_11 })
- public void testLongField() throws Exception
+ public void testLongField()
{
testSqlQuery("select * from alfresco where `expense:EmpNo` >= '000001'", 3);
testSqlQuery("select * from alfresco where `expense:EmpNo` >=000001", 3);
@@ -337,7 +333,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 8, groups = { TestGroup.INSIGHT_11 }, enabled=false)
- public void testLongFieldNullValues() throws Exception
+ 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
@@ -350,7 +346,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 9, groups = { TestGroup.INSIGHT_11 })
- public void testDoubleField() throws Exception
+ public void testDoubleField()
{
testSqlQuery("select * from alfresco where `expense:ExchangeRate` >= '12'", 2);
testSqlQuery("select * from alfresco where `expense:ExchangeRate` >= 12.5", 1);
@@ -365,7 +361,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 10, groups = { TestGroup.INSIGHT_11 }, enabled = false)
- public void testDoubleFieldNullValues() throws Exception
+ 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
@@ -374,12 +370,12 @@ public class SelectStarTest extends AbstractSearchServiceE2E
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);
+ testSqlQuery("select * from alfresco where `expense:ExchangeRate` is not null and TYPE = 'expense:expenseReport'", 3);
}
// TODO: Enable the test when fixed: Bug: Search-1455
@Test(priority = 11, groups = { TestGroup.INSIGHT_11 }, enabled = false)
- public void testFloatField() throws Exception
+ public void testFloatField()
{
testSqlQuery("select * from alfresco where `expense:amount` >= '60.50'", 2);
testSqlQuery("select * from alfresco where `expense:amount` >= 60", 3);
@@ -393,7 +389,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 12, groups = { TestGroup.INSIGHT_11 }, enabled=false)
- public void testFloatFieldNullValues() throws Exception
+ public void testFloatFieldNullValues()
{
testSqlQuery("select * from alfresco where `expense:amount` >= '60.50'", 2);
testSqlQuery("select * from alfresco where `expense:amount` >= 60", 3);
@@ -406,7 +402,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 13, groups = { TestGroup.INSIGHT_11 })
- public void testBooleanField() throws Exception
+ public void testBooleanField()
{
testSqlQuery("select * from alfresco where `expense:Approved` = 'true'", 2);
testSqlQuery("select * from alfresco where `expense:Approved` = 'false'", 2);
@@ -417,7 +413,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 14, groups = { TestGroup.INSIGHT_11 }, enabled = false)
- public void testBooleanFieldNullValues() throws Exception
+ 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
@@ -430,7 +426,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 15, groups = { TestGroup.INSIGHT_11 })
- public void testDateField() throws Exception
+ public void testDateField()
{
testSqlQuery("select * from alfresco where `expense:ExpenseDate` <'" + DT_NOW + "'", 2);
testSqlQuery("select * from alfresco where `expense:ExpenseDate` < '" + DT_NOW + "'", 2);
@@ -456,7 +452,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 16, groups = { TestGroup.INSIGHT_11 }, enabled = false)
- public void testDateFieldNullValues() throws Exception
+ 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
@@ -466,10 +462,10 @@ public class SelectStarTest extends AbstractSearchServiceE2E
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() throws Exception
+ 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);
@@ -488,7 +484,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 18, groups = { TestGroup.INSIGHT_11 }, enabled = false)
- public void testDateTimeFieldNullValues() throws Exception
+ 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
@@ -502,7 +498,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
// TODO: Search-1477: Enable, Uncomment Tests when bug is fixed
@Test(priority = 19, groups = { TestGroup.INSIGHT_11 }, enabled = false)
- public void testVirtualTimeDimensions() throws Exception
+ public void testVirtualTimeDimensions()
{
testSqlQuery("select * from alfresco where TYPE = 'expense:expenseReport' order by cm_created desc", 5);
@@ -526,7 +522,7 @@ public class SelectStarTest extends AbstractSearchServiceE2E
}
@Test(priority = 20, groups = { TestGroup.INSIGHT_11 })
- public void testFieldNameWithUnderscore() throws Exception
+ 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);
@@ -543,23 +539,4 @@ public class SelectStarTest extends AbstractSearchServiceE2E
// + " group by expense_Recorded_At_year"
// + " order by expense_Recorded_At desc", 5);
}
-
- private RestResponse testSqlQuery(String sql, Integer entriesCount) throws Exception
- {
- SearchSqlRequest sqlRequest = new SearchSqlRequest();
- sqlRequest.setSql(sql);
-
- RestResponse response = restClient.authenticateUser(testUser).withSearchSqlAPI().searchSql(sqlRequest);
-
- restClient.assertStatusCodeIs(HttpStatus.OK);
-
- if (entriesCount != null)
- {
- restClient.onResponse().assertThat().body("list.pagination.count", Matchers.equalTo(entriesCount));
- // To check the label: Use the json path in body: list.entries.entry[0][0].label
- // To check the value: Use the json path in body: list.entries.entry[0][0].value
- }
-
- return response;
- }
}