### Question:
GapFreeAllEntriesLabelScanReader implements AllEntriesLabelScanReader { @Override public Iterator<NodeLabelRange> iterator() { return new GapFillingIterator( nodeLabelRanges.iterator(), (highId - 1) / nodeLabelRanges.rangeSize(), nodeLabelRanges.rangeSize() ); } GapFreeAllEntriesLabelScanReader( AllEntriesLabelScanReader nodeLabelRanges, long highId ); @Override long maxCount(); @Override void close(); @Override int rangeSize(); @Override Iterator<NodeLabelRange> iterator();  }### Answer:
@Test void shouldFillGapInBeginning() { int[] ranges = array( EMPTY_RANGE, EMPTY_RANGE, NON_EMPTY_RANGE ); GapFreeAllEntriesLabelScanReader reader = newGapFreeAllEntriesLabelScanReader( ranges ); Iterator<NodeLabelRange> iterator = reader.iterator(); assertRanges( iterator, ranges ); }
@Test void shouldFillGapInEnd() { int[] ranges = array( NON_EMPTY_RANGE, EMPTY_RANGE, EMPTY_RANGE ); GapFreeAllEntriesLabelScanReader reader = newGapFreeAllEntriesLabelScanReader( ranges ); Iterator<NodeLabelRange> iterator = reader.iterator(); assertRanges( iterator, ranges ); }
@Test void shouldFillGapInMiddle() { int[] ranges = array( EMPTY_RANGE, NON_EMPTY_RANGE, EMPTY_RANGE ); GapFreeAllEntriesLabelScanReader reader = newGapFreeAllEntriesLabelScanReader( ranges ); Iterator<NodeLabelRange> iterator = reader.iterator(); assertRanges( iterator, ranges ); }
@Test void shouldFillRandomGaps() { int numberOfRanges = random.intBetween( 50, 100 ); int[] ranges = new int[numberOfRanges]; for ( int rangeId = 0; rangeId < numberOfRanges; rangeId++ ) { ranges[rangeId] = random.nextInt( 1 << RANGE_SIZE ); } GapFreeAllEntriesLabelScanReader reader = newGapFreeAllEntriesLabelScanReader( ranges ); Iterator<NodeLabelRange> iterator = reader.iterator(); assertRanges( iterator, ranges ); }