### Question:
IRODSGenQueryTranslator { protected List<String> parseSelectsIntoListOfNames(final String query) throws JargonQueryException { String queryDelimited; queryDelimited = query.toUpperCase(); queryDelimited = queryDelimited.replaceAll(" ", " "); queryDelimited = queryDelimited.replaceAll(ORDER_BY, "ORDERBY"); queryDelimited = queryDelimited.replaceAll(GROUP_BY, "GROUPBY"); List<String> selectFieldNames = new ArrayList<String>(); boolean readPastSelect = false; boolean haveNotHitEndOfSelects = true; String token; String queryNoCommas = queryDelimited.replaceAll(",", " "); StringTokenizer tokenizer = new StringTokenizer(queryNoCommas, " "); int tokenCtr = 0; while (tokenizer.hasMoreElements() && haveNotHitEndOfSelects) { token = tokenizer.nextToken(); if (token.equalsIgnoreCase("select")) { readPastSelect = true; continue; } if (!readPastSelect) { JargonQueryException qe = new JargonQueryException("error in query, no select detected"); qe.setQuery(query); throw qe; } if (token.equalsIgnoreCase("where") || token.equalsIgnoreCase("ORDERBY") || token.equalsIgnoreCase("GROUPBY")) { haveNotHitEndOfSelects = false; continue; } if (token.equalsIgnoreCase("distinct") || token.equalsIgnoreCase("non-distinct")) { if (tokenCtr != 1) { JargonQueryException qe = new JargonQueryException( "distinct/non-distinct must be second token after select"); qe.setQuery(query); } continue; } selectFieldNames.add(token.trim()); tokenCtr++; } return selectFieldNames; } 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 testParseSelectsIntoListOfNames() throws Exception { String query = "select blah, yelp"; IRODSServerProperties props = IRODSServerProperties.instance(IRODSServerProperties.IcatEnabled.ICAT_ENABLED, 100, "rods2.2", "d", "zone"); IRODSGenQueryTranslator translator = new IRODSGenQueryTranslator(props); List<String> selects = translator.parseSelectsIntoListOfNames(query); Assert.assertEquals(2, selects.size()); Assert.assertEquals("BLAH", selects.get(0)); Assert.assertEquals("YELP", selects.get(1)); }
@Test(expected = JargonQueryException.class) public final void testParseSelectsIntoListOfNamesNoSelect() throws Exception { String query = "blah, yelp"; IRODSServerProperties props = IRODSServerProperties.instance(IRODSServerProperties.IcatEnabled.ICAT_ENABLED, 100, "rods2.2", "d", "zone"); IRODSGenQueryTranslator translator = new IRODSGenQueryTranslator(props); translator.parseSelectsIntoListOfNames(query); }