### Question:
StoreInfoCommand implements AdminCommand { @Override public void execute( String[] args ) throws IncorrectUsage, CommandFailed { final Path databaseDirectory = arguments.parse( args ).getMandatoryPath( "store" ); Validators.CONTAINS_EXISTING_DATABASE.validate( databaseDirectory.toFile() ); DatabaseLayout databaseLayout = DatabaseLayout.of( databaseDirectory.toFile() ); try ( Closeable ignored = StoreLockChecker.check( databaseLayout.getStoreLayout() ); DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(); JobScheduler jobScheduler = createInitialisedScheduler(); PageCache pageCache = StandalonePageCacheFactory.createPageCache( fileSystem, jobScheduler ) ) { final String storeVersion = new StoreVersionCheck( pageCache ) .getVersion( databaseLayout.metadataStore() ) .orElseThrow( () -> new CommandFailed( String.format( "Could not find version metadata in store '%s'", databaseDirectory ) ) ); final String fmt = "%-30s%s"; out.accept( String.format( fmt, "Store format version:", storeVersion ) ); RecordFormats format = RecordFormatSelector.selectForVersion( storeVersion ); out.accept( String.format( fmt, "Store format introduced in:", format.introductionVersion() ) ); findSuccessor( format ) .map( next -> String.format( fmt, "Store format superseded in:", next.introductionVersion() ) ) .ifPresent( out ); } catch ( StoreLockException e ) { throw new CommandFailed( "the database is in use -- stop Neo4j and try again", e ); } catch ( Exception e ) { throw new CommandFailed( e.getMessage(), e ); } } StoreInfoCommand( Consumer<String> out ); @Override void execute( String[] args ); static Arguments arguments();  }### Answer:
@Test public void noArgFails() throws Exception { expected.expect( IllegalArgumentException.class ); expected.expectMessage( "Missing argument 'store'" ); command.execute( new String[]{} ); }
@Test public void emptyArgFails() throws Exception { expected.expect( IllegalArgumentException.class ); expected.expectMessage( "Missing argument 'store'" ); command.execute( new String[]{"--store="} ); }
@Test public void nonExistingDatabaseShouldThrow() throws Exception { expected.expect( IllegalArgumentException.class ); expected.expectMessage( "does not contain a database" ); execute( Paths.get( "yaba", "daba", "doo" ).toString() ); }
@Test public void readsLatestStoreVersionCorrectly() throws Exception { RecordFormats currentFormat = RecordFormatSelector.defaultFormat(); prepareNeoStoreFile( currentFormat.storeVersion() ); execute( databaseDirectory.toString() ); verify( out, times( 2 ) ).accept( outCaptor.capture() ); assertEquals( Arrays.asList( String.format( "Store format version: %s", currentFormat.storeVersion() ), String.format( "Store format introduced in: %s", currentFormat.introductionVersion() ) ), outCaptor.getAllValues() ); }
@Test public void readsOlderStoreVersionCorrectly() throws Exception { prepareNeoStoreFile( StandardV2_3.RECORD_FORMATS.storeVersion() ); execute( databaseDirectory.toString() ); verify( out, times( 3 ) ).accept( outCaptor.capture() ); assertEquals( Arrays.asList( "Store format version: v0.A.6", "Store format introduced in: 2.3.0", "Store format superseded in: 3.0.0" ), outCaptor.getAllValues() ); }
@Test public void throwsOnUnknownVersion() throws Exception { prepareNeoStoreFile( "v9.9.9" ); expected.expect( new RootCauseMatcher( IllegalArgumentException.class ) ); expected.expectMessage( "Unknown store version 'v9.9.9'" ); execute( databaseDirectory.toString() ); }