use of org.alfresco.rest.api.search.model.SearchSQLQuery in project alfresco-remote-api by Alfresco.
the class SearchSQLParseTest method testSQLDeserializeSelectQuery.
@Test
public void testSQLDeserializeSelectQuery() throws IOException {
String query = "{\"stmt\": \"select SITE from alfresco\"}";
SearchSQLQuery searchQuery = parse(query);
assertEquals("select SITE from alfresco", searchQuery.getStmt());
}
use of org.alfresco.rest.api.search.model.SearchSQLQuery in project alfresco-remote-api by Alfresco.
the class ResultMapperTests method testSqlResponse.
@Test
public void testSqlResponse() throws IOException, JSONException {
JSONObject response = new JSONObject("{\"docs\":[{\"SITE\":\"_REPOSITORY_\"},{\"SITE\":\"surf-config\"},{\"SITE\":\"swsdp\"},{\"EOF\":true,\"RESPONSE_TIME\":96}]}");
JSONArray docs = response.getJSONArray("docs");
SearchSQLQuery query = new SearchSQLQuery("select SITE from alfresco group by SITE", null, null, 100, false, null, null);
CollectionWithPagingInfo<TupleList> info = mapper.toCollectionWithPagingInfo(docs, query);
assertEquals(100, info.getPaging().getMaxItems());
assertEquals(0, info.getPaging().getSkipCount());
assertEquals(false, info.getCollection().isEmpty());
assertEquals(3, info.getCollection().size());
info = mapper.toCollectionWithPagingInfo(new JSONArray(), query);
assertEquals(100, info.getPaging().getMaxItems());
assertEquals(0, info.getPaging().getSkipCount());
assertEquals(true, info.getCollection().isEmpty());
assertEquals(0, info.getCollection().size());
try {
mapper.toCollectionWithPagingInfo(null, query);
} catch (Exception e) {
assertNotNull(e);
assertEquals("Solr response is required instead of JSONArray docs was null", e.getMessage());
}
try {
mapper.toCollectionWithPagingInfo(docs, null);
} catch (Exception e) {
assertNotNull(e);
assertEquals("SearchSQLQuery is required", e.getMessage());
}
}
Aggregations