### Question:
IRODSGenQueryTranslator { protected List<String> parseOrderByFieldsIntoList(final String query) throws JargonQueryException { List<String> orderByVals = new ArrayList<String>(); String upperCaseVersionOfQuery = query.toUpperCase(); int indexOfOrderBy = upperCaseVersionOfQuery.indexOf("ORDER BY"); if (indexOfOrderBy == -1) { log.debug("no order by in query"); return orderByVals; } String orderBySectionOfQueryToParse; orderBySectionOfQueryToParse = upperCaseVersionOfQuery.substring(indexOfOrderBy + 8); log.debug("order by section of query:{}", orderBySectionOfQueryToParse); String token; String queryNoCommas = orderBySectionOfQueryToParse.replaceAll(",", " "); StringTokenizer tokenizer = new StringTokenizer(queryNoCommas, " "); while (tokenizer.hasMoreElements()) { token = tokenizer.nextToken(); orderByVals.add(token); } return orderByVals; } IRODSGenQueryTranslator(final IRODSServerProperties irodsServerProperties);  IRODSGenQueryTranslator(final IRODSServerProperties irodsServerProperties,
			final ExtensibleMetaDataMapping extensibleMetaDataMapping); TranslatedIRODSGenQuery getTranslatedQuery(final IRODSGenQuery irodsQuery); IRODSServerProperties getIrodsServerProperties(); void setIrodsServerProperties(final IRODSServerProperties irodsServerProperties); ExtensibleMetaDataMapping getExtensibleMetaDataMapping(); void setExtensibleMetaDataMapping(final ExtensibleMetaDataMapping extensibleMetaDataMapping); static final String[] operatorStrings; static final String ORDER_BY; }### Answer:
@Test public final void tokenizeOrderBy() throws Exception { String query = "SELECT COLL_ID,COLL_NAME,META_COLL_ATTR_NAME,META_COLL_ATTR_VALUE,META_COLL_ATTR_UNITS ORDER BY META_COLL_ATTR_NAME"; IRODSServerProperties props = IRODSServerProperties.instance(IRODSServerProperties.IcatEnabled.ICAT_ENABLED, 100, "rods2.4", "d", "zone"); IRODSGenQueryTranslator translator = new IRODSGenQueryTranslator(props); List<String> orderByFields = translator.parseOrderByFieldsIntoList(query); Assert.assertEquals("did not set the group by", 1, orderByFields.size()); Assert.assertEquals("did not find order by field", "META_COLL_ATTR_NAME", orderByFields.get(0)); }
@Test public final void tokenizeTwoOrderBy() throws Exception { String query = "SELECT COLL_ID,COLL_NAME,META_COLL_ATTR_NAME,META_COLL_ATTR_VALUE,META_COLL_ATTR_UNITS ORDER BY META_COLL_ATTR_NAME, META_COLL_ATTR_VALUE"; IRODSServerProperties props = IRODSServerProperties.instance(IRODSServerProperties.IcatEnabled.ICAT_ENABLED, 100, "rods2.4", "d", "zone"); IRODSGenQueryTranslator translator = new IRODSGenQueryTranslator(props); List<String> orderByFields = translator.parseOrderByFieldsIntoList(query); Assert.assertEquals("did not set the group by", 2, orderByFields.size()); Assert.assertEquals("did not find order by field", "META_COLL_ATTR_NAME", orderByFields.get(0)); Assert.assertEquals("did not find order by field", "META_COLL_ATTR_VALUE", orderByFields.get(1)); }