@Override @Nonnull public AdminCommandSection commandSection() { return AdminCommandSection.general(); }
@Override @Nonnull public AdminCommandSection commandSection() { return AdminCommandSection.general(); }
@Nonnull @Override public AdminCommandSection commandSection() { return AdminCommandSection.general(); }
@Nonnull @Override public AdminCommandSection commandSection() { return AdminCommandSection.general(); }
@Override @Nonnull public AdminCommandSection commandSection() { return AdminCommandSection.general(); }
@Override @Nonnull public AdminCommandSection commandSection() { return AdminCommandSection.general(); }
@Override public AdminCommandSection commandSection() { return AdminCommandSection.general(); }
private void printCommands( Consumer<String> output ) { Map<AdminCommandSection,List<AdminCommand.Provider>> groupedProviders = groupProvidersBySection(); AdminCommandSection.general() .printAllCommandsUnderSection( output, groupedProviders.remove( AdminCommandSection.general() ) ); groupedProviders.entrySet().stream() .sorted( Comparator.comparing( groupedProvider -> groupedProvider.getKey().printable() ) ) .forEach(entry -> entry.getKey().printAllCommandsUnderSection( output, entry.getValue() ) ); }
@Override @Nonnull public AdminCommandSection commandSection() { return AdminCommandSection.general(); }
private static AdminCommand.Provider mockCommand( String name ) { AdminCommand.Provider commandProvider = mock( AdminCommand.Provider.class ); when( commandProvider.name() ).thenReturn( name ); when( commandProvider.commandSection() ).thenReturn( AdminCommandSection.general() ); return commandProvider; } }
private static AdminCommand.Provider mockCommand( String name, String summary ) { AdminCommand.Provider commandProvider = mock( AdminCommand.Provider.class ); when( commandProvider.name() ).thenReturn( name ); when( commandProvider.summary() ).thenReturn( summary ); when( commandProvider.commandSection() ).thenReturn( AdminCommandSection.general() ); return commandProvider; } }
@Test void shouldPrintUsageForAllCommandsAlphabetically() { AdminCommandSection generalSection = AdminCommandSection.general(); List<AdminCommand.Provider> providers = asList( mockCommand( "restore", "Restore" ), mockCommand( "bam", "A summary" ), mockCommand( "zzzz-last-one", "Another summary" ) ); generalSection.printAllCommandsUnderSection( out, providers ); InOrder ordered = inOrder( out ); ordered.verify( out ).accept( "" ); ordered.verify( out ).accept( "General" ); ordered.verify( out ).accept( " bam" ); ordered.verify( out ).accept( " A summary" ); ordered.verify( out ).accept( " restore" ); ordered.verify( out ).accept( " Restore" ); ordered.verify( out ).accept( " zzzz-last-one" ); ordered.verify( out ).accept( " Another summary" ); ordered.verifyNoMoreInteractions(); }
@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 hashCodeUsingReflection() { TestGeneralSection testGeneralSection = new TestGeneralSection(); TestAnotherGeneralSection testAnotherGeneralSection = new TestAnotherGeneralSection(); HashMap<AdminCommandSection,String> map = new HashMap<>(); map.put( AdminCommandSection.general(), "General-Original" ); map.put( testGeneralSection, "General-Test" ); map.put( testAnotherGeneralSection, "General-AnotherTest" ); assertEquals( 2, map.size() ); assertEquals( "General-Test", map.get( AdminCommandSection.general() ) ); assertEquals( "General-Test", map.get( testGeneralSection ) ); assertEquals( "General-AnotherTest", map.get( testAnotherGeneralSection ) ); }
@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(); }
@Override @Nonnull public AdminCommandSection commandSection() { return AdminCommandSection.general(); }
@Nonnull @Override public AdminCommandSection commandSection() { return AdminCommandSection.general(); }
@Override @Nonnull public AdminCommandSection commandSection() { return AdminCommandSection.general(); }