Skip to content

Commit

Permalink
Rename neo4j-admin version command to store-info
Browse files Browse the repository at this point in the history
  • Loading branch information
spacecowboy committed Mar 31, 2017
1 parent 76dff58 commit 8bd9fe9
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 41 deletions.
Expand Up @@ -40,15 +40,15 @@


import static org.neo4j.kernel.impl.store.format.RecordFormatSelector.findSuccessor; import static org.neo4j.kernel.impl.store.format.RecordFormatSelector.findSuccessor;


public class VersionCommand implements AdminCommand public class StoreInfoCommand implements AdminCommand
{ {
private static final Arguments arguments = new Arguments() private static final Arguments arguments = new Arguments()
.withArgument( new MandatoryCanonicalPath( "store", "path-to-dir", .withArgument( new MandatoryCanonicalPath( "store", "path-to-dir",
"Path to database store to check version of." ) ); "Path to database store." ) );


private Consumer<String> out; private Consumer<String> out;


public VersionCommand( Consumer<String> out ) public StoreInfoCommand( Consumer<String> out )
{ {
this.out = out; this.out = out;
} }
Expand All @@ -69,17 +69,17 @@ public void execute( String[] args ) throws IncorrectUsage, CommandFailed
() -> new CommandFailed( String.format( "Could not find version metadata in store '%s'", () -> new CommandFailed( String.format( "Could not find version metadata in store '%s'",
storeDir ) ) ); storeDir ) ) );


final String fmt = "%-25s%s"; final String fmt = "%-30s%s";
out.accept( String.format( fmt, "Store format version:", storeVersion ) ); out.accept( String.format( fmt, "Store format version:", storeVersion ) );


RecordFormats format = RecordFormatSelector.selectForVersion( storeVersion ); RecordFormats format = RecordFormatSelector.selectForVersion( storeVersion );
out.accept( String.format( fmt, "Introduced in version:", format.introductionVersion() ) ); out.accept( String.format( fmt, "Store format introduced in:", format.introductionVersion() ) );


findSuccessor( format ) findSuccessor( format )
.map( next -> String.format( fmt, "Superseded in version:", next.introductionVersion() ) ) .map( next -> String.format( fmt, "Store format superseded in:", next.introductionVersion() ) )
.ifPresent( out ); .ifPresent( out );


out.accept( String.format( fmt, "Current version:", Version.getNeo4jVersion() ) ); //out.accept( String.format( fmt, "Current version:", Version.getNeo4jVersion() ) );
} }
catch ( IOException e ) catch ( IOException e )
{ {
Expand Down
Expand Up @@ -27,26 +27,26 @@
import org.neo4j.commandline.admin.OutsideWorld; import org.neo4j.commandline.admin.OutsideWorld;
import org.neo4j.commandline.arguments.Arguments; import org.neo4j.commandline.arguments.Arguments;


public class VersionCommandProvider extends AdminCommand.Provider public class StoreInfoCommandProvider extends AdminCommand.Provider
{ {


public VersionCommandProvider() public StoreInfoCommandProvider()
{ {
super( "version" ); super( "store-info" );
} }


@Override @Override
@Nonnull @Nonnull
public Arguments allArguments() public Arguments allArguments()
{ {
return VersionCommand.arguments(); return StoreInfoCommand.arguments();
} }


@Override @Override
@Nonnull @Nonnull
public String summary() public String summary()
{ {
return "Check the version of a Neo4j database store."; return "Prints information about a Neo4j database store.";
} }


@Override @Override
Expand All @@ -60,14 +60,14 @@ public AdminCommandSection commandSection()
@Nonnull @Nonnull
public String description() public String description()
{ {
return "Checks the version of a Neo4j database store. Note that this command expects a path to a store " + return "Prints information about a Neo4j database store, such as what version of Neo4j created it. Note that " +
"directory, for example --store=data/databases/graph.db."; "this command expects a path to a store directory, for example --store=data/databases/graph.db.";
} }


@Override @Override
@Nonnull @Nonnull
public AdminCommand create( Path homeDir, Path configDir, OutsideWorld outsideWorld ) public AdminCommand create( Path homeDir, Path configDir, OutsideWorld outsideWorld )
{ {
return new VersionCommand( outsideWorld::stdOutLine ); return new StoreInfoCommand( outsideWorld::stdOutLine );
} }
} }
@@ -1,4 +1,4 @@
org.neo4j.commandline.dbms.ImportCommandProvider org.neo4j.commandline.dbms.ImportCommandProvider
org.neo4j.commandline.dbms.DumpCommandProvider org.neo4j.commandline.dbms.DumpCommandProvider
org.neo4j.commandline.dbms.LoadCommandProvider org.neo4j.commandline.dbms.LoadCommandProvider
org.neo4j.commandline.dbms.VersionCommandProvider org.neo4j.commandline.dbms.StoreInfoCommandProvider
Expand Up @@ -52,7 +52,7 @@
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.neo4j.kernel.impl.store.MetaDataStore.Position.STORE_VERSION; import static org.neo4j.kernel.impl.store.MetaDataStore.Position.STORE_VERSION;


public class VersionCommandTest public class StoreInfoCommandTest
{ {
@Rule @Rule
public TestDirectory testDirectory = TestDirectory.testDirectory(); public TestDirectory testDirectory = TestDirectory.testDirectory();
Expand All @@ -65,7 +65,7 @@ public class VersionCommandTest


private Path databaseDirectory; private Path databaseDirectory;
private ArgumentCaptor<String> outCaptor; private ArgumentCaptor<String> outCaptor;
private VersionCommand command; private StoreInfoCommand command;
private Consumer<String> out; private Consumer<String> out;


@Before @Before
Expand All @@ -77,7 +77,7 @@ public void setUp() throws Exception


outCaptor = ArgumentCaptor.forClass( String.class ); outCaptor = ArgumentCaptor.forClass( String.class );
out = mock( Consumer.class ); out = mock( Consumer.class );
command = new VersionCommand( out ); command = new StoreInfoCommand( out );
} }


@Test @Test
Expand All @@ -87,15 +87,16 @@ public void shouldPrintNiceHelp() throws Exception
{ {
PrintStream ps = new PrintStream( baos ); PrintStream ps = new PrintStream( baos );
Usage usage = new Usage( "neo4j-admin", mock( CommandLocator.class ) ); Usage usage = new Usage( "neo4j-admin", mock( CommandLocator.class ) );
usage.printUsageForCommand( new VersionCommandProvider(), ps::println ); usage.printUsageForCommand( new StoreInfoCommandProvider(), ps::println );


assertEquals( String.format( "usage: neo4j-admin version --store=<path-to-dir>%n" + assertEquals( String.format( "usage: neo4j-admin store-info --store=<path-to-dir>%n" +
"%n" + "%n" +
"Checks the version of a Neo4j database store. Note that this command expects a%n" + "Prints information about a Neo4j database store, such as what version of Neo4j%n" +
"path to a store directory, for example --store=data/databases/graph.db.%n" + "created it. Note that this command expects a path to a store directory, for%n" +
"example --store=data/databases/graph.db.%n" +
"%n" + "%n" +
"options:%n" + "options:%n" +
" --store=<path-to-dir> Path to database store to check version of.%n" ), " --store=<path-to-dir> Path to database store.%n" ),
baos.toString() ); baos.toString() );
} }
} }
Expand Down Expand Up @@ -135,13 +136,12 @@ public void readsLatestStoreVersionCorrectly() throws Exception


execute( databaseDirectory.toString() ); execute( databaseDirectory.toString() );


verify( out, times( 3 ) ).accept( outCaptor.capture() ); verify( out, times( 2 ) ).accept( outCaptor.capture() );


assertEquals( assertEquals(
Arrays.asList( Arrays.asList(
String.format( "Store format version: %s", currentFormat.storeVersion() ), String.format( "Store format version: %s", currentFormat.storeVersion() ),
String.format( "Introduced in version: %s", currentFormat.introductionVersion() ), String.format( "Store format introduced in: %s", currentFormat.introductionVersion() ) ),
String.format( "Current version: %s", Version.getNeo4jVersion() ) ),
outCaptor.getAllValues() ); outCaptor.getAllValues() );
} }


Expand All @@ -152,14 +152,13 @@ public void readsOlderStoreVersionCorrectly() throws Exception


execute( databaseDirectory.toString() ); execute( databaseDirectory.toString() );


verify( out, times( 4 ) ).accept( outCaptor.capture() ); verify( out, times( 3 ) ).accept( outCaptor.capture() );


assertEquals( assertEquals(
Arrays.asList( Arrays.asList(
"Store format version: v0.A.5", "Store format version: v0.A.5",
"Introduced in version: 2.2.0", "Store format introduced in: 2.2.0",
"Superseded in version: 2.3.0", "Store format superseded in: 2.3.0" ),
String.format( "Current version: %s", Version.getNeo4jVersion() ) ),
outCaptor.getAllValues() ); outCaptor.getAllValues() );
} }


Expand Down
Expand Up @@ -45,7 +45,7 @@
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.neo4j.kernel.impl.store.MetaDataStore.Position.STORE_VERSION; import static org.neo4j.kernel.impl.store.MetaDataStore.Position.STORE_VERSION;


public class VersionCommandEnterpriseTest public class StoreInfoCommandEnterpriseTest
{ {
@Rule @Rule
public TestDirectory testDirectory = TestDirectory.testDirectory(); public TestDirectory testDirectory = TestDirectory.testDirectory();
Expand All @@ -58,7 +58,7 @@ public class VersionCommandEnterpriseTest


private Path databaseDirectory; private Path databaseDirectory;
private ArgumentCaptor<String> outCaptor; private ArgumentCaptor<String> outCaptor;
private VersionCommand command; private StoreInfoCommand command;
private Consumer<String> out; private Consumer<String> out;


@Before @Before
Expand All @@ -69,7 +69,7 @@ public void setUp() throws Exception
Files.createDirectories( databaseDirectory ); Files.createDirectories( databaseDirectory );
outCaptor = ArgumentCaptor.forClass( String.class ); outCaptor = ArgumentCaptor.forClass( String.class );
out = mock( Consumer.class ); out = mock( Consumer.class );
command = new VersionCommand( out ); command = new StoreInfoCommand( out );
} }


@Test @Test
Expand All @@ -79,14 +79,13 @@ public void readsEnterpriseStoreVersionCorrectly() throws Exception


execute( databaseDirectory.toString() ); execute( databaseDirectory.toString() );


verify( out, times( 4 ) ).accept( outCaptor.capture() ); verify( out, times( 3 ) ).accept( outCaptor.capture() );


assertEquals( assertEquals(
Arrays.asList( Arrays.asList(
"Store format version: vE.H.0", "Store format version: vE.H.0",
"Introduced in version: 3.0.0", "Store format introduced in: 3.0.0",
"Superseded in version: 3.0.6", "Store format superseded in: 3.0.6" ),
String.format( "Current version: %s", Version.getNeo4jVersion() ) ),
outCaptor.getAllValues() ); outCaptor.getAllValues() );
} }


Expand Down

0 comments on commit 8bd9fe9

Please sign in to comment.