### Question:
UniqueDocumentFilter extends AbstractQueryFilter { @Override public String filterStatement(String statement, String language) { StringBuilder builder = new StringBuilder(); String result = statement; String original = statement; String lcStatement = statement.toLowerCase(); if (Query.HQL.equals(language) && isFilterable(lcStatement)) { String prettySeparator = ", "; builder.append("select distinct doc.fullName"); int columnPosition = 1; List<String> selectColumns = getSelectColumns(original); for (String column : selectColumns) { if (!FULLNAME_COLUMN.equals(column)) { builder.append(prettySeparator); builder.append(column); columnPosition++; } } for (String column : getOrderByColumns(original)) { if (!FULLNAME_COLUMN.equals(column) && !selectColumns.contains(column)) { builder.append(prettySeparator); builder.append(column); this.columnsToRemove.add(columnPosition); columnPosition++; } } builder.append(" "); builder.append(statement.substring(lcStatement.indexOf(" from ")).trim()); result = builder.toString(); } if (!statement.equals(result)) { logger.debug("Query [{}] has been transformed into [{}]", original, result); } return result; }  @Override String filterStatement(String statement, String language); @Override List filterResults(List results); static final String HINT; }### Answer:
@Test public void filterSelectWithAsStatement() { assertEquals("select distinct doc.fullName from XWikiDocument as doc", this.filter.filterStatement("select doc.fullName from XWikiDocument as doc", Query.HQL)); }
@Test public void filterSelectStatementWithMismatchingDocAlias() { assertEquals("select mydoc.fullName from XWikiDocument mydoc", this.filter.filterStatement("select mydoc.fullName from XWikiDocument mydoc", Query.HQL)); }
@Test public void filterStatementWhenStatementAlreadyContainsDistinct() { assertEquals("select distinct doc.fullName from XWikiDocument doc", this.filter.filterStatement("select distinct doc.fullName from XWikiDocument doc", Query.HQL)); }