### Question:
TransactionMonitor { public void startAtLastTransaction() { if (!running) { iterator = transactionLog.iterator(); while (iterator.nextTransactionState() == TransactionState.OK) { iterator.next(); } running = true; monitorThread.start(); } } TransactionMonitor(final TransactionLog transactionLog); void startAtFirstTransaction(); void startAtLastTransaction(); void stop(); void addListener(TransactionListener l); void removeListener(TransactionListener l);  }### Answer:
@Test(timeout=3000) public void testStartAtLastTransaction() throws InterruptedException { when(transactionIterator.nextTransactionState()) .thenReturn(TransactionState.OK) .thenReturn(TransactionState.OK) .thenReturn(TransactionState.OK) .thenReturn(TransactionState.OK) .thenReturn(TransactionState.EMPTY) .thenReturn(TransactionState.OK) .thenReturn(TransactionState.OK) .thenReturn(TransactionState.OK) .thenReturn(TransactionState.EMPTY); final CountDownLatch endSignal = new CountDownLatch(3); transactionMonitor.addListener(new TransactionListener() { int nextTransaction = 5; @Override public void onTransaction(Transaction t) { assertEquals(nextTransaction, t.getTxnHeader().getZxid()); nextTransaction++; endSignal.countDown(); logger.debug("test 2:" + nextTransaction); } @Override public void onPartialTransaction() { fail(); } @Override public void onCorruption() { fail(); } }); transactionMonitor.startAtLastTransaction(); endSignal.await(); }