Search-904 Added Tests Select distinct for /sql api

This commit is contained in:
Meenal Bhave
2018-07-09 17:28:05 +01:00
parent b3b6dcbd8b
commit fa482ef229
2 changed files with 45 additions and 0 deletions
@@ -626,4 +626,29 @@ public class SearchSQLAPITest extends AbstractSearchTest
restClient.assertStatusCodeIs(HttpStatus.OK);
restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PATH", Matchers.notNullValue());
}
@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", Matchers.equalToIgnoringCase("site"));
// Select distinct cm_name: solr format
sqlRequest = new SearchSqlRequest();
sqlRequest.setSql("select distinct cm_name from alfresco limit 5");
sqlRequest.setFormat("solr");
response = searchSql(sqlRequest);
restClient.assertStatusCodeIs(HttpStatus.OK);
restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.notNullValue());
}
}
@@ -190,4 +190,24 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest
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"));
}
}
}