### Question:
EncodedSequentialLog implements SequentialLog<E> { @Override public void truncate(long seqNum) throws IOException, LogEntryNotFound { long truncationPos = persistenceNavigator.getAddressOfEntry(seqNum); persistence.truncate(truncationPos); persistenceNavigator.notifyTruncation(seqNum); } EncodedSequentialLog(BytePersistence persistence,
                              SequentialEntryCodec<E> codec,
                              PersistenceNavigator persistenceNavigator); @Override void append(List<E> entries); @Override List<E> subSequence(long start, long end); @Override boolean isEmpty(); @Override E getLastEntry(); @Override SequentialEntryIterator<E> iterator(); @Override void truncate(long seqNum); @Override void sync(); @Override void close();  }### Answer:
@Test public void notifiesTheNavigatorWhenTruncating() throws Exception { long truncationSeqNum = 33; context.checking(new Expectations() {{ ignoring(codec); ignoring(persistence); allowing(navigator).getAddressOfEntry(with(any(Long.class))); oneOf(navigator).notifyTruncation(truncationSeqNum); }}); log.truncate(truncationSeqNum); }
@Test public void processesTruncationRequestsByDelegatingThemToTheSuppliedPersistence() throws Exception { long entryAddress = 100; context.checking(new Expectations() {{ allowing(navigator).notifyTruncation(with(any(Long.class))); oneOf(navigator).getAddressOfEntry(seqNum(7)); will(returnValue(entryAddress)); oneOf(persistence).truncate(entryAddress); }}); log.truncate(seqNum(7)); }