@Test public void lastVerifiedAndCacheTokenApply() { final DateTime now = DateTime.now(); final String cacheToken = "foo-bar"; NestedAttributesMap attributes = new NestedAttributesMap(P_ATTRIBUTES, Maps.<String, Object>newHashMap()); Asset asset = mock(Asset.class); when(asset.attributes()).thenReturn(attributes); CacheInfo cacheInfo = new CacheInfo(now, cacheToken); CacheInfo.applyToAsset(asset, cacheInfo); assertThat(asset.attributes().child(CacheInfo.CACHE).get(CacheInfo.LAST_VERIFIED, Date.class), equalTo(now.toDate())); assertThat(asset.attributes().child(CacheInfo.CACHE).get(CacheInfo.CACHE_TOKEN, String.class), equalTo(cacheToken)); }
public static void applyToAsset(final Asset asset, final CacheInfo cacheInfo) { checkNotNull(asset); checkNotNull(cacheInfo); final NestedAttributesMap cache = asset.attributes().child(CACHE); cache.set(LAST_VERIFIED, toDate(cacheInfo.getLastVerified())); cache.set(CACHE_TOKEN, cacheInfo.getCacheToken()); }
CacheInfo { public static void applyToAsset(final Asset asset, final CacheInfo cacheInfo) { checkNotNull(asset); checkNotNull(cacheInfo); final NestedAttributesMap cache = asset.attributes().child(CACHE); cache.set(LAST_VERIFIED, toDate(cacheInfo.getLastVerified())); cache.set(CACHE_TOKEN, cacheInfo.getCacheToken()); } }
CacheInfo { public static void applyToAsset(final Asset asset, final CacheInfo cacheInfo) { checkNotNull(asset); checkNotNull(cacheInfo); final NestedAttributesMap cache = asset.attributes().child(CACHE); cache.set(LAST_VERIFIED, toDate(cacheInfo.getLastVerified())); cache.set(CACHE_TOKEN, cacheInfo.getCacheToken()); } CacheInfo(final DateTime lastVerified, @Nullable final String cacheToken); }
CacheInfo { public static void applyToAsset(final Asset asset, final CacheInfo cacheInfo) { checkNotNull(asset); checkNotNull(cacheInfo); final NestedAttributesMap cache = asset.attributes().child(CACHE); cache.set(LAST_VERIFIED, toDate(cacheInfo.getLastVerified())); cache.set(CACHE_TOKEN, cacheInfo.getCacheToken()); } 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); }
CacheInfo { public static void applyToAsset(final Asset asset, final CacheInfo cacheInfo) { checkNotNull(asset); checkNotNull(cacheInfo); final NestedAttributesMap cache = asset.attributes().child(CACHE); cache.set(LAST_VERIFIED, toDate(cacheInfo.getLastVerified())); cache.set(CACHE_TOKEN, cacheInfo.getCacheToken()); } 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; }