### Question:
RebuildFromLogs { public void rebuild( File source, File target, long txId ) throws Exception, InconsistentStoreException { try ( PageCache pageCache = StandalonePageCacheFactory.createPageCache( fs, createInitialisedScheduler() ) ) { LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder( source, fs ).build(); long highestVersion = logFiles.getHighestLogVersion(); if ( highestVersion < 0 ) { printUsage( "Inconsistent number of log files found in " + source ); return; } long lastTxId; try ( TransactionApplier applier = new TransactionApplier( fs, target, pageCache ) ) { lastTxId = applier.applyTransactionsFrom( source, txId ); } MetaDataStore.setRecord( pageCache, DatabaseLayout.of( target ).metadataStore(), MetaDataStore.Position.LAST_TRANSACTION_ID, lastTxId ); checkConsistency( target, pageCache ); } } RebuildFromLogs( FileSystemAbstraction fs ); static void main( String[] args ); void rebuild( File source, File target, long txId );  }### Answer:
@Test public void shouldRebuildFromLog() throws Exception, InconsistentStoreException { File prototypePath = getPrototypePath(); populatePrototype( prototypePath ); File rebuildPath = getRebuilPath(); new RebuildFromLogs( fileSystemRule.get() ).rebuild( prototypePath, rebuildPath, BASE_TX_ID ); assertEquals( getDbRepresentation( prototypePath ), getDbRepresentation( rebuildPath ) ); }
@Test public void failRebuildFromLogIfStoreIsInconsistentAfterRebuild() throws InconsistentStoreException, Exception { File prototypePath = getPrototypePath(); populatePrototype( prototypePath ); File rebuildPath = getRebuilPath(); expectedException.expect( InconsistentStoreException.class ); RebuildFromLogs rebuildFromLogs = new TestRebuildFromLogs( fileSystemRule.get() ); rebuildFromLogs.rebuild( prototypePath, rebuildPath, BASE_TX_ID ); }
@Test public void shouldRebuildFromLogUpToATx() throws Exception, InconsistentStoreException { File prototypePath = getPrototypePath(); long txId = populatePrototype( prototypePath ); File copy = new File( dir.databaseDir(), "copy" ); FileUtils.copyRecursively( prototypePath, copy ); GraphDatabaseAPI db = db( copy ); try ( org.neo4j.graphdb.Transaction tx = db.beginTx() ) { db.createNode(); tx.success(); } finally { db.shutdown(); } File rebuildPath = getRebuilPath(); new RebuildFromLogs( fileSystemRule.get() ).rebuild( copy, rebuildPath, txId ); assertEquals( getDbRepresentation( prototypePath ), getDbRepresentation( rebuildPath ) ); }