mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Search-634 Tests implemented for select star via sql api and jdbc
(cherry picked from commit 7f3e7ad1aaea2f47934f7c8aef91b7e356a26a25)
This commit is contained in:
@@ -599,4 +599,31 @@ public class SearchSQLAPITest extends AbstractSearchTest
|
||||
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", Matchers.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.PATH", Matchers.notNullValue());
|
||||
}
|
||||
}
|
||||
@@ -150,4 +150,44 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest
|
||||
// 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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user