OntologyCacheImpl implements OntologyCache { @Override public void removeFromCache(String recordIdStr, String commitIdStr) { String key = generateKey(recordIdStr, commitIdStr); getOntologyCache().ifPresent(cache -> { if (cache.containsKey(key)) { cache.remove(key); } }); }  @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 removeFromCacheTest() throws Exception { when(cache.containsKey(anyString())).thenReturn(true); service.removeFromCache("test", "test"); verify(cache).containsKey("test&test"); verify(cache).remove("test&test"); }
@Test public void removeFromCacheWhenNotContained() throws Exception { when(cache.containsKey(anyString())).thenReturn(false); service.removeFromCache("test", "test"); verify(cache).containsKey("test&test"); verify(cache, times(0)).remove("test&test"); }