### Question:
UUIDSequence implements KeySequence { @Override public Iterator<CharSequence> nextReaderKeys(long maxKeys) { return new KeySequenceIterator(this, maxKeys); } UUIDSequence(KeySequenceConfig keySequenceConfig); @Override CharSequence nextReaderKey(); @Override CharSequence nextWriterKey(); @Override long readerKeysAvailable(); @Override KeySequenceConfig getConfig(boolean sharedInstance); @Override Iterator<CharSequence> nextReaderKeys(long maxKeys); @Override boolean equals(Object obj); @Override int hashCode(); static final int RESERVED_KEYS; }### Answer:
@Test public void nextAvailableKeysNextReturnsNullIfReaderIndexEqualsInitialWriterIndex() { KeySequenceConfig config = createDefaultTestKeySequenceConfig(); KeySequence sequence = createDefaultTestUUIDSequence(config); Iterator<CharSequence> iterator = sequence.nextReaderKeys(1); CharSequence next = iterator.next(); assertNull(next); }
@Test public void nextAvailableKeysNextReturnsNextReaderKeyIfReaderIndexLowerThanWriterIndex() { CharSequence expectedFirstKey = getNextExpectedKey(RESERVED_KEYS + 1); CharSequence expectedSecondKey = getNextExpectedKey(RESERVED_KEYS + 2); KeySequenceConfig config = createDefaultTestWriterIndexConfig(RESERVED_KEYS + 2); KeySequence sequence = createDefaultTestUUIDSequence(config); Iterator<CharSequence> iterator = sequence.nextReaderKeys(2); CharSequence readerKey1 = iterator.next(); CharSequence readerKey2 = iterator.next(); assertEquals(expectedFirstKey, readerKey1); assertEquals(expectedSecondKey, readerKey2); }