### Question:
UriBasedAnalyzer extends FeedsAnalyzer { @Override public List<SyndEntry> getNewEntries(SyndFeed feed) { final List<SyndEntry> resultList = new ArrayList<SyndEntry>(); final Iterator<SyndEntry> entriesIterator = feed.getEntries().iterator(); while (entriesIterator.hasNext() && (resultList.size() < this.maxEntriesAmount)) { final SyndEntry aFeedEntry = entriesIterator.next(); if (!aFeedEntry.getUri().equals(this.lastKnownUri)) { resultList.add(aFeedEntry); } else { break; } } Collections.reverse(resultList); return resultList; } UriBasedAnalyzer(int maxEntriesAmount, String lastKnownUri); @Override List<SyndEntry> getNewEntries(SyndFeed feed);  }### Answer:
@Test public void noNewEntryTest() { final SyndFeed feed = new SyndFeedImpl(); feed.setEntries(Arrays.asList(createEntry("third", "ccc"), createEntry("second", "bbb"), createEntry("first", "aaa"))); final UriBasedAnalyzer analyzer = new UriBasedAnalyzer(10, "ccc"); final List<SyndEntry> entries = analyzer.getNewEntries(feed); Assert.assertTrue(entries.isEmpty()); }
@Test public void newEntriesTest() { final SyndFeed feed = new SyndFeedImpl(); feed.setEntries(Arrays.asList(createEntry("third", "ccc"), createEntry("second", "bbb"), createEntry("first", "aaa"))); final UriBasedAnalyzer analyzer = new UriBasedAnalyzer(10, "aaa"); final List<SyndEntry> entries = analyzer.getNewEntries(feed); Assert.assertEquals(2, entries.size()); Assert.assertEquals("second", entries.get(0).getTitle()); Assert.assertEquals("third", entries.get(1).getTitle()); }
@Test public void aLotOfNewEntriesTest() { final SyndFeed feed = new SyndFeedImpl(); feed.setEntries(Arrays.asList(createEntry("fourth", "ddd"), createEntry("third", "ccc"), createEntry("second", "bbb"), createEntry("first", "aaa"))); final UriBasedAnalyzer analyzer = new UriBasedAnalyzer(2, "aaa"); final List<SyndEntry> entries = analyzer.getNewEntries(feed); Assert.assertEquals(2, entries.size()); Assert.assertEquals("third", entries.get(0).getTitle()); Assert.assertEquals("fourth", entries.get(1).getTitle()); }