DatabaseServerInfo { @Override public String toString() { return String.format("Database name is `%s`, version is `%s`", databaseName, databaseVersion); } DatabaseServerInfo(final DataSource dataSource); @Override String toString();  }
@Test public void assertToString() throws SQLException { DatabaseMetaData databaseMetaData = mock(DatabaseMetaData.class); when(databaseMetaData.getDatabaseProductName()).thenReturn("fixtureDB"); when(databaseMetaData.getDatabaseProductVersion()).thenReturn("1.0.0"); when(dataSource.getConnection().getMetaData()).thenReturn(databaseMetaData); assertThat(new DatabaseServerInfo(dataSource).toString(), is("Database name is `fixtureDB`, version is `1.0.0`")); }