RestQueryGenerator { public static String generateOrderParams(List<SortParameter> sortParameterList) { StringBuilder orderBuilder = new StringBuilder(); boolean first = true; for(SortParameter sortParameter : sortParameterList) { if(!first) orderBuilder.append(ORDER_SPLIT); else first = false; String orderingKeyword = sortParameter.getOrder() == Order.ASCENDING ? ASC_KEYWORD : DESC_KEYWORD; orderBuilder.append(sortParameter.getField()).append(" ").append(orderingKeyword); } return orderBuilder.toString(); } private  RestQueryGenerator(); static String generatorQuery(BlockOperation block); static String generateOrderParams(List<SortParameter> sortParameterList); static final String STRING_ESCAPE; }
@Test public void testGenerateOrderParams() { List<SortParameter> sortParameterList = new ArrayList<>(); sortParameterList.add(new SortParameter("field1", Order.ASCENDING)); assertEquals("Unexpected order params", "field1 ASC", RestQueryGenerator.generateOrderParams(sortParameterList)); sortParameterList.add(new SortParameter("field3", Order.DESCENDING)); assertEquals("Unexpected order params", "field1 ASC,field3 DESC", RestQueryGenerator.generateOrderParams(sortParameterList)); }