### Question:
ResultSetIterator implements RelationalInput { @Override public void close() throws Exception { if (!resultSet.isClosed()) { resultSet.close(); } if (!resultSet.isClosed()) { resultSet.getStatement().close(); } } ResultSetIterator(ResultSet resultSet);  ResultSetIterator(ResultSet resultSet, String relationName); @Override boolean hasNext(); @Override List<String> next(); @Override int numberOfColumns(); @Override String relationName(); @Override ImmutableList<String> columnNames(); @Override void close(); static final String UNKNOWN_RELATION_NAME; }### Answer:
@Test public void testClose() throws Exception { ResultSet resultSetMock = twoLinesResultSetFixture.getTestData(); Statement statementMock = mock(Statement.class); when(resultSetMock.getStatement()).thenReturn(statementMock); ResultSetIterator resultSetIterator = new ResultSetIterator(resultSetMock); resultSetIterator.close(); verify(resultSetMock).close(); verify(statementMock).close(); }
@Test public void testCloseAlreadyClosed() throws Exception { ResultSet resultSetMock = twoLinesResultSetFixture.getTestData(); when(resultSetMock.isClosed()).thenReturn(true); Statement statementMock = mock(Statement.class); when(statementMock.isClosed()).thenReturn(true); ResultSetIterator resultSetIterator = new ResultSetIterator(resultSetMock); when(resultSetMock.getStatement()).thenReturn(statementMock); resultSetIterator.close(); verify(resultSetMock, never()).close(); verify(statementMock, never()).close(); }