MemcachedResponseStore extends ResponseStore { @Override public void invalidate(String key) { checkNotNull(key); checkArgument(key.length() > 0, "key can not be empty"); if (!_readOnly) { _client.delete(buildKey(key)); } } MemcachedResponseStore(MemcachedClient client, String keyPrefix, boolean readOnly); @Override Optional<CachedResponse> get(String key); @Override void put(String key, CachedResponse response); @Override void invalidate(String key);  }
@Test(dataProvider = "invalidateData") public void invalidate(String prefix, boolean readOnly, String key, String memcacheKey) { MemcachedClient client = mock(MemcachedClient.class); MemcachedResponseStore store = new MemcachedResponseStore(client, prefix, readOnly); store.invalidate(key); if (!readOnly) { verify(client).delete(memcacheKey); } verifyNoMoreInteractions(client); }