### Question:
JdbcUtil { public static void commit(Connection connection) throws SQLException { if (!connection.getAutoCommit()) { connection.commit(); } } 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 commit() throws SQLException { Connection connection = Mockito.mock(Connection.class); Mockito.when(connection.getAutoCommit()) .thenReturn(false); JdbcUtil.commit(connection); Mockito.verify(connection) .commit(); }
@Test void commitWithAutoCommit() throws SQLException { Connection connection = Mockito.mock(Connection.class); Mockito.when(connection.getAutoCommit()) .thenReturn(true); JdbcUtil.commit(connection); Mockito.verify(connection, Mockito.never()) .commit(); }