### Question:
SqlQueryParser implements QueryParser { protected NamedSelector parseNamedSelector( TokenStream tokens, TypeSystem typeSystem ) { SelectorName name = parseSelectorName(tokens, typeSystem); SelectorName alias = null; if (tokens.canConsume("AS")) alias = parseSelectorName(tokens, typeSystem); return new NamedSelector(name, alias); }  String getLanguage(); @Override String toString(); @Override boolean equals( Object obj ); QueryCommand parseQuery( String query,
                                    TypeSystem typeSystem ); static final String LANGUAGE; }### Answer:
@Test public void shouldParseNamedSelectorFromUnquotedNameWithNoAlias() { NamedSelector selector = parser.parseNamedSelector(tokens("name"), typeSystem); assertThat(selector.name(), is(selectorName("name"))); assertThat(selector.alias(), is(nullValue())); assertThat(selector.aliasOrName(), is(selectorName("name"))); }
@Test public void shouldParseNamedSelectorFromUnquotedNameWithUnquotedAlias() { NamedSelector selector = parser.parseNamedSelector(tokens("name AS alias"), typeSystem); assertThat(selector.name(), is(selectorName("name"))); assertThat(selector.alias(), is(selectorName("alias"))); assertThat(selector.aliasOrName(), is(selectorName("alias"))); }
@Test public void shouldParseNamedSelectorFromQuotedNameWithUnquotedAlias() { NamedSelector selector = parser.parseNamedSelector(tokens("'name' AS alias"), typeSystem); assertThat(selector.name(), is(selectorName("name"))); assertThat(selector.alias(), is(selectorName("alias"))); assertThat(selector.aliasOrName(), is(selectorName("alias"))); }
@Test public void shouldParseNamedSelectorFromQuotedNameWithQuotedAlias() { NamedSelector selector = parser.parseNamedSelector(tokens("'name' AS [alias]"), typeSystem); assertThat(selector.name(), is(selectorName("name"))); assertThat(selector.alias(), is(selectorName("alias"))); assertThat(selector.aliasOrName(), is(selectorName("alias"))); }
@Test( expected = ParsingException.class ) public void shouldFailInParseNamedSelectorIfNoMoreTokens() { parser.parseNamedSelector(tokens(" "), typeSystem); }