public class CriteriaUtilsTest extends TestCase
{
public void testOrderBy () {
/* Create a list of OrderBy objects. */
List<OrderBy> list = new ArrayList<OrderBy>();
list.add(new OrderBy("foobar", OrderDirection.ASC));
list.add(new OrderBy("baz", OrderDirection.DESC));
/* Make this OrderBy one that is case insensitive. */
OrderBy bacon = new OrderBy("bacon", OrderDirection.DESC);
list.add(bacon);
bacon.setCaseSensitive(false);
/* Convert the list into an array. */
OrderBy[] ob = list.toArray(new OrderBy[list.size()]);
/* Invoke the utility class that constructs the Order By. */
String orderByClause = CriteriaUtils.constructOrderBy(ob);
assertEquals(" ORDER BY o.foobar ASC, o.baz DESC, UPPER( o.bacon ) DESC", orderByClause);