Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
QueryResult result = query.execute();
String[] columnNames = {"car.jcr:name", "category.jcr:primaryType", "car.jcr:path", "category.jcr:path"};
// Because every "Toyota" car has a parent, there will be no 'car' nodes that don't have a category. However,
// we'll see every category node, and there are 25 of them. Therefore, we'll see 25 nodes.
validateQuery().rowCount(25).hasColumns(columnNames).onEachRow(new Predicate() {
@Override
public void validate( int rowNumber,
Row row ) throws RepositoryException {
// Every row should have a category ...
assertNotNull(row.getNode("category"));