@Test void getMetaDataThatThrows() throws SQLException { String message = RandomStringUtils.randomAlphabetic(50); when(connection.getMetaData()).thenThrow(new SQLException(message)); calling(() -> ConnectionUtil.getMetaData(connection)) .shouldThrow(RuntimeSqlException.class) .withCause(SQLException.class) .withMessage(is(message)); verify(connection).getMetaData(); verifyNoMoreInteractions(connection); }
public static DatabaseMetaData getMetaData(Connection connection) { try { return connection.getMetaData(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }
ConnectionUtil extends UtilityClass { public static DatabaseMetaData getMetaData(Connection connection) { try { return connection.getMetaData(); } catch (SQLException e) { throw new RuntimeSqlException(e); } } }
ConnectionUtil extends UtilityClass { public static DatabaseMetaData getMetaData(Connection connection) { try { return connection.getMetaData(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  }
ConnectionUtil extends UtilityClass { public static DatabaseMetaData getMetaData(Connection connection) { try { return connection.getMetaData(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  static DatabaseMetaData getMetaData(Connection connection); static void commit(Connection connection); static void rollback(Connection connection); static boolean execute(Connection connection, String sql); static PreparedStatement prepare(Connection connection, String sql); }
ConnectionUtil extends UtilityClass { public static DatabaseMetaData getMetaData(Connection connection) { try { return connection.getMetaData(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  static DatabaseMetaData getMetaData(Connection connection); static void commit(Connection connection); static void rollback(Connection connection); static boolean execute(Connection connection, String sql); static PreparedStatement prepare(Connection connection, String sql);  }