OrderByParser extends ParserBase { public static OrderBy parse(String expr) { return new OrderByParser(expr).orderBy(); } OrderByParser(String expr); static OrderBy parse(String expr); OrderBy orderBy(); static final String ORDER_BY; }
@Test public void testSingle() { OrderBy orderBy = OrderByParser.parse("name"); assertSingleOrderBy(orderBy, "name", null, true); orderBy = OrderByParser.parse("t.name"); assertSingleOrderBy(orderBy, "name", "t", true); orderBy = OrderByParser.parse("t.name desc"); assertSingleOrderBy(orderBy, "name", "t", false); }
@Test public void testMulti() { OrderBy orderBy = OrderByParser.parse("id,name"); assertEquals(2, orderBy.items().length); assertOrderBy(orderBy.items()[0], "id", null, true); assertOrderBy(orderBy.items()[1], "name", null, true); orderBy = OrderByParser.parse("id desc,name"); assertOrderBy(orderBy.items()[0], "id", null, false); assertOrderBy(orderBy.items()[1], "name", null, true); orderBy = OrderByParser.parse("t.id desc,t.name asc"); assertOrderBy(orderBy.items()[0], "id", "t", false); assertOrderBy(orderBy.items()[1], "name", "t", true); }