@FixFor( "MODE-2151" )
@Test
public void shouldBeAbleToCreateAndExecuteJcrSql2QueryWithChildNodeJoinWithChildCountCriteria() throws RepositoryException {

    String sql = "SELECT * FROM [car:Car] as car JOIN [nt:unstructured] as category ON ISCHILDNODE(car,category) WHERE CHILDCOUNT(category) > 4";
    Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    String[] columnNames = allOf(carColumnNames("car"), allColumnNames("category"));
    // Just the "Utility" nodes ...
    validateQuery().rowCount(5).hasColumns(columnNames).validate(query, query.execute());
    sql = "SELECT * FROM [car:Car] as car JOIN [nt:unstructured] as category ON ISCHILDNODE(car,category) WHERE CHILDCOUNT(category) > 2";
    query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    // Just the "Utility", "Hybrid", and "Luxury" nodes ...
    validateQuery().rowCount(11).hasColumns(columnNames).validate(query, query.execute());
    sql = "SELECT * FROM [car:Car] as car JOIN [nt:unstructured] as category ON ISCHILDNODE(car,category)";
    query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    // All categories ...
    validateQuery().rowCount(13).hasColumns(columnNames).validate(query, query.execute());
}