CacheEntry { @Override public int hashCode() { return key.hashCode(); } CacheEntry(KeyType key, ValueType value); KeyType getKey(); ValueType getValue(); @Override int hashCode(); @Override boolean equals(Object object); @Override String toString();  }
@Test public void hashCodeAndEqualsAreSame() { String key = getRandomString(); String value = getRandomString(); CacheEntry<String, String> cacheEntry = new CacheEntry<>(key, value); CacheEntry<String, String> cacheEntry2 = new CacheEntry<>(key, value); assertEquals(cacheEntry.hashCode(), cacheEntry2.hashCode()); assertEquals(cacheEntry, cacheEntry2); }