@Test void connectionThatThrows() throws SQLException { when(dataSource.getConnection()).thenThrow(new SQLException("We have none")); calling(() -> DataSourceUtil.connection(dataSource)) .shouldThrow(RuntimeSqlException.class) .withCause(SQLException.class) .withMessage(is("We have none")); verify(dataSource).getConnection(); verifyNoMoreInteractions(dataSource); }
public static Connection connection(DataSource dataSource) { try { return dataSource.getConnection(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }
DataSourceUtil extends UtilityClass { public static Connection connection(DataSource dataSource) { try { return dataSource.getConnection(); } catch (SQLException e) { throw new RuntimeSqlException(e); } } }
DataSourceUtil extends UtilityClass { public static Connection connection(DataSource dataSource) { try { return dataSource.getConnection(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  }
DataSourceUtil extends UtilityClass { public static Connection connection(DataSource dataSource) { try { return dataSource.getConnection(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  static Connection connection(DataSource dataSource); }
DataSourceUtil extends UtilityClass { public static Connection connection(DataSource dataSource) { try { return dataSource.getConnection(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  static Connection connection(DataSource dataSource);  }