OntologyCacheImpl implements OntologyCache { @Override public void clearCacheImports(Resource ontologyIRI) { Optional<Cache<String, Ontology>> optCache = getOntologyCache(); optCache.ifPresent(cache -> { Set<String> cachesToRemove = new HashSet<>(); for (Cache.Entry<String, Ontology> entry : cache) { Set<? extends Resource> importedIRIs = entry.getValue().getImportedOntologyIRIs(); if (importedIRIs.contains(ontologyIRI)) { cachesToRemove.add(entry.getKey()); } } cache.removeAll(cachesToRemove); }); }  @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 clearCacheImportsWithHitTest() throws Exception { service.clearCacheImports(ontologyIRI); verify(cache).removeAll(Collections.singleton(key)); }
@Test public void clearCacheImportsWithMissTest() throws Exception { service.clearCacheImports(vf.createIRI("http: verify(cache).removeAll(Collections.emptySet()); }