@Test
public void shouldBeAbleToCreateAndExecuteJcrSql2QueryToFindAllCarsUnderHybrid() throws RepositoryException {

    String sql = "SELECT car.[car:maker], car.[car:model], car.[car:year], car.[car:msrp], car.[jcr:path] FROM [car:Car] AS car WHERE PATH(car) LIKE '%/Hybrid/%' ORDER BY [car:model]";
    Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    QueryResult result = query.execute();
    String[] columnNames = {"car:maker", "car:model", "car:year", "car:msrp", "jcr:path"};
    validateQuery().rowCount(3).hasColumns(columnNames).onEachRow(new Predicate() {
        @Override
        public void validate( int rowNumber,
                              Row row ) throws RepositoryException {
            if (rowNumber == 1) {
                assertThat(row.getValue("car:model").getString(), is("Altima"));
                assertThat(row.getValue("car:msrp").getString(), is("$18,260"));
                assertThat(row.getValue("car:year").getLong(), is(2008L));
            } else if (rowNumber == 2) {
                assertThat(row.getValue("car:model").getString(), is("Highlander"));
                assertThat(row.getValue("car:msrp").getString(), is("$34,200"));
                assertThat(row.getValue("car:year").getLong(), is(2008L));
            } else if (rowNumber == 3) {
                assertThat(row.getValue("car:model").getString(), is("Prius"));
                assertThat(row.getValue("car:msrp").getString(), is("$21,500"));
                assertThat(row.getValue("car:year").getLong(), is(2008L));
            }
        }
    }).validate(query, result);
}