@Test public void defaultLastDownloadedWhenNoDownloadsUsesNewestDownloadDate() throws Exception { OffsetDateTime expected = OffsetDateTime.now(); FluentAsset asset1 = mockAsset(NAME, 1); AssetBlob blob1 = mockBlob(expected.minus(1, MILLIS)); when(asset1.blob()).thenReturn(Optional.of(blob1)); FluentAsset asset2 = mockAsset(NAME, 2); AssetBlob blob2 = mockBlob(expected); when(asset2.blob()).thenReturn(Optional.of(blob2)); FluentAsset asset3 = mockAsset(NAME, 3); AssetBlob blob3 = mockBlob(expected.minus(2, MILLIS)); when(asset3.blob()).thenReturn(Optional.of(blob3)); Collection<Asset> assets = ImmutableList.of(asset1, asset2, asset3); assertThat(underTest.lastDownloaded(assets).isPresent(), is(false)); }
@VisibleForTesting Optional<OffsetDateTime> lastDownloaded(final Collection<? extends Asset> assets) { return assets.stream() .map(Asset::lastDownloaded) .filter(Optional::isPresent) .map(Optional::get) .max(OffsetDateTime::compareTo); }
DefaultSearchDocumentProducer extends ComponentSupport implements SearchDocumentProducer { @VisibleForTesting Optional<OffsetDateTime> lastDownloaded(final Collection<? extends Asset> assets) { return assets.stream() .map(Asset::lastDownloaded) .filter(Optional::isPresent) .map(Optional::get) .max(OffsetDateTime::compareTo); } }
DefaultSearchDocumentProducer extends ComponentSupport implements SearchDocumentProducer { @VisibleForTesting Optional<OffsetDateTime> lastDownloaded(final Collection<? extends Asset> assets) { return assets.stream() .map(Asset::lastDownloaded) .filter(Optional::isPresent) .map(Optional::get) .max(OffsetDateTime::compareTo); } @Inject  DefaultSearchDocumentProducer(final Set<SearchDocumentExtension> documentExtensions); }
DefaultSearchDocumentProducer extends ComponentSupport implements SearchDocumentProducer { @VisibleForTesting Optional<OffsetDateTime> lastDownloaded(final Collection<? extends Asset> assets) { return assets.stream() .map(Asset::lastDownloaded) .filter(Optional::isPresent) .map(Optional::get) .max(OffsetDateTime::compareTo); } @Inject  DefaultSearchDocumentProducer(final Set<SearchDocumentExtension> documentExtensions); @Override String getDocument(final FluentComponent component, final Map<String, Object> commonFields); }
DefaultSearchDocumentProducer extends ComponentSupport implements SearchDocumentProducer { @VisibleForTesting Optional<OffsetDateTime> lastDownloaded(final Collection<? extends Asset> assets) { return assets.stream() .map(Asset::lastDownloaded) .filter(Optional::isPresent) .map(Optional::get) .max(OffsetDateTime::compareTo); } @Inject  DefaultSearchDocumentProducer(final Set<SearchDocumentExtension> documentExtensions); @Override String getDocument(final FluentComponent component, final Map<String, Object> commonFields);  }