@Test void executeUpdateThatThrows() throws SQLException { when(preparedStatement.executeUpdate()).thenThrow(new SQLException("Update failed")); calling(() -> PreparedStatementUtil.executeUpdate(preparedStatement)) .shouldThrow(RuntimeSqlException.class) .withCause(SQLException.class) .withMessage(is("Update failed")); verify(preparedStatement).executeUpdate(); verifyNoMoreInteractions(preparedStatement); }
public static int executeUpdate(PreparedStatement preparedStatement) { try { return preparedStatement.executeUpdate(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }
PreparedStatementUtil extends UtilityClass { public static int executeUpdate(PreparedStatement preparedStatement) { try { return preparedStatement.executeUpdate(); } catch (SQLException e) { throw new RuntimeSqlException(e); } } }
PreparedStatementUtil extends UtilityClass { public static int executeUpdate(PreparedStatement preparedStatement) { try { return preparedStatement.executeUpdate(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  }
PreparedStatementUtil extends UtilityClass { public static int executeUpdate(PreparedStatement preparedStatement) { try { return preparedStatement.executeUpdate(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  static void setObject(PreparedStatement preparedStatement, int i, Object arg); static int executeUpdate(PreparedStatement preparedStatement); static boolean execute(PreparedStatement preparedStatement); static ResultSet executeQuery(PreparedStatement preparedStatement); }
PreparedStatementUtil extends UtilityClass { public static int executeUpdate(PreparedStatement preparedStatement) { try { return preparedStatement.executeUpdate(); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  static void setObject(PreparedStatement preparedStatement, int i, Object arg); static int executeUpdate(PreparedStatement preparedStatement); static boolean execute(PreparedStatement preparedStatement); static ResultSet executeQuery(PreparedStatement preparedStatement);  }