@Test public void testPostFeedEntriesEmptyDate() throws Exception { Transaction txn = new Transaction(null, false); List<SyndEntry> entries = new ArrayList<>(); entries.add(new SyndEntryImpl()); SyndEntry entry = new SyndEntryImpl(); entry.setUpdatedDate(new Date()); entries.add(entry); String body = "<p> (" + entry.getUpdatedDate().toString() + ")</p>"; Message msg = new Message(new MessageId(getRandomId()), blogGroupId, 0, getRandomBytes(42)); BlogPost post = new BlogPost(msg, null, localAuthor); context.checking(new Expectations() {{ oneOf(db).startTransaction(false); will(returnValue(txn)); oneOf(clock).currentTimeMillis(); will(returnValue(42L)); oneOf(blogPostFactory) .createBlogPost(feed.getBlogId(), 42L, null, localAuthor, body); will(returnValue(post)); oneOf(blogManager).addLocalPost(txn, post); oneOf(db).commitTransaction(txn); oneOf(db).endTransaction(txn); }}); feedManager.postFeedEntries(feed, entries); }
long postFeedEntries(Feed feed, List<SyndEntry> entries) throws DbException { long lastEntryTime = feed.getLastEntryTime(); Transaction txn = db.startTransaction(false); try { Collections.sort(entries, getEntryComparator()); for (SyndEntry entry : entries) { long entryTime; if (entry.getPublishedDate() != null) { entryTime = entry.getPublishedDate().getTime(); } else if (entry.getUpdatedDate() != null) { entryTime = entry.getUpdatedDate().getTime(); } else { LOG.warning("Entry has no date, ignored."); continue; } if (entryTime > feed.getLastEntryTime()) { postEntry(txn, feed, entry); if (entryTime > lastEntryTime) lastEntryTime = entryTime; } } db.commitTransaction(txn); } finally { db.endTransaction(txn); } return lastEntryTime; }
FeedManagerImpl implements FeedManager, Client, EventListener,
		BlogManager.RemoveBlogHook { long postFeedEntries(Feed feed, List<SyndEntry> entries) throws DbException { long lastEntryTime = feed.getLastEntryTime(); Transaction txn = db.startTransaction(false); try { Collections.sort(entries, getEntryComparator()); for (SyndEntry entry : entries) { long entryTime; if (entry.getPublishedDate() != null) { entryTime = entry.getPublishedDate().getTime(); } else if (entry.getUpdatedDate() != null) { entryTime = entry.getUpdatedDate().getTime(); } else { LOG.warning("Entry has no date, ignored."); continue; } if (entryTime > feed.getLastEntryTime()) { postEntry(txn, feed, entry); if (entryTime > lastEntryTime) lastEntryTime = entryTime; } } db.commitTransaction(txn); } finally { db.endTransaction(txn); } return lastEntryTime; } }
FeedManagerImpl implements FeedManager, Client, EventListener,
		BlogManager.RemoveBlogHook { long postFeedEntries(Feed feed, List<SyndEntry> entries) throws DbException { long lastEntryTime = feed.getLastEntryTime(); Transaction txn = db.startTransaction(false); try { Collections.sort(entries, getEntryComparator()); for (SyndEntry entry : entries) { long entryTime; if (entry.getPublishedDate() != null) { entryTime = entry.getPublishedDate().getTime(); } else if (entry.getUpdatedDate() != null) { entryTime = entry.getUpdatedDate().getTime(); } else { LOG.warning("Entry has no date, ignored."); continue; } if (entryTime > feed.getLastEntryTime()) { postEntry(txn, feed, entry); if (entryTime > lastEntryTime) lastEntryTime = entryTime; } } db.commitTransaction(txn); } finally { db.endTransaction(txn); } return lastEntryTime; } @Inject  FeedManagerImpl(@Scheduler ScheduledExecutorService scheduler,
			@IoExecutor Executor ioExecutor, DatabaseComponent db,
			ContactGroupFactory contactGroupFactory, ClientHelper clientHelper,
			BlogManager blogManager, BlogPostFactory blogPostFactory,
			FeedFactory feedFactory, SocketFactory torSocketFactory,
			Clock clock, Dns noDnsLookups); }
FeedManagerImpl implements FeedManager, Client, EventListener,
		BlogManager.RemoveBlogHook { long postFeedEntries(Feed feed, List<SyndEntry> entries) throws DbException { long lastEntryTime = feed.getLastEntryTime(); Transaction txn = db.startTransaction(false); try { Collections.sort(entries, getEntryComparator()); for (SyndEntry entry : entries) { long entryTime; if (entry.getPublishedDate() != null) { entryTime = entry.getPublishedDate().getTime(); } else if (entry.getUpdatedDate() != null) { entryTime = entry.getUpdatedDate().getTime(); } else { LOG.warning("Entry has no date, ignored."); continue; } if (entryTime > feed.getLastEntryTime()) { postEntry(txn, feed, entry); if (entryTime > lastEntryTime) lastEntryTime = entryTime; } } db.commitTransaction(txn); } finally { db.endTransaction(txn); } return lastEntryTime; } @Inject  FeedManagerImpl(@Scheduler ScheduledExecutorService scheduler,
			@IoExecutor Executor ioExecutor, DatabaseComponent db,
			ContactGroupFactory contactGroupFactory, ClientHelper clientHelper,
			BlogManager blogManager, BlogPostFactory blogPostFactory,
			FeedFactory feedFactory, SocketFactory torSocketFactory,
			Clock clock, Dns noDnsLookups); @Override void eventOccurred(Event e); @Override void createLocalState(Transaction txn); @Override void addFeed(String url); @Override void removeFeed(Feed feed); @Override void removingBlog(Transaction txn, Blog b); @Override List<Feed> getFeeds(); }
FeedManagerImpl implements FeedManager, Client, EventListener,
		BlogManager.RemoveBlogHook { long postFeedEntries(Feed feed, List<SyndEntry> entries) throws DbException { long lastEntryTime = feed.getLastEntryTime(); Transaction txn = db.startTransaction(false); try { Collections.sort(entries, getEntryComparator()); for (SyndEntry entry : entries) { long entryTime; if (entry.getPublishedDate() != null) { entryTime = entry.getPublishedDate().getTime(); } else if (entry.getUpdatedDate() != null) { entryTime = entry.getUpdatedDate().getTime(); } else { LOG.warning("Entry has no date, ignored."); continue; } if (entryTime > feed.getLastEntryTime()) { postEntry(txn, feed, entry); if (entryTime > lastEntryTime) lastEntryTime = entryTime; } } db.commitTransaction(txn); } finally { db.endTransaction(txn); } return lastEntryTime; } @Inject  FeedManagerImpl(@Scheduler ScheduledExecutorService scheduler,
			@IoExecutor Executor ioExecutor, DatabaseComponent db,
			ContactGroupFactory contactGroupFactory, ClientHelper clientHelper,
			BlogManager blogManager, BlogPostFactory blogPostFactory,
			FeedFactory feedFactory, SocketFactory torSocketFactory,
			Clock clock, Dns noDnsLookups); @Override void eventOccurred(Event e); @Override void createLocalState(Transaction txn); @Override void addFeed(String url); @Override void removeFeed(Feed feed); @Override void removingBlog(Transaction txn, Blog b); @Override List<Feed> getFeeds();  }