AbstractQueryTranslator implements QueryTranslator<Q,O,P> { @Override public <T, R> O translateOrder(Query<T, R> query) { List<Ordering> orderingList = query.getOrder().get(); @SuppressWarnings("unchecked") O[] orders = (O[]) Array.newInstance(orderClass, orderingList.size()); for (int i = 0; i < orders.length; i++) { Ordering ordering = orderingList.get(i); orders[i] = order( propertyResolver.resolve(ordering.getPropertyName(), query.getEntityClass()), ordering.getOrder()); } return order(orders); } AbstractQueryTranslator(Class<Q> queryClass,
            Class<O> orderClass,
            PropertyResolver propertyResolver); @Override Q translate(Query<T,R> query); @Override O translateOrder(Query<T, R> query); abstract Q eq(String fieldName, Object value); abstract Q ne(String fieldName, Object value); abstract Q lt(String fieldName, Object value); abstract Q lte(String fieldName, Object value); abstract Q gt(String fieldName, Object value); abstract Q gte(String fieldName, Object value); abstract Q between(String fieldName, Object from, Object to); abstract Q in(String fieldName, Object[] values); abstract Q notIn(String fieldName, Object[] values); abstract Q contains(String fieldName, Object[] values); abstract Q isNull(String fieldName); abstract Q notNull(String fieldName); abstract Q isEmpty(String fieldName); abstract Q notEmpty(String fieldName); abstract Q within(
            String fieldName, Point<N> center, Number distance); abstract Q and(Q... subqueries); abstract Q or(Q... subqueries); abstract O order(String fieldName, Order o); abstract O order(O... orders);  }
@Test public void translateOrdering_one_asc() { Ordering o = Ordering.asc(property); String expected = field + " asc"; assertEquals(expected, translator.translateOrder(orderQuery(o))); }
@Test public void translateOrdering_one_desc() { Ordering o = Ordering.desc(property); String expected = field + " desc"; assertEquals(expected, translator.translateOrder(orderQuery(o))); }
@Test public void translateOrdering_many() { Query<Test,Test> orderQuery = orderQuery( Ordering.asc("property1"), Ordering.desc("property2"), Ordering.asc("property3"), Ordering.desc("property4") ); String expected = "property1 asc, property2 desc, property3 asc, property4 desc"; assertEquals(expected, translator.translateOrder(orderQuery)); }