### Question:
HqlQueryExecutor implements QueryExecutor, Initializable { protected String completeShortFormStatement(String statement) { String lcStatement = statement.toLowerCase().trim(); if (lcStatement.isEmpty() || lcStatement.startsWith(",") || lcStatement.startsWith("where ") || lcStatement.startsWith("order by ")) { return "select doc.fullName from XWikiDocument doc " + statement.trim(); } return statement; }  @Override void initialize(); @Override List<T> execute(final Query query);  }### Answer:
@Test public void completeShortStatementWhenEmpty() { assertEquals("select doc.fullName from XWikiDocument doc ", this.executor.completeShortFormStatement("")); }
@Test public void completeShortStatementStartingWithWhere() { assertEquals("select doc.fullName from XWikiDocument doc where doc.author='XWiki.Admin'", this.executor.completeShortFormStatement("where doc.author='XWiki.Admin'")); }
@Test public void completeShortStatementStartingWithFrom() { assertEquals( "select doc.fullName from XWikiDocument doc , BaseObject obj where doc.fullName=obj.name " + "and obj.className='XWiki.MyClass'", this.executor.completeShortFormStatement( ", BaseObject obj where " + "doc.fullName=obj.name and obj.className='XWiki.MyClass'")); }
@Test public void completeShortStatementStartingWithOrderBy() { assertEquals("select doc.fullName from XWikiDocument doc order by doc.date desc", this.executor.completeShortFormStatement("order by doc.date desc")); }
@Test public void completeShortStatementPassingAnAlreadyCompleteQuery() { assertEquals("select doc.fullName from XWikiDocument doc order by doc.date desc", this.executor .completeShortFormStatement("select doc.fullName from XWikiDocument doc order by doc.date desc")); }
@Test public void completeShortStatementPassingAQueryOnSomethingElseThanADocument() { assertEquals("select lock.docId from XWikiLock as lock ", this.executor.completeShortFormStatement("select lock.docId from XWikiLock as lock ")); }