### Question:
PhysicalLogicalTransactionStore implements LogicalTransactionStore { @Override public TransactionMetadata getMetadataFor( long transactionId ) throws IOException { if ( transactionId <= BASE_TX_ID ) { return METADATA_FOR_EMPTY_STORE; } TransactionMetadata transactionMetadata = transactionMetadataCache.getTransactionMetadata( transactionId ); if ( transactionMetadata == null ) { try ( IOCursor<CommittedTransactionRepresentation> cursor = getTransactions( transactionId ) ) { while ( cursor.next() ) { CommittedTransactionRepresentation tx = cursor.get(); LogEntryCommit commitEntry = tx.getCommitEntry(); long committedTxId = commitEntry.getTxId(); long timeWritten = commitEntry.getTimeWritten(); TransactionMetadata metadata = transactionMetadataCache.cacheTransactionMetadata( committedTxId, tx.getStartEntry().getStartPosition(), tx.getStartEntry().getMasterId(), tx.getStartEntry().getLocalId(), LogEntryStart.checksum( tx.getStartEntry() ), timeWritten ); if ( committedTxId == transactionId ) { transactionMetadata = metadata; } } } if ( transactionMetadata == null ) { throw new NoSuchTransactionException( transactionId ); } } return transactionMetadata; } PhysicalLogicalTransactionStore( LogFiles logFiles,
            TransactionMetadataCache transactionMetadataCache,
            LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader, Monitors monitors,
            boolean failOnCorruptedLogFiles ); @Override TransactionCursor getTransactions( LogPosition position ); @Override TransactionCursor getTransactionsInReverseOrder( LogPosition backToPosition ); @Override TransactionCursor getTransactions( final long transactionIdToStartFrom ); @Override TransactionMetadata getMetadataFor( long transactionId ); @Override boolean existsOnDisk( long transactionId );  }### Answer:
@Test public void shouldThrowNoSuchTransactionExceptionIfMetadataNotFound() throws Exception { LogFiles logFiles = mock( LogFiles.class ); TransactionMetadataCache cache = new TransactionMetadataCache(); LifeSupport life = new LifeSupport(); final LogicalTransactionStore txStore = new PhysicalLogicalTransactionStore( logFiles, cache, new VersionAwareLogEntryReader<>(), monitors, true ); try { life.start(); try { txStore.getMetadataFor( 10 ); fail( "Should have thrown" ); } catch ( NoSuchTransactionException e ) { } } finally { life.shutdown(); } }