### Question:
CompletionUtils { static String getStringToParse(String textTillCaret) { int lastIndexOfLineFeed = textTillCaret.lastIndexOf('\n'); String lineTillCaret; if(-1 == lastIndexOfLineFeed) { lineTillCaret = textTillCaret; } else { lineTillCaret = textTillCaret.substring(lastIndexOfLineFeed); } String beginning = ""; if (0 != lineTillCaret.trim().length() && !Character.isWhitespace(lineTillCaret.charAt(lineTillCaret.length() - 1))) { String trimmedLineTillCaret = lineTillCaret.trim(); int lastSeparatorIndex = getLastSeparatorIndex(trimmedLineTillCaret); if (-1 == lastSeparatorIndex) { beginning = trimmedLineTillCaret; } else { beginning = trimmedLineTillCaret.substring(lastSeparatorIndex + 1, trimmedLineTillCaret.length()); } } return beginning; }    }### Answer:
@Test public void testGetStringToParse_incomplete() { String result = CompletionUtils.getStringToParse("select"); assertEquals("select", result); }
@Test public void testGetStringToParse() { String result = CompletionUtils.getStringToParse(SELECT_ID_FROM_MYDB_TABLE); assertEquals("mydb.table", result); result = CompletionUtils.getStringToParse(SELECT_ID_FROM_TABLE_S_WHERE_S_ID_1); assertEquals("1", result); }