AssetDataImpl implements AssetData { @Override public Date getLastModifiedDate() { long assetLastModification = asset.getLastModified(); Calendar created = null; if (assetLastModification == 0) { ValueMap resourceMap = asset.adaptTo(ValueMap.class); if (resourceMap != null) { created = resourceMap.get(JcrConstants.JCR_CREATED, Calendar.class); } assetLastModification = (null != created) ? created.getTimeInMillis() : 0; } return new Date(assetLastModification); } AssetDataImpl(@NotNull Asset asset); @Override String getId(); @Override Date getLastModifiedDate(); @Override String getFormat(); @Override String getUrl(); @Override String[] getTags();  }
@Test void testGetLastModifiedDate() { Asset asset = mock(Asset.class); when(asset.getLastModified()).thenReturn(0L); ValueMap valueMap = mock(ValueMap.class); when(asset.adaptTo(ValueMap.class)).thenReturn(valueMap); Calendar now = Calendar.getInstance(); when(valueMap.get(JcrConstants.JCR_CREATED, Calendar.class)).thenReturn(now); assertEquals(now.getTime(), new AssetDataImpl(asset).getLastModifiedDate()); }