@Test public void responseWithMaxAgeShouldBeStored() { Headers headers = new Headers().add(HeaderConstants.CACHE_CONTROL, "max-age=10"); assertTrue(helper.shouldBeStored(new HTTPResponse(Status.OK, headers))); }
boolean shouldBeStored(HTTPResponse response) { boolean hasValidator = response.getHeaders().getLastModified().isPresent() || response.getHeaders().getETag().isPresent(); boolean hasExpiry = response.getHeaders().getExpires().isPresent() || (OptionalUtils.exists(response.getHeaders().getCacheControl(), cc -> cc.getMaxAge() > 0)); return hasExpiry || hasValidator; }
HTTPCacheHelper { boolean shouldBeStored(HTTPResponse response) { boolean hasValidator = response.getHeaders().getLastModified().isPresent() || response.getHeaders().getETag().isPresent(); boolean hasExpiry = response.getHeaders().getExpires().isPresent() || (OptionalUtils.exists(response.getHeaders().getCacheControl(), cc -> cc.getMaxAge() > 0)); return hasExpiry || hasValidator; } }
HTTPCacheHelper { boolean shouldBeStored(HTTPResponse response) { boolean hasValidator = response.getHeaders().getLastModified().isPresent() || response.getHeaders().getETag().isPresent(); boolean hasExpiry = response.getHeaders().getExpires().isPresent() || (OptionalUtils.exists(response.getHeaders().getCacheControl(), cc -> cc.getMaxAge() > 0)); return hasExpiry || hasValidator; } HTTPCacheHelper(CacheHeaderBuilder cacheHeaderBuilder); }
HTTPCacheHelper { boolean shouldBeStored(HTTPResponse response) { boolean hasValidator = response.getHeaders().getLastModified().isPresent() || response.getHeaders().getETag().isPresent(); boolean hasExpiry = response.getHeaders().getExpires().isPresent() || (OptionalUtils.exists(response.getHeaders().getCacheControl(), cc -> cc.getMaxAge() > 0)); return hasExpiry || hasValidator; } HTTPCacheHelper(CacheHeaderBuilder cacheHeaderBuilder);  }
HTTPCacheHelper { boolean shouldBeStored(HTTPResponse response) { boolean hasValidator = response.getHeaders().getLastModified().isPresent() || response.getHeaders().getETag().isPresent(); boolean hasExpiry = response.getHeaders().getExpires().isPresent() || (OptionalUtils.exists(response.getHeaders().getCacheControl(), cc -> cc.getMaxAge() > 0)); return hasExpiry || hasValidator; } HTTPCacheHelper(CacheHeaderBuilder cacheHeaderBuilder);   }