LruCacheManager implements CacheManager { int getCapacity() { return capacity; } LruCacheManager();   LruCacheManager(Map<String, String> properties); @Override void add(Object primaryKey, Object entity, Descriptor descriptor); @Override T get(Class<T> cls, Object primaryKey, Descriptor descriptor); @Override void evictInferredObjects(); @Override void setInferredClasses(Set<Class<?>> inferredClasses); @Override void close(); @Override boolean contains(Class<?> cls, Object identifier, Descriptor descriptor); @Override void evict(Class<?> cls, Object identifier, URI context); @Override void evict(Class<?> cls); @Override void evict(URI context); @Override void evictAll(); static final int DEFAULT_CAPACITY; }
@Test public void testInitWithDefaultCapacity() { assertEquals(LruCacheManager.DEFAULT_CAPACITY, manager.getCapacity()); }
@Test public void testInitWithCustomCapacity() { int capacity = 117; final Map<String, String> props = Collections .singletonMap(JOPAPersistenceProperties.LRU_CACHE_CAPACITY, Integer.toString(capacity)); this.manager = new LruCacheManager(props); assertEquals(capacity, manager.getCapacity()); }
@Test public void initializationWithInvalidCapacityUsesDefaultValue() { final Map<String, String> props = Collections .singletonMap(JOPAPersistenceProperties.LRU_CACHE_CAPACITY, "-111"); this.manager = new LruCacheManager(props); assertEquals(LruCacheManager.DEFAULT_CAPACITY, manager.getCapacity()); }