RowResultScanner implements ResultScanner<T> { @Override public int available() { return stream.isReceiveReady() ? 1 : 0; } RowResultScanner(ServerStream<T> stream, T[] arr); @Override T next(); @Override T[] next(int count); @Override int available(); @Override void close();  }
@Test public void testAvailableOperation() { when(stream.isReceiveReady()).thenReturn(true); scanner = new RowResultScanner<>(stream, TEST_ARRAY); assertEquals(1, scanner.available()); when(stream.isReceiveReady()).thenReturn(false); assertEquals(0, scanner.available()); verify(stream, times(2)).isReceiveReady(); }