### Question:
TransactionLogFileInformation implements LogFileInformation { @Override public long getFirstEntryId( long version ) throws IOException { Long logHeader = logHeaderCache.getLogHeader( version ); if ( logHeader != null ) { return logHeader + 1; } if ( logFiles.versionExists( version ) ) { long previousVersionLastCommittedTx = logFiles.extractHeader( version ).lastCommittedTxId; logHeaderCache.putHeader( version, previousVersionLastCommittedTx ); return previousVersionLastCommittedTx + 1; } return -1; } TransactionLogFileInformation( LogFiles logFiles, LogHeaderCache logHeaderCache, TransactionLogFilesContext context ); @Override long getFirstExistingEntryId(); @Override long getFirstEntryId( long version ); @Override long getLastEntryId(); @Override long getFirstStartRecordTimestamp( long version ); @Override boolean transactionExistsOnDisk( long transactionId );  }### Answer:
@Test public void shouldReadAndCacheFirstCommittedTransactionIdForAGivenVersionWhenNotCached() throws Exception { TransactionLogFileInformation info = new TransactionLogFileInformation( logFiles, logHeaderCache, context ); long expected = 5; long version = 10L; when( logHeaderCache.getLogHeader( version ) ).thenReturn( null ); when( logFiles.versionExists( version ) ).thenReturn( true ); when( logFiles.extractHeader( version ) ).thenReturn( new LogHeader( (byte) -1, -1L, expected - 1L ) ); long firstCommittedTxId = info.getFirstEntryId( version ); assertEquals( expected, firstCommittedTxId ); verify( logHeaderCache, times( 1 ) ).putHeader( version, expected - 1 ); }
@Test public void shouldReadFirstCommittedTransactionIdForAGivenVersionWhenCached() throws Exception { TransactionLogFileInformation info = new TransactionLogFileInformation( logFiles, logHeaderCache, context ); long expected = 5; long version = 10L; when( logHeaderCache.getLogHeader( version ) ).thenReturn( expected - 1 ); long firstCommittedTxId = info.getFirstEntryId( version ); assertEquals( expected, firstCommittedTxId ); }