@Test public void testGet() throws IOException { when(cacheController.isStale(cacheInfo)).thenReturn(false); doReturn(content).when(underTest).getCachedContent(cachedContext); Content foundContent = underTest.get(cachedContext); assertThat(foundContent, is(content)); }
@Override public Content get(final Context context) throws IOException { checkNotNull(context); Content content = maybeGetCachedContent(context); if (!isStale(context, content)) { return content; } if (proxyCooperation == null) { return doGet(context, content); } return proxyCooperation.cooperate(getRequestKey(context), failover -> { Content latestContent = content; if (failover) { latestContent = proxyCooperation.join(() -> maybeGetCachedContent(context)); if (!isStale(context, latestContent)) { return latestContent; } } return doGet(context, latestContent); }); }
ProxyFacetSupport extends FacetSupport implements ProxyFacet { @Override public Content get(final Context context) throws IOException { checkNotNull(context); Content content = maybeGetCachedContent(context); if (!isStale(context, content)) { return content; } if (proxyCooperation == null) { return doGet(context, content); } return proxyCooperation.cooperate(getRequestKey(context), failover -> { Content latestContent = content; if (failover) { latestContent = proxyCooperation.join(() -> maybeGetCachedContent(context)); if (!isStale(context, latestContent)) { return latestContent; } } return doGet(context, latestContent); }); } }
ProxyFacetSupport extends FacetSupport implements ProxyFacet { @Override public Content get(final Context context) throws IOException { checkNotNull(context); Content content = maybeGetCachedContent(context); if (!isStale(context, content)) { return content; } if (proxyCooperation == null) { return doGet(context, content); } return proxyCooperation.cooperate(getRequestKey(context), failover -> { Content latestContent = content; if (failover) { latestContent = proxyCooperation.join(() -> maybeGetCachedContent(context)); if (!isStale(context, latestContent)) { return latestContent; } } return doGet(context, latestContent); }); }  }
ProxyFacetSupport extends FacetSupport implements ProxyFacet { @Override public Content get(final Context context) throws IOException { checkNotNull(context); Content content = maybeGetCachedContent(context); if (!isStale(context, content)) { return content; } if (proxyCooperation == null) { return doGet(context, content); } return proxyCooperation.cooperate(getRequestKey(context), failover -> { Content latestContent = content; if (failover) { latestContent = proxyCooperation.join(() -> maybeGetCachedContent(context)); if (!isStale(context, latestContent)) { return latestContent; } } return doGet(context, latestContent); }); }  URI getRemoteUrl(); @Override Content get(final Context context); static boolean isDownloading(); @Override void invalidateProxyCaches(); }
ProxyFacetSupport extends FacetSupport implements ProxyFacet { @Override public Content get(final Context context) throws IOException { checkNotNull(context); Content content = maybeGetCachedContent(context); if (!isStale(context, content)) { return content; } if (proxyCooperation == null) { return doGet(context, content); } return proxyCooperation.cooperate(getRequestKey(context), failover -> { Content latestContent = content; if (failover) { latestContent = proxyCooperation.join(() -> maybeGetCachedContent(context)); if (!isStale(context, latestContent)) { return latestContent; } } return doGet(context, latestContent); }); }  URI getRemoteUrl(); @Override Content get(final Context context); static boolean isDownloading(); @Override void invalidateProxyCaches(); static final String BYPASS_HTTP_ERRORS_HEADER_NAME; static final String BYPASS_HTTP_ERRORS_HEADER_VALUE; }