public AdminTool( CommandLocator commandLocator, BlockerLocator blockerLocator, OutsideWorld outsideWorld, boolean debug ) { this.commandLocator = CommandLocator.withAdditionalCommand( help(), commandLocator ); this.blockerLocator = blockerLocator; this.outsideWorld = outsideWorld; this.debug = debug; this.usage = new Usage( scriptName, this.commandLocator ); }
@Test void shouldPrintUsageForACommand() { // given AdminCommand.Provider commandProvider = mockCommand( "bam", "A summary", AdminCommandSection.general() ); AdminCommand.Provider[] commands = new AdminCommand.Provider[]{commandProvider}; final Usage usage = new Usage( "neo4j-admin", new CannedLocator( commands ) ); // when usage.printUsageForCommand( commandProvider, out ); // then InOrder ordered = inOrder( out ); ordered.verify( out ).accept( "usage: neo4j-admin bam " ); ordered.verify( out ).accept( "" ); ordered.verify( out ).accept( "environment variables:" ); ordered.verify( out ).accept( " NEO4J_CONF Path to directory which contains neo4j.conf." ); ordered.verify( out ).accept( " NEO4J_DEBUG Set to anything to enable debug output." ); ordered.verify( out ).accept( " NEO4J_HOME Neo4j home directory." ); ordered.verify( out ).accept( " HEAP_SIZE Set JVM maximum heap size during command execution." ); ordered.verify( out ).accept( " Takes a number and a unit, for example 512m." ); ordered.verify( out ).accept( "" ); ordered.verify( out ).accept( "description" ); }
@Test void shouldPrintUsageWithConfiguration() { AdminCommand.Provider[] commands = new AdminCommand.Provider[]{mockCommand( "bam", "A summary", AdminCommandSection.general() )}; final Usage usage = new Usage( "neo4j-admin", new CannedLocator( commands ) ); usage.print( out ); InOrder ordered = inOrder( out ); ordered.verify( out ).accept( "usage: neo4j-admin <command>" ); ordered.verify( out ).accept( "" ); ordered.verify( out ).accept( "Manage your Neo4j instance." ); ordered.verify( out ).accept( "" ); ordered.verify( out ).accept( "environment variables:" ); ordered.verify( out ).accept( " NEO4J_CONF Path to directory which contains neo4j.conf." ); ordered.verify( out ).accept( " NEO4J_DEBUG Set to anything to enable debug output." ); ordered.verify( out ).accept( " NEO4J_HOME Neo4j home directory." ); ordered.verify( out ).accept( " HEAP_SIZE Set JVM maximum heap size during command execution." ); ordered.verify( out ).accept( " Takes a number and a unit, for example 512m." ); ordered.verify( out ).accept( "" ); ordered.verify( out ).accept( "available commands:" ); ordered.verify( out ).accept( "General" ); ordered.verify( out ).accept( " bam" ); ordered.verify( out ).accept( " A summary" ); ordered.verify( out ).accept( "" ); ordered.verify( out ).accept( "Use neo4j-admin help <command> for more details." ); ordered.verifyNoMoreInteractions(); }
@Test void commandsUnderSameAdminCommandSectionPrintableSectionShouldAppearTogether() { AdminCommand.Provider[] commands = new AdminCommand.Provider[]{ mockCommand( "first-command", "first-command", AdminCommandSection.general() ), mockCommand( "second-command", "second-command", new TestGeneralSection() )}; final Usage usage = new Usage( "neo4j-admin", new CannedLocator( commands ) ); usage.print( out ); InOrder ordered = inOrder( out ); ordered.verify( out ).accept( "usage: neo4j-admin <command>" ); ordered.verify( out ).accept( "" ); ordered.verify( out ).accept( "Manage your Neo4j instance." ); ordered.verify( out ).accept( "" ); ordered.verify( out ).accept( "environment variables:" ); ordered.verify( out ).accept( " NEO4J_CONF Path to directory which contains neo4j.conf." ); ordered.verify( out ).accept( " NEO4J_DEBUG Set to anything to enable debug output." ); ordered.verify( out ).accept( " NEO4J_HOME Neo4j home directory." ); ordered.verify( out ).accept( " HEAP_SIZE Set JVM maximum heap size during command execution." ); ordered.verify( out ).accept( " Takes a number and a unit, for example 512m." ); ordered.verify( out ).accept( "" ); ordered.verify( out ).accept( "available commands:" ); ordered.verify( out ).accept( "General" ); ordered.verify( out ).accept( " first-command" ); ordered.verify( out ).accept( " first-command" ); ordered.verify( out ).accept( " second-command" ); ordered.verify( out ).accept( " second-command" ); ordered.verify( out ).accept( "" ); ordered.verify( out ).accept( "Use neo4j-admin help <command> for more details." ); ordered.verifyNoMoreInteractions(); }
@Test public void shouldPrintNiceHelp() throws Throwable { try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) { PrintStream ps = new PrintStream( baos ); Usage usage = new Usage( "neo4j-admin", mock( CommandLocator.class ) ); usage.printUsageForCommand( new SetInitialPasswordCommandProvider(), ps::println ); assertEquals( String.format( "usage: neo4j-admin set-initial-password <password>%n" + "%n" + "environment variables:%n" + " NEO4J_CONF Path to directory which contains neo4j.conf.%n" + " NEO4J_DEBUG Set to anything to enable debug output.%n" + " NEO4J_HOME Neo4j home directory.%n" + " HEAP_SIZE Set JVM maximum heap size during command execution.%n" + " Takes a number and a unit, for example 512m.%n" + "%n" + "Sets the initial password of the initial admin user ('neo4j').%n" ), baos.toString() ); } }
@Test public void shouldPrintNiceHelp() throws Throwable { try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) { PrintStream ps = new PrintStream( baos ); Usage usage = new Usage( "neo4j-admin", mock( CommandLocator.class ) ); usage.printUsageForCommand( new SetDefaultAdminCommandProvider(), ps::println ); assertEquals( String.format( "usage: neo4j-admin set-default-admin <username>%n" + "%n" + "environment variables:%n" + " NEO4J_CONF Path to directory which contains neo4j.conf.%n" + " NEO4J_DEBUG Set to anything to enable debug output.%n" + " NEO4J_HOME Neo4j home directory.%n" + " HEAP_SIZE Set JVM maximum heap size during command execution.%n" + " Takes a number and a unit, for example 512m.%n" + "%n" + "Sets the user to become admin if users but no roles are present, for example%n" + "when upgrading to neo4j 3.1 enterprise.%n" ), baos.toString() ); } }
@Test public void shouldPrintNiceHelp() throws Exception { try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) { PrintStream ps = new PrintStream( baos ); Usage usage = new Usage( "neo4j-admin", mock( CommandLocator.class ) ); usage.printUsageForCommand( new StoreInfoCommandProvider(), ps::println ); assertEquals( String.format( "usage: neo4j-admin store-info --store=<path-to-dir>%n" + "%n" + "environment variables:%n" + " NEO4J_CONF Path to directory which contains neo4j.conf.%n" + " NEO4J_DEBUG Set to anything to enable debug output.%n" + " NEO4J_HOME Neo4j home directory.%n" + " HEAP_SIZE Set JVM maximum heap size during command execution.%n" + " Takes a number and a unit, for example 512m.%n" + "%n" + "Prints information about a Neo4j database store, such as what version of Neo4j%n" + "created it. Note that this command expects a path to a store directory, for%n" + "example --store=data/databases/graph.db.%n" + "%n" + "options:%n" + " --store=<path-to-dir> Path to database store.%n" ), baos.toString() ); } }
@Test void shouldPrintNiceHelp() throws Exception { try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) { PrintStream ps = new PrintStream( baos ); Usage usage = new Usage( "neo4j-admin", mock( CommandLocator.class ) ); usage.printUsageForCommand( new DumpCommandProvider(), ps::println ); assertEquals( String.format( "usage: neo4j-admin dump [--database=<name>] --to=<destination-path>%n" + "%n" + "environment variables:%n" + " NEO4J_CONF Path to directory which contains neo4j.conf.%n" + " NEO4J_DEBUG Set to anything to enable debug output.%n" + " NEO4J_HOME Neo4j home directory.%n" + " HEAP_SIZE Set JVM maximum heap size during command execution.%n" + " Takes a number and a unit, for example 512m.%n" + "%n" + "Dump a database into a single-file archive. The archive can be used by the load%n" + "command. <destination-path> can be a file or directory (in which case a file%n" + "called <database>.dump will be created). It is not possible to dump a database%n" + "that is mounted in a running Neo4j server.%n" + "%n" + "options:%n" + " --database=<name> Name of database. [default:" + GraphDatabaseSettings.DEFAULT_DATABASE_NAME + "]%n" + " --to=<destination-path> Destination (file or folder) of database dump.%n" ), baos.toString() ); } }
Usage usage = new Usage( "neo4j-admin", mock( CommandLocator.class ) ); usage.printUsageForCommand( new LoadCommandProvider(), ps::println );
HelpCommand helpCommand = new HelpCommand( new Usage( "neo4j-admin", commandLocator ), ps::println, commandLocator ); helpCommand.execute( "foobar" );
Usage usage = new Usage( "neo4j-admin", mock( CommandLocator.class ) ); usage.printUsageForCommand( new CheckConsistencyCommandProvider(), ps::println );
Usage usage = new Usage( "neo4j-admin", commandLocator );
Usage usage = new Usage( "neo4j-admin", mock( CommandLocator.class ) ); usage.printUsageForCommand( new ImportCommandProvider(), ps::println );
sc=new Scanner(System.in); String input=""; while((input=sc.nextLine())!=null) { String[] arr=input.split(" "); int numberI=Integer.parseInt(arr[0]); Usage usage=new Usage(arr[1]); computerNames[numberI].addObsseration(usage); } sc.close();
int calls = myLineScan2.nextInt(); int txt = myLineScan2.nextInt(); usages.add((new Usage(custID, calls, txt)));