CacheInfo { public static boolean invalidateAsset(final Asset asset) { checkNotNull(asset); final NestedAttributesMap cache = asset.attributes().child(CACHE); return !INVALIDATED.equals(cache.set(CACHE_TOKEN, INVALIDATED)); } CacheInfo(final DateTime lastVerified, @Nullable final String cacheToken); DateTime getLastVerified(); @Nullable String getCacheToken(); boolean isInvalidated(); @Override String toString(); @Nullable static CacheInfo extractFromAsset(final Asset asset); @Nullable static CacheInfo extractFromAsset(final NestedAttributesMap attributes); static void applyToAsset(final Asset asset, final CacheInfo cacheInfo); static boolean invalidateAsset(final Asset asset); @VisibleForTesting
  static final String CACHE; @VisibleForTesting
  static final String CACHE_TOKEN; @VisibleForTesting
  static final String LAST_VERIFIED; @VisibleForTesting
  static final String INVALIDATED; }
@Test public void invalidateAsset() { Asset asset = mockAsset(DateTime.now(), "foo-bar"); assertThat(CacheInfo.invalidateAsset(asset), equalTo(true)); assertThat(asset.attributes().child(CacheInfo.CACHE).get(CacheInfo.CACHE_TOKEN, String.class), equalTo(INVALIDATED)); assertThat(CacheInfo.invalidateAsset(asset), equalTo(false)); assertThat(asset.attributes().child(CacheInfo.CACHE).get(CacheInfo.CACHE_TOKEN, String.class), equalTo(INVALIDATED)); }