### Question:
GuavaGraphCache implements GraphCache<Id, M> { @Override public ObjectVersionGraph<M> load(Id docId) { try { return cache.get(docId); } catch (ExecutionException e) { throw new RuntimeException(e); } } GuavaGraphCache(VersionStore<Id, M> versionStore,
                           CacheBuilder<Object, Object> cacheBuilder); @SuppressWarnings("unchecked")  GuavaGraphCache(VersionStore<Id, M> versionStore,
                           CacheBuilder<Object, Object> cacheBuilder,
                           GraphOptions<Id, M> graphOptions); static Function<VersionStore<Id, M>, GraphCache<Id, M>> guavaCacheBuilder(CacheBuilder<Object, Object> cacheBuilder); static Function<VersionStore<Id, M>, GraphCache<Id, M>> guavaCacheBuilder(CacheBuilder<Object, Object> cacheBuilder,
                                                                                             GraphOptions<Id, M> graphOptions); @Override ObjectVersionGraph<M> load(Id docId); @Override void refresh(Id docId); @Override void evict(Id docId); @Override void evict(Iterator<Id> docIds); @Override void evictAll();  }### Answer:
@Test public void load_and_refresh() { GuavaGraphCache<String, String> cache = newRefreshingCache(); String docId = randomUUID().toString(); ObjectVersionGraph<String> versionGraph = cache.load(docId); assertThat(versionGraph.isEmpty()).isTrue(); ObjectVersion<String> version = ObjectVersion.<String>builder() .changeset(ImmutableMap.of(ROOT.property("property"), "value")) .build(); documentStore.append(docId, ObjectVersionGraph.init(version).getTip()); documentStore.publish(); versionGraph = cache.load(docId); assertThat(versionGraph.isEmpty()).isFalse(); assertThat(versionGraph.getTip().getVersion()).isEqualTo(version); version = ObjectVersion.<String>builder() .changeset(ImmutableMap.of(ROOT.property("property"), "value2")) .build(); documentStore.append(docId, ObjectVersionGraph.init(version).getTip()); documentStore.publish(); versionGraph = cache.load(docId); assertThat(versionGraph.getTip().getVersion()).isEqualTo(version); cache = newRefreshingCache(); versionGraph = cache.load(docId); assertThat(versionGraph.getTip().getVersion()).isEqualTo(version); assertThat(cache.load(docId)).isSameAs(versionGraph); }
@Test public void return_empty_if_fetch_fails() throws InterruptedException { String docId = randomUUID().toString(); GuavaGraphCache<String, String> cache = newRefreshingCache(); ObjectVersion<String> version = ObjectVersion.<String>builder().build(); documentStore.append(docId, ObjectVersionGraph.init(version).getTip()); publish(cache, docId); assertThat(cache.load(docId).isEmpty()).isEqualTo(false); queryFactory.delete(documentVersion).where(documentVersion.revision.eq(version.revision)).execute(); Thread.sleep(10); assertThat(cache.load(docId).isEmpty()).isEqualTo(true); }