@Test public void testEmpty() { Supplier<List<String>> supplier = mock(Supplier.class); Iterator<String> instance = new BulkBufferingEntryIterator<String>(10) { @Override protected List<String> loadNextChunk(int chunkSize) { return supplier.get(); } }; when(supplier.get()).thenReturn(Collections.emptyList()); assertThat(instance.hasNext()).isFalse(); assertThatThrownBy(instance::next).isInstanceOf(NoSuchElementException.class); verify(supplier).get(); }
@Override public boolean hasNext() { if (this.endOfStream) { return false; } if (this.buffer == null) { load(); } else if (this.nextPos >= this.buffer.size()) { if (this.buffer.size() < bufferSize) { this.endOfStream = true; } else { load(); } } return !this.endOfStream; }
BulkBufferingEntryIterator implements Iterator<T> { @Override public boolean hasNext() { if (this.endOfStream) { return false; } if (this.buffer == null) { load(); } else if (this.nextPos >= this.buffer.size()) { if (this.buffer.size() < bufferSize) { this.endOfStream = true; } else { load(); } } return !this.endOfStream; } }
BulkBufferingEntryIterator implements Iterator<T> { @Override public boolean hasNext() { if (this.endOfStream) { return false; } if (this.buffer == null) { load(); } else if (this.nextPos >= this.buffer.size()) { if (this.buffer.size() < bufferSize) { this.endOfStream = true; } else { load(); } } return !this.endOfStream; } BulkBufferingEntryIterator(int bufferSize); }
BulkBufferingEntryIterator implements Iterator<T> { @Override public boolean hasNext() { if (this.endOfStream) { return false; } if (this.buffer == null) { load(); } else if (this.nextPos >= this.buffer.size()) { if (this.buffer.size() < bufferSize) { this.endOfStream = true; } else { load(); } } return !this.endOfStream; } BulkBufferingEntryIterator(int bufferSize); @Override boolean hasNext(); @Override T next(); }
BulkBufferingEntryIterator implements Iterator<T> { @Override public boolean hasNext() { if (this.endOfStream) { return false; } if (this.buffer == null) { load(); } else if (this.nextPos >= this.buffer.size()) { if (this.buffer.size() < bufferSize) { this.endOfStream = true; } else { load(); } } return !this.endOfStream; } BulkBufferingEntryIterator(int bufferSize); @Override boolean hasNext(); @Override T next();  }