### Question:
SpyMemcachedAdapter implements MemcachedAdapter { String getNamespacedKey(CacheNamespace cacheNamespace, String key) { String namespaceIndicator = getNamespaceIndicator(cacheNamespace); if (cacheNamespace.isNamespaceExpirationRequired() == false) { return namespaceIndicator + ":" + key; } String namespaceIndicatorKey = namespaceIndicator + NAMESPACE_NAME_SQUENCE_SEPARATOR; long namespaceSquence = memcachedClient.incr(namespaceIndicatorKey, 0L, System.currentTimeMillis(), DEFAULT_NAMESPACE_SEQUENCE_EXPIRY_SECONDS); return namespaceIndicatorKey + namespaceSquence + ":" + key; }  void setMemcachedClient(MemcachedClientIF memcachedClient); void setCacheKeyPrefix(String cacheKeyPrefix); @Override void init(OverridableReadOnlyProperties properties); @Override void destroy(); @Override Object get(CacheNamespace cacheNamespace, String key); @Override void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); @Override void delete(CacheNamespace cacheNamespace, String key); @Override long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); @Override long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); @Override void evictAll(CacheNamespace cacheNamespace); static final String PROPERTY_KEY_PREFIX; static final String HOST_PROPERTY_KEY; static final String HASH_ALGORITHM_PROPERTY_KEY; static final String OPERATION_TIMEOUT_MILLIS_PROPERTY_KEY; static final String TRANSCODER_PROPERTY_KEY; static final String CACHE_KEY_PREFIX_PROPERTY_KEY; static final String AUTH_GENERATOR_PROPERTY_KEY; static final String AUTH_WAIT_TIME_MILLIS_PROPERTY_KEY; static final String NAMESPACE_NAME_SQUENCE_SEPARATOR; static final int DEFAULT_NAMESPACE_SEQUENCE_EXPIRY_SECONDS; static final long DEFAULT_AUTH_WAIT_TIME_MILLIS; }### Answer:
@Test public void getNamespacedKey_namespaceExpirationRequired_false() throws Exception { CacheNamespace cacheNamespace = new CacheNamespace("authors", false); String namespacedKey = spyMemcachedAdapter.getNamespacedKey(cacheNamespace, "authors#4"); assertThat(namespacedKey).isEqualTo("hXm.authors:authors#4"); }
@Test public void getNamespacedKey_namespaceExpirationRequired_true() throws Exception { CacheNamespace cacheNamespace = new CacheNamespace("books", true); when(memcachedClient.incr(eq("hXm.books@"), eq(0L), anyLong(), eq(DEFAULT_NAMESPACE_SEQUENCE_EXPIRY_SECONDS))) .thenReturn(123L); String namspacedKey = spyMemcachedAdapter.getNamespacedKey(cacheNamespace, "books#1"); assertThat(namspacedKey).isEqualTo("hXm.books@123:books#1"); verify(memcachedClient).incr(eq("hXm.books@"), eq(0L), longCaptor.capture(), eq(DEFAULT_NAMESPACE_SEQUENCE_EXPIRY_SECONDS)); assertSystemCurrentTimeMillis(longCaptor.getValue()); }