### Question:
TransactionQueue { public void queue( TransactionToApply transaction ) throws Exception { if ( isEmpty() ) { first = last = transaction; } else { last.next( transaction ); last = transaction; } if ( ++size == maxSize ) { empty(); } } TransactionQueue( int maxSize, Applier applier ); void queue( TransactionToApply transaction ); void empty(); boolean isEmpty(); TransactionToApply first(); TransactionToApply last();  }### Answer:
@Test public void shouldLinkTogetherTransactions() throws Exception { Applier applier = mock( Applier.class ); int batchSize = 10; TransactionQueue queue = new TransactionQueue( batchSize, applier ); TransactionToApply[] txs = new TransactionToApply[batchSize]; for ( int i = 0; i < batchSize; i++ ) { queue.queue( txs[i] = new TransactionToApply( mock( TransactionRepresentation.class ) ) ); } verify( applier, times( 1 ) ).apply( any(), any() ); for ( int i = 0; i < txs.length - 1; i++ ) { assertEquals( txs[i + 1], txs[i].next() ); } }