### Question:
StatementParser { public static StatementType getStatementType(String sql) { if (clientLibraryParser.isQuery(sql)) { return StatementType.SELECT; } else if (clientLibraryParser.isDdlStatement(sql)) { return StatementType.DDL; } else if (clientLibraryParser.isUpdateStatement(sql)) { return StatementType.DML; } else { return StatementType.UNKNOWN; } } private  StatementParser(); static StatementType getStatementType(String sql);  }### Answer:
@Test public void parsesSelectQueries() { String sql = "SELECT * from blahblahblah"; assertThat(StatementParser.getStatementType(sql)).isEqualTo(StatementType.SELECT); }
@Test public void parsesDmlQueries() { String sql = "InSeRt INTO TABLE_NAME VALUES (value1, value2, value3,...valueN)"; assertThat(StatementParser.getStatementType(sql)).isEqualTo(StatementType.DML); sql = "DELETE FROM target_name WHERE true"; assertThat(StatementParser.getStatementType(sql)).isEqualTo(StatementType.DML); sql = "UPDATE Singers\n" + "SET BirthDate = '1990-10-10'\n" + "WHERE FirstName = 'Marc' AND LastName = 'Richards'"; assertThat(StatementParser.getStatementType(sql)).isEqualTo(StatementType.DML); }
@Test public void parsesDdlQueries() { String sql = "drop table Blarg"; assertThat(StatementParser.getStatementType(sql)).isEqualTo(StatementType.DDL); sql = "CREATE table foobar5000"; assertThat(StatementParser.getStatementType(sql)).isEqualTo(StatementType.DDL); sql = "ALTER TABLE table Add Column name STRING"; assertThat(StatementParser.getStatementType(sql)).isEqualTo(StatementType.DDL); }
@Test public void parseUnknownQuery() { String sql = "int number = 5"; assertThat(StatementParser.getStatementType(sql)).isEqualTo(StatementType.UNKNOWN); }
@Test public void parseQueryWithOptionsPrefix() { String sql = "@{FORCE_INDEX=index_name} @{JOIN_METHOD=HASH_JOIN} SELECT * FROM blahblah"; assertThat(StatementParser.getStatementType(sql)).isEqualTo(StatementType.SELECT); }