DefaultDatabase implements Database { @Override public Database truncate(String tableName) { Connection connection = openConnection(); try { truncate(tableName, connection); return this; } finally { closeQuietly(connection); } } DefaultDatabase(Configuration config);  DefaultDatabase(DatabaseClient client); void start(); void stop(); @Override Map<String, String> getSonarProperties(); @Override DatabaseClient getClient(); @Override Database truncate(String tableName); @Override int countSql(String sql); @Override List<Map<String, String>> executeSql(String sql); @Override Connection openConnection(); @Override DefaultDatabase closeQuietly(@Nullable Connection connection); @Override void killOtherConnections();  }
@Test public void truncate() { assertThat(db.countSql("select count(kee) from metrics")).isGreaterThan(0); db.truncate("metrics"); assertThat(db.countSql("select count(kee) from metrics")).isEqualTo(0); }
@Test public void truncateShouldFailIfUppercase() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Table name [METRICS] should be lowercase to avoid issues"); db.truncate("METRICS"); }