MemoryDataStore implements DataStore<K, E> { @Override public Collection<K> keys() { return new LinkedList<>(store.keySet()); } MemoryDataStore(Class<E> entityType); @Override boolean hasKey(K key); @Override boolean save(K key, E entity); @Override boolean delete(K key); @Override E retrieve(K key); @Override Collection<K> keys(); @Override synchronized Collection<E> retrieveAll(); @Override Class<E> getEntityType(); @Override void truncate();  }
@Test public void testKeys() { dataStore.save("1", new Person()); dataStore.save("2", new Person()); dataStore.save("3", new Person()); assertThat(dataStore.keys(), containsInAnyOrder("1", "2", "3")); }