@Test public void initializeWhenError() throws Exception { DefaultIconSetCache cache = mocker.getComponentUnderTest(); CacheFactory cacheFactory = mock(CacheFactory.class); when(cacheManager.getCacheFactory()).thenReturn(cacheFactory); Exception exception = new CacheException("ERROR"); when(cacheFactory.newCache(any(CacheConfiguration.class))).thenThrow(exception); Exception exceptionCaught = null; try { cache.initialize(); } catch(InitializationException e){ exceptionCaught = e; } assertNotNull(exceptionCaught); assertEquals("Failed to initialize the IconSet Cache.", exceptionCaught.getMessage()); assertEquals(exception, exceptionCaught.getCause()); }
@Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(ICON_SET_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException("Failed to initialize the IconSet Cache.", e); } }
DefaultIconSetCache implements IconSetCache, Initializable { @Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(ICON_SET_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException("Failed to initialize the IconSet Cache.", e); } } }
DefaultIconSetCache implements IconSetCache, Initializable { @Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(ICON_SET_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException("Failed to initialize the IconSet Cache.", e); } }  }
DefaultIconSetCache implements IconSetCache, Initializable { @Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(ICON_SET_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException("Failed to initialize the IconSet Cache.", e); } }  @Override void initialize(); @Override IconSet get(String name); @Override IconSet get(String name, String wikiId); @Override IconSet get(DocumentReference documentReference); @Override void put(String name, IconSet iconSet); @Override void put(String name, String wikiId, IconSet iconSet); @Override void put(DocumentReference documentReference, IconSet iconSet); @Override void clear(); @Override void clear(DocumentReference documentReference); @Override void clear(String name); @Override void clear(String name, String wikiId); }
DefaultIconSetCache implements IconSetCache, Initializable { @Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(ICON_SET_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException("Failed to initialize the IconSet Cache.", e); } }  @Override void initialize(); @Override IconSet get(String name); @Override IconSet get(String name, String wikiId); @Override IconSet get(DocumentReference documentReference); @Override void put(String name, IconSet iconSet); @Override void put(String name, String wikiId, IconSet iconSet); @Override void put(DocumentReference documentReference, IconSet iconSet); @Override void clear(); @Override void clear(DocumentReference documentReference); @Override void clear(String name); @Override void clear(String name, String wikiId);  }