@Test public void testCombinedFeedNotFound() { expect(datastore.get(feedId, CombinedFeed.class)).andReturn(null); replayAll(); testedClass.run(); verifyAll(); }
@Override public void run() { CombinedFeed fetchedCombinedFeed = datastore.get(combinedFeedID, CombinedFeed.class); if (fetchedCombinedFeed == null) { LOG.warn("There is no CombinedFeed for the ID: " + combinedFeedID); return; } List<FeedEntry> entries = fetchedCombinedFeed.getUrls().stream() .map(feedDownloader) .flatMap(Collection::stream) .map(entryMapper) .filter(Objects::nonNull) .sorted((e1, e2) -> e2.getPublishDate().compareTo(e1.getPublishDate())) .collect(Collectors.toList()); CombinedFeed combinedFeed = of(fetchedCombinedFeed).feedEntries(entries).build(); datastore.put(combinedFeedID, combinedFeed); LOG.debug("New entries for the CombinedFeed were downloaded [combined-feed={}, entries-count={}]", combinedFeed.getId(), entries.size()); }
FeedDownloadTask implements Runnable { @Override public void run() { CombinedFeed fetchedCombinedFeed = datastore.get(combinedFeedID, CombinedFeed.class); if (fetchedCombinedFeed == null) { LOG.warn("There is no CombinedFeed for the ID: " + combinedFeedID); return; } List<FeedEntry> entries = fetchedCombinedFeed.getUrls().stream() .map(feedDownloader) .flatMap(Collection::stream) .map(entryMapper) .filter(Objects::nonNull) .sorted((e1, e2) -> e2.getPublishDate().compareTo(e1.getPublishDate())) .collect(Collectors.toList()); CombinedFeed combinedFeed = of(fetchedCombinedFeed).feedEntries(entries).build(); datastore.put(combinedFeedID, combinedFeed); LOG.debug("New entries for the CombinedFeed were downloaded [combined-feed={}, entries-count={}]", combinedFeed.getId(), entries.size()); } }
FeedDownloadTask implements Runnable { @Override public void run() { CombinedFeed fetchedCombinedFeed = datastore.get(combinedFeedID, CombinedFeed.class); if (fetchedCombinedFeed == null) { LOG.warn("There is no CombinedFeed for the ID: " + combinedFeedID); return; } List<FeedEntry> entries = fetchedCombinedFeed.getUrls().stream() .map(feedDownloader) .flatMap(Collection::stream) .map(entryMapper) .filter(Objects::nonNull) .sorted((e1, e2) -> e2.getPublishDate().compareTo(e1.getPublishDate())) .collect(Collectors.toList()); CombinedFeed combinedFeed = of(fetchedCombinedFeed).feedEntries(entries).build(); datastore.put(combinedFeedID, combinedFeed); LOG.debug("New entries for the CombinedFeed were downloaded [combined-feed={}, entries-count={}]", combinedFeed.getId(), entries.size()); } FeedDownloadTask(Function<URL, List<SyndEntry>> feedDownloader, InMemoryDataStore datastore, String feedId); }
FeedDownloadTask implements Runnable { @Override public void run() { CombinedFeed fetchedCombinedFeed = datastore.get(combinedFeedID, CombinedFeed.class); if (fetchedCombinedFeed == null) { LOG.warn("There is no CombinedFeed for the ID: " + combinedFeedID); return; } List<FeedEntry> entries = fetchedCombinedFeed.getUrls().stream() .map(feedDownloader) .flatMap(Collection::stream) .map(entryMapper) .filter(Objects::nonNull) .sorted((e1, e2) -> e2.getPublishDate().compareTo(e1.getPublishDate())) .collect(Collectors.toList()); CombinedFeed combinedFeed = of(fetchedCombinedFeed).feedEntries(entries).build(); datastore.put(combinedFeedID, combinedFeed); LOG.debug("New entries for the CombinedFeed were downloaded [combined-feed={}, entries-count={}]", combinedFeed.getId(), entries.size()); } FeedDownloadTask(Function<URL, List<SyndEntry>> feedDownloader, InMemoryDataStore datastore, String feedId); @Override void run(); }
FeedDownloadTask implements Runnable { @Override public void run() { CombinedFeed fetchedCombinedFeed = datastore.get(combinedFeedID, CombinedFeed.class); if (fetchedCombinedFeed == null) { LOG.warn("There is no CombinedFeed for the ID: " + combinedFeedID); return; } List<FeedEntry> entries = fetchedCombinedFeed.getUrls().stream() .map(feedDownloader) .flatMap(Collection::stream) .map(entryMapper) .filter(Objects::nonNull) .sorted((e1, e2) -> e2.getPublishDate().compareTo(e1.getPublishDate())) .collect(Collectors.toList()); CombinedFeed combinedFeed = of(fetchedCombinedFeed).feedEntries(entries).build(); datastore.put(combinedFeedID, combinedFeed); LOG.debug("New entries for the CombinedFeed were downloaded [combined-feed={}, entries-count={}]", combinedFeed.getId(), entries.size()); } FeedDownloadTask(Function<URL, List<SyndEntry>> feedDownloader, InMemoryDataStore datastore, String feedId); @Override void run();  }