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