### Question:
CacheKey implements Cloneable, Serializable { public void update(Object object) { int baseHashCode = object == null ? 1 : ArrayUtil.hashCode(object); count++; checksum += baseHashCode; baseHashCode *= count; hashcode = multiplier * hashcode + baseHashCode; updateList.add(object); } CacheKey();  CacheKey(Object[] objects); int getUpdateCount(); void update(Object object); void updateAll(Object[] objects); @Override boolean equals(Object object); @Override int hashCode(); @Override String toString(); @Override CacheKey clone(); static final CacheKey NULL_CACHE_KEY; }### Answer:
@Test public void shouldDemonstrateEmptyAndNullKeysAreEqual() { CacheKey key1 = new CacheKey(); CacheKey key2 = new CacheKey(); assertEquals(key1, key2); assertEquals(key2, key1); key1.update(null); key2.update(null); assertEquals(key1, key2); assertEquals(key2, key1); key1.update(null); key2.update(null); assertEquals(key1, key2); assertEquals(key2, key1); }
@Test (expected = NotSerializableException.class) public void serializationExceptionTest() throws Exception { CacheKey cacheKey = new CacheKey(); cacheKey.update(new Object()); serialize(cacheKey); }
@Test public void serializationTest() throws Exception { CacheKey cacheKey = new CacheKey(); cacheKey.update("serializable"); Assert.assertEquals(cacheKey, serialize(cacheKey)); }
@Test void shouldDemonstrateEmptyAndNullKeysAreEqual() { CacheKey key1 = new CacheKey(); CacheKey key2 = new CacheKey(); assertEquals(key1, key2); assertEquals(key2, key1); key1.update(null); key2.update(null); assertEquals(key1, key2); assertEquals(key2, key1); key1.update(null); key2.update(null); assertEquals(key1, key2); assertEquals(key2, key1); }
@Test void serializationExceptionTest() { CacheKey cacheKey = new CacheKey(); cacheKey.update(new Object()); Assertions.assertThrows(NotSerializableException.class, () -> { serialize(cacheKey); }); }
@Test void serializationTest() throws Exception { CacheKey cacheKey = new CacheKey(); cacheKey.update("serializable"); Assertions.assertEquals(cacheKey, serialize(cacheKey)); }