@Test
public void shouldBeAbleToCreateAndExecuteJcrSql2QueryToFindAllCarNodesOrderedByAscendingLexicographicalPriceAndNullsFirst()
    throws RepositoryException {

    String sql = "SELECT * FROM [car:Car] ORDER BY [car:msrp] ASC NULLS FIRST";
    Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    QueryResult result = query.execute();
    validateQuery().rowCount(13).hasColumns(carColumnNames("car:Car")).onEachRow(new Predicate() {
        @Override
        public void validate( int rowNumber,
                              Row row ) throws RepositoryException {
            // Results are sorted by lexicographic MSRP (as a string, not as a number)!!!
            if (rowNumber == 1) {
                assertThat(row.getValue("car:model").getString(), is("DTS"));
                assertThat(row.getValue("car:msrp"), is(nullValue()));
                assertThat(row.getValue("car:mpgCity"), is(nullValue()));
            } else if (rowNumber == 13) {
                assertThat(row.getValue("car:model").getString(), is("LR3"));
                assertThat(row.getValue("car:msrp").getString(), is("$48,525"));
                assertThat(row.getValue("car:mpgCity").getLong(), is(12L));
            } else if (rowNumber == 12) {
                assertThat(row.getValue("car:model").getString(), is("IS350"));
                assertThat(row.getValue("car:msrp").getString(), is("$36,305"));
                assertThat(row.getValue("car:mpgCity").getLong(), is(18L));
            } else if (rowNumber == 12) {
                assertThat(row.getValue("car:model").getString(), is("DB9"));
                assertThat(row.getValue("car:msrp").getString(), is("$171,600"));
                assertThat(row.getValue("car:mpgCity").getLong(), is(12L));
            }
        }
    }).validate(query, result);
}