use of com.hortonworks.registries.storage.search.SearchQuery in project registry by hortonworks.
the class SearchApiTest method testSearchAPIJsons.
@Test
public void testSearchAPIJsons() throws Exception {
LOG.info("simpleQuery = [{}]", simpleQuery);
LOG.info("complexQuery = [{}]", complexQuery);
SearchQuery[] queries = { simpleQuery, complexQuery };
for (SearchQuery query : queries) {
ObjectMapper objectMapper = new ObjectMapper();
String queryAsJson = objectMapper.writeValueAsString(query);
LOG.info("queryAsJson = [{}]", queryAsJson);
SearchQuery returnedQuery = objectMapper.readValue(queryAsJson, SearchQuery.class);
LOG.info("returnedQuery [{}] ", returnedQuery);
Assert.assertEquals(query, returnedQuery);
}
}
use of com.hortonworks.registries.storage.search.SearchQuery in project registry by hortonworks.
the class JdbcStorageManagerIntegrationTest method testSearchQueryApi.
@Test
public void testSearchQueryApi() {
for (StorableTest storableTest : storableTests) {
storableTest.addAllToStorage();
String nameSpace = storableTest.getNameSpace();
SearchQuery searchQuery = SearchQuery.searchFrom(nameSpace).where(WhereClause.begin().contains("name", "info").and().gt("id", 1L).combine()).orderBy(OrderBy.asc("name"));
Collection<Storable> storablesWithIdGt1 = getStorageManager().search(searchQuery);
System.out.println("storablesWithIdGt1 = " + storablesWithIdGt1);
for (Storable storable : storablesWithIdGt1) {
Assert.assertTrue(storable.getId() > 1L);
}
Collection<Storable> allStorables = getStorageManager().list(searchQuery.getNameSpace());
System.out.println("list = " + allStorables);
Assert.assertEquals(allStorables.size() - 1, storablesWithIdGt1.size());
}
}
Aggregations