@Test
  public void testAll() {
    Counter allsCounter = mock(Counter.class);
    when(this.keyValueStoreMetrics.alls()).thenReturn(allsCounter);

    for (int i = 0; i < 10; i++) {
      this.inMemoryKeyValueStore.put(key(OTHER_KEY_PREFIX, i), value(OTHER_VALUE_PREFIX, i));
      this.inMemoryKeyValueStore.put(key(i), value(i));
    }
    KeyValueIterator<byte[], byte[]> all = this.inMemoryKeyValueStore.all();

    // all entries of one prefix comes first due to ordering
    for (int i = 0; i < 10; i++) {
      assertEntryEquals(key(i), value(i), all.next());
    }
    for (int i = 0; i < 10; i++) {
      assertEntryEquals(key(OTHER_KEY_PREFIX, i), value(OTHER_VALUE_PREFIX, i), all.next());
    }
    assertFalse(all.hasNext());

    verify(allsCounter).inc();

    // key size increments: 10 calls for each prefix
    verify(this.bytesReadCounter, times(10)).inc(DEFAULT_KEY_LENGTH);
    // all keys using OTHER_KEY_PREFIX have the same length
    int otherKeyLength = key(OTHER_KEY_PREFIX, 0).length;
    verify(this.bytesReadCounter, times(10)).inc(otherKeyLength);

    // value size increments: 10 calls for each prefix
    verify(this.bytesReadCounter, times(10)).inc(DEFAULT_VALUE_LENGTH);
    // all values using OTHER_VALUE_PREFIX have the same length
    int otherValueLength = value(OTHER_VALUE_PREFIX, 0).length;
    verify(this.bytesReadCounter, times(10)).inc(otherValueLength);
  }
The length of the result of {@link #value(int)} will always be the same, so this can be used as the length for any
key produced by {@link #value(int)}.
samza-kv-inmemory/src/test/java/org/apache/samza/storage/kv/inmemory/TestInMemoryKeyValueStore.java