HashMapCacheService implements ICacheService { @Override public <K, V> ICache<K, V> getCache(final String cacheName) { HashMapCache<K, V> cache = caches.computeIfAbsent(cacheName, k -> new HashMapCache<>(useJavaSerialisation)); return cache; }  @Override void initialise(final Properties properties); @Override void shutdown(); @Override ICache<K, V> getCache(final String cacheName); static final String STATIC_CACHE; static final String JAVA_SERIALISATION_CACHE; }
@Test public void shouldReturnInstanceOfHashMapCache() { final ICache cache = service.getCache(CACHE_NAME); assertTrue(cache instanceof HashMapCache); }
@Test public void shouldCreateNewHashMapCacheIfOneDoesNotExist() { final ICache cache = service.getCache(CACHE_NAME); assertEquals(0, cache.size()); }
@Test public void shouldReUseCacheIfOneExists() throws CacheOperationException { final ICache<String, Integer> cache = service.getCache(CACHE_NAME); cache.put("key", 1); final ICache<String, Integer> sameCache = service.getCache(CACHE_NAME); assertEquals(1, sameCache.size()); assertEquals(new Integer(1), sameCache.get("key")); }