@Test void commitThatThrows() throws SQLException { String message = RandomStringUtils.randomAlphabetic(50); doThrow(new SQLException(message)).when(connection).commit(); calling(() -> ConnectionUtil.commit(connection)) .shouldThrow(RuntimeSqlException.class) .withCause(SQLException.class) .withMessage(is(message)); verify(connection).commit(); verifyNoMoreInteractions(connection); }
public static void commit(Connection connection) { try { connection.commit(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }
ConnectionUtil extends UtilityClass { public static void commit(Connection connection) { try { connection.commit(); } catch (SQLException e) { throw new RuntimeSqlException(e); } } }
ConnectionUtil extends UtilityClass { public static void commit(Connection connection) { try { connection.commit(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  }
ConnectionUtil extends UtilityClass { public static void commit(Connection connection) { try { connection.commit(); } 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 void commit(Connection connection) { try { connection.commit(); } 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);  }