### Question:
SqlTableNameExtractor { public static String extractTableName(final String sql) { String lowerCaseSql = sql.toLowerCase(); String from = " from "; int fromIndex = lowerCaseSql.indexOf(from); if (fromIndex < 0) { return null; } String tableString = sql.substring(fromIndex + from.length()); if (tableString.startsWith("(")) { return null; } int endTableIndex = -1; for (int i = 0; i < tableString.length(); i++) { char c = tableString.charAt(i); if (c == ' ' || c == ',' || c == ';') { endTableIndex = i; break; } } return endTableIndex < 0 ? tableString : tableString.substring(0, endTableIndex); } private  SqlTableNameExtractor(); static String extractTableName(final String sql);  }### Answer:
@Test public void itExtractsTableNameBasic() { String sql = "SELECT * FROM table WHERE bar = baz"; assertThat(SqlTableNameExtractor.extractTableName(sql)).isEqualTo("table"); }
@Test public void itExtractsTableNameWithComma() { String sql = "SELECT * FROM table, other_table WHERE bar = baz"; assertThat(SqlTableNameExtractor.extractTableName(sql)).isEqualTo("table"); }
@Test public void itExtractsTableNameWithSemicolon() { String sql = "SELECT * FROM table;"; assertThat(SqlTableNameExtractor.extractTableName(sql)).isEqualTo("table"); }