@Test public void testClose() throws Exception { List<String> listOfOneElement = ImmutableList.of(TEST_VALUE, TEST_VALUE); when(stream.iterator()).thenReturn(listOfOneElement.iterator()); doNothing().when(stream).cancel(); try (ResultScanner<String> closedScanner = new RowResultScanner<>(stream, TEST_ARRAY)) { assertEquals(TEST_VALUE, closedScanner.next()); } verify(stream).iterator(); verify(stream).cancel(); }
@Override public void close() { if (iterator.hasNext()) { stream.cancel(); } }
RowResultScanner implements ResultScanner<T> { @Override public void close() { if (iterator.hasNext()) { stream.cancel(); } } }
RowResultScanner implements ResultScanner<T> { @Override public void close() { if (iterator.hasNext()) { stream.cancel(); } } RowResultScanner(ServerStream<T> stream, T[] arr); }
RowResultScanner implements ResultScanner<T> { @Override public void close() { if (iterator.hasNext()) { stream.cancel(); } } RowResultScanner(ServerStream<T> stream, T[] arr); @Override T next(); @Override T[] next(int count); @Override int available(); @Override void close(); }
RowResultScanner implements ResultScanner<T> { @Override public void close() { if (iterator.hasNext()) { stream.cancel(); } } RowResultScanner(ServerStream<T> stream, T[] arr); @Override T next(); @Override T[] next(int count); @Override int available(); @Override void close();  }