vamossagar12 commented on a change in pull request #9508: URL: https://github.com/apache/kafka/pull/9508#discussion_r532213742
########## File path: streams/src/test/java/org/apache/kafka/streams/state/internals/CachingInMemoryKeyValueStoreTest.java ########## @@ -359,6 +361,31 @@ public void shouldReverseIterateOverRange() { ), results); } + @Test + public void shouldGetRecordsWithPrefixKey() { + final List<KeyValue<Bytes, byte[]>> entries = new ArrayList<>(); + entries.add(new KeyValue<>(bytesKey("k1"), bytesValue("1"))); + entries.add(new KeyValue<>(bytesKey("k2"), bytesValue("2"))); + entries.add(new KeyValue<>(bytesKey("p2"), bytesValue("2"))); + entries.add(new KeyValue<>(bytesKey("p1"), bytesValue("2"))); + entries.add(new KeyValue<>(bytesKey("p0"), bytesValue("2"))); + store.putAll(entries); + final KeyValueIterator<Bytes, byte[]> keysWithPrefix = store.prefixScan("p", new StringSerializer()); + final List<String> keys = new ArrayList<>(); + final List<String> values = new ArrayList<>(); + int numberOfKeysReturned = 0; + + while (keysWithPrefix.hasNext()) { + final KeyValue<Bytes, byte[]> next = keysWithPrefix.next(); + keys.add(next.key.toString()); + values.add(new String(next.value)); + numberOfKeysReturned++; + } + assertThat(numberOfKeysReturned, is(3)); + assertThat(keys, is(Arrays.asList("p0", "p1", "p2"))); + assertThat(values, is(Arrays.asList("2", "2", "2"))); + } Review comment: @cadonna , I noticed that for this particular Test class, some test cases like `shouldDelegateDeprecatedInit` and `shouldDelegateInit` use mocking the `inner` store and other ones use the explicitly created object. If you are ok, I can create a separate ticket and take care of making all test cases similar to `MeteredKeyValueStoreTest` where all of them use the same mocked inner store and let this one as is. Let me know if that's ok with you. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org