OntologyCacheImpl implements OntologyCache { @Override public Optional<Cache<String, Ontology>> getOntologyCache() { if (cacheManager != null) { return cacheManager.getCache(CACHE_NAME, String.class, Ontology.class); } return Optional.empty(); }  @Reference void setCacheManager(CacheManager cacheManager); @Override String generateKey(String recordIri, String commitIri); @Override Optional<Cache<String, Ontology>> getOntologyCache(); @Override void clearCacheImports(Resource ontologyIRI); @Override void clearCache(@Nonnull Resource recordId); @Override void removeFromCache(String recordIdStr, String commitIdStr);  }
@Test public void getOntologyCacheTest() throws Exception { Optional<Cache<String, Ontology>> result = service.getOntologyCache(); assertTrue(result.isPresent()); assertEquals(cache, result.get()); service.setCacheManager(null); result = service.getOntologyCache(); assertFalse(result.isPresent()); }