### Question:
JdbcUtil { public static void closeQuietly(ResultSet resultSet) { if (resultSet == null) { return; } try { resultSet.close(); } catch (SQLException e) { logSQLException(e); LOGGER.warn(Messages.COULD_NOT_CLOSE_RESULT_SET, e); } catch (Exception e) { LOGGER.warn(Messages.COULD_NOT_CLOSE_RESULT_SET, e); } } private  JdbcUtil(); static void closeQuietly(ResultSet resultSet); static void closeQuietly(Statement statement); static void closeQuietly(Connection connection); static void logSQLException(SQLException exception); static void commit(Connection connection); static void rollback(Connection connection);  }### Answer:
@Test void closeQuietlyResultSet() throws SQLException { ResultSet resultSet = Mockito.mock(ResultSet.class); JdbcUtil.closeQuietly(resultSet); Mockito.verify(resultSet) .close(); }
@Test void closeQuietlyResultSetWithException() throws SQLException { ResultSet resultSet = Mockito.mock(ResultSet.class); Mockito.doThrow(new SQLException()) .when(resultSet) .close(); JdbcUtil.closeQuietly(resultSet); Mockito.verify(resultSet) .close(); }
@Test void closeQuietlyResultSetWithNull() { ResultSet resultSet = null; Assertions.assertDoesNotThrow(() -> JdbcUtil.closeQuietly(resultSet)); }
@Test void closeQuietlyStatement() throws SQLException { Statement statement = Mockito.mock(Statement.class); JdbcUtil.closeQuietly(statement); Mockito.verify(statement) .close(); }
@Test void closeQuietlyStatementWithException() throws SQLException { Statement statement = Mockito.mock(Statement.class); Mockito.doThrow(new SQLException()) .when(statement) .close(); JdbcUtil.closeQuietly(statement); Mockito.verify(statement) .close(); }
@Test void closeQuietlyStatementWithNull() { Statement statement = null; Assertions.assertDoesNotThrow(() -> JdbcUtil.closeQuietly(statement)); }
@Test void closeQuietlyConnection() throws SQLException { Connection connection = Mockito.mock(Connection.class); JdbcUtil.closeQuietly(connection); Mockito.verify(connection) .close(); }
@Test void closeQuietlyConnectionWithException() throws SQLException { Connection connection = Mockito.mock(Connection.class); Mockito.doThrow(new SQLException()) .when(connection) .close(); JdbcUtil.closeQuietly(connection); Mockito.verify(connection) .close(); }
@Test void closeQuietlyConnectionWithNull() { Connection connection = null; Assertions.assertDoesNotThrow(() -> JdbcUtil.closeQuietly(connection)); }