### Question:
SerializedKeyValueIterator implements KeyValueIterator<K, V> { @Override public KeyValue<K, V> next() { if (!hasNext()) { throw new NoSuchElementException(); } final KeyValue<Bytes, byte[]> next = bytesIterator.next(); return KeyValue.pair(serdes.keyFrom(next.key.get()), serdes.valueFrom(next.value)); } SerializedKeyValueIterator(final KeyValueIterator<Bytes, byte[]> bytesIterator,
                               final StateSerdes<K, V> serdes); @Override void close(); @Override K peekNextKey(); @Override boolean hasNext(); @Override KeyValue<K, V> next(); @Override void remove();  }### Answer:
@Test public void shouldReturnNextValueWhenItExists() throws Exception { assertThat(serializedKeyValueIterator.next(), equalTo(KeyValue.pair("hi", "there"))); assertThat(serializedKeyValueIterator.next(), equalTo(KeyValue.pair("hello", "world"))); }
@Test public void shouldThrowNoSuchElementOnNextWhenIteratorExhausted() throws Exception { advanceIteratorToEnd(); try { serializedKeyValueIterator.next(); fail("Expected NoSuchElementException on exhausted iterator"); } catch (final NoSuchElementException nse) { } }
@Test public void shouldReturnNextValueWhenItExists() { assertThat(serializedKeyValueIterator.next(), equalTo(KeyValue.pair("hi", "there"))); assertThat(serializedKeyValueIterator.next(), equalTo(KeyValue.pair("hello", "world"))); }
@Test public void shouldThrowNoSuchElementOnNextWhenIteratorExhausted() { advanceIteratorToEnd(); try { serializedKeyValueIterator.next(); fail("Expected NoSuchElementException on exhausted iterator"); } catch (final NoSuchElementException nse) { } }