QueryManager queryManager = ocm.getQueryManager();
Filter filter = queryManager.createFilter(Paragraph.class);
filter.addLike("text", "Para%");
filter.setScope("/test/");
Query query = queryManager.createQuery(filter);
query.addOrderByDescending("text");
String strQueryBuilderStringWithDescending = ((QueryImpl)query).getOrderByExpression();
Collection result = ocm.getObjects(query);
assertEquals("Invalid number of objects - should be = 3", 3, result.size());
//Text is Descending
Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
Iterator iterator = result.iterator();
Paragraph para = (Paragraph)iterator.next();
assertEquals("Para 3",para.getText());
para = (Paragraph)iterator.next();
assertEquals("Para 2",para.getText());
para = (Paragraph)iterator.next();
assertEquals("Para 1",para.getText());
//Text is Ascending
query = queryManager.createQuery(filter);
query.addOrderByAscending("text");
ocm = this.getObjectContentManager();
result = ocm.getObjects(query);
assertEquals("Invalid number of objects - should be = 3", 3, result.size());
iterator = result.iterator();