@Test public void testResponseWherePayloadHasBeenRemoved() throws IOException { HTTPRequest request = new HTTPRequest(DUMMY_URI); Payload payload = mock(Payload.class); when(payload.isAvailable()).thenReturn(false); CacheItem item = new DefaultCacheItem(new HTTPResponse(Optional.of(payload), Status.OK, new Headers())); assertTrue("The cached item was not stale", item.isStale(LocalDateTime.now())); when(cacheStorage.get(request)).thenReturn(item); HTTPResponse resolvedResponse = new HTTPResponse(createClosedPayload(), Status.OK, new Headers()); when(responseResolver.resolve(isA(HTTPRequest.class))).thenReturn(resolvedResponse); when(cacheStorage.insert(isA(HTTPRequest.class), eq(resolvedResponse))).thenReturn(resolvedResponse); HTTPResponse response = cache.execute(request); assertTrue("None match was not empty", request.getHeaders().getConditionals().getNoneMatch().isEmpty()); verify(responseResolver, atLeast(1)).resolve(isA(HTTPRequest.class)); assertTrue("response did not have payload", response.hasPayload()); assertTrue(response.getPayload().get().isAvailable()); }
public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } HTTPCache(CacheStorage storage, ResponseResolver resolver); }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } HTTPCache(CacheStorage storage, ResponseResolver resolver); void clear(); CacheStorage getStorage(); ResponseResolver getResolver(); CacheStatistics getStatistics(); HTTPResponse execute(final HTTPRequest request); HTTPResponse executeRefresh(final HTTPRequest request); void shutdown(); boolean isTranslateHEADToGET(); void setTranslateHEADToGET(boolean translateHEADToGET); }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } HTTPCache(CacheStorage storage, ResponseResolver resolver); void clear(); CacheStorage getStorage(); ResponseResolver getResolver(); CacheStatistics getStatistics(); HTTPResponse execute(final HTTPRequest request); HTTPResponse executeRefresh(final HTTPRequest request); void shutdown(); boolean isTranslateHEADToGET(); void setTranslateHEADToGET(boolean translateHEADToGET);  }