### Question:
Journal { public void removeEntry(int index) throws IndexOutOfBoundsException { if (index >= this.entries.size()) { throw new IndexOutOfBoundsException(index + " > " + this.entries.size()); } final Iterator<JournalEntry> iterator = this.entries.iterator(); for (int i = 0; i <= index; i++) { iterator.next(); } iterator.remove(); } Journal(SubscriptionData subscription, LoggerPersistenceManager persistenceManager);  Journal(SubscriptionData subscription); void addEntries(List<JournalEntry> newEntries); List<JournalEntry> getEntries(); void removeEntry(int index); void clear(); void flush();  }### Answer:
@Test public void removeEntryTest() { final Journal logger = new Journal(null, JournalTest.MANAGER); final List<JournalEntry> entriesToAdd = new ArrayList<JournalEntry>(5); for (int i = 0; i < 5; i++) { entriesToAdd.add(new JournalEntry("my " + i + " entry")); } final List<JournalEntry> remainingEntries = new ArrayList<JournalEntry>(entriesToAdd); logger.addEntries(entriesToAdd); logger.removeEntry(2); remainingEntries.remove(2); final List<JournalEntry> loggedEntries = logger.getEntries(); Assert.assertEquals(4, loggedEntries.size()); Assert.assertEquals(remainingEntries.size(), loggedEntries.size()); for (int i = 0; i < remainingEntries.size(); i++) { Assert.assertEquals(remainingEntries.get(i), loggedEntries.get(i)); } Assert.assertFalse(loggedEntries.contains(entriesToAdd.get(2))); }
@Test(expected = IndexOutOfBoundsException.class) public void removeOutOfBoundsTest() { final Journal logger = new Journal(null, JournalTest.MANAGER); logger.removeEntry(3); }