Tabnine Logo
IncorrectUsage
Code IndexAdd Tabnine to your IDE (free)

How to use
IncorrectUsage
in
org.neo4j.commandline.admin

Best Java code snippets using org.neo4j.commandline.admin.IncorrectUsage (Showing top 20 results out of 315)

origin: neo4j/neo4j

private void validateClassifiers( Set<String> availableClassifiers, Set<String> orphans ) throws IncorrectUsage
{
  for ( String classifier : orphans )
  {
    if ( !availableClassifiers.contains( classifier ) )
    {
      throw new IncorrectUsage( "Unknown classifier: " + classifier );
    }
  }
}
origin: neo4j/neo4j

private void badUsage( AdminCommand.Provider command, IncorrectUsage e )
{
  outsideWorld.stdErrLine( e.getMessage() );
  outsideWorld.stdErrLine( "" );
  usage.printUsageForCommand( command, outsideWorld::stdErrLine );
  failure();
}
origin: neo4j/neo4j

private void validate() throws IncorrectUsage
{
  for ( String o : parsedArgs.asMap().keySet() )
  {
    if ( !namedArgs.containsKey( o ) )
    {
      throw new IncorrectUsage( format( "unrecognized option: '%s'", o ) );
    }
  }
  long mandatoryPositionalArgs = positionalArgs.stream()
      .filter( o -> o instanceof MandatoryPositionalArgument )
      .count();
  if ( parsedArgs.orphans().size() < mandatoryPositionalArgs )
  {
    throw new IncorrectUsage( "not enough arguments" );
  }
  String excessArgs = parsedArgs.orphans().stream()
      .skip( positionalArgs.size() )
      .collect( Collectors.joining( " " ) );
  if ( !excessArgs.isEmpty() )
  {
    throw new IncorrectUsage( format( "unrecognized arguments: '%s'", excessArgs ) );
  }
}
origin: neo4j/neo4j

@Test
void printsUnknownCommandWhenUnknownCommandIsProvided()
{
  CommandLocator commandLocator = mock( CommandLocator.class );
  when( commandLocator.getAllProviders() ).thenReturn( Collections.emptyList() );
  when( commandLocator.findProvider( "foobar" ) ).thenThrow( new NoSuchElementException( "foobar" ) );
  HelpCommand helpCommand = new HelpCommand( mock( Usage.class ), out, commandLocator );
  IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () -> helpCommand.execute( "foobar" ) );
  assertThat( incorrectUsage.getMessage(), containsString( "Unknown command: foobar" ) );
}
origin: neo4j/neo4j

DatabaseImporter( Args args, Config config, OutsideWorld outsideWorld ) throws IncorrectUsage
{
  this.config = config;
  try
  {
    this.from = args.interpretOption( "from", Converters.mandatory(), Converters.toFile(),
        Validators.CONTAINS_EXISTING_DATABASE );
  }
  catch ( IllegalArgumentException e )
  {
    throw new IncorrectUsage( e.getMessage() );
  }
}
origin: neo4j/neo4j

@Test
void printsAvailableCommandsWhenUnknownCommandIsProvided()
{
  CommandLocator commandLocator = mock( CommandLocator.class );
  List<AdminCommand.Provider> mockCommands = asList( mockCommand( "foo" ), mockCommand( "bar" ), mockCommand( "baz" ) );
  when( commandLocator.getAllProviders() ).thenReturn( mockCommands );
  when( commandLocator.findProvider( "foobar" ) ).thenThrow( new NoSuchElementException( "foobar" ) );
  HelpCommand helpCommand = new HelpCommand( mock( Usage.class ), out, commandLocator );
  IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () -> helpCommand.execute( "foobar" ) );
  assertThat( incorrectUsage.getMessage(), containsString( "Available commands are: foo bar baz" ) );
}
origin: neo4j/neo4j

  @Override
  public void execute( String... args ) throws IncorrectUsage
  {
    if ( args.length > 0 )
    {
      try
      {
        AdminCommand.Provider commandProvider = this.locator.findProvider( args[0] );
        usage.printUsageForCommand( commandProvider, output );
      }
      catch ( NoSuchElementException e )
      {
        StringBuilder validCommands = new StringBuilder();
        locator.getAllProviders()
            .forEach( commandProvider -> validCommands.append( commandProvider.name() ).append( " " ) );

        throw new IncorrectUsage(
            format( "Unknown command: %s. Available commands are: %s\n", args[0], validCommands ) );
      }
    }
    else
    {
      usage.print( output );
    }
  }
}
origin: neo4j/neo4j

@Test
void databaseAndBackupAreMutuallyExclusive() throws Exception
{
  ConsistencyCheckService consistencyCheckService = mock( ConsistencyCheckService.class );
  Path homeDir = testDir.directory( "home" ).toPath();
  CheckConsistencyCommand checkConsistencyCommand =
      new CheckConsistencyCommand( homeDir, testDir.directory( "conf" ).toPath(), consistencyCheckService );
  when( consistencyCheckService.runFullConsistencyCheck( any(), any(), any(), any(),
      any(), anyBoolean(), any( ConsistencyFlags.class ) ) )
      .thenReturn( ConsistencyCheckService.Result.success( null ) );
  IncorrectUsage incorrectUsage =
      assertThrows( IncorrectUsage.class, () -> checkConsistencyCommand.execute( new String[]{"--database=foo", "--backup=bar"} ) );
  assertEquals( "Only one of '--database' and '--backup' can be specified.", incorrectUsage.getMessage() );
}
origin: neo4j/neo4j

throw new IncorrectUsage(
    "If you specify 'all' this has to be the only classifier. Found ['" + String.join( "','", classifiers ) + "'] as well." );
origin: neo4j/neo4j

@Test
void requiresDatabaseArgument()
{
  try ( NullOutsideWorld outsideWorld = new NullOutsideWorld() )
  {
    ImportCommand importCommand =
        new ImportCommand( testDir.directory( "home" ).toPath(), testDir.directory( "conf" ).toPath(),
            outsideWorld );
    String[] arguments = {"--mode=database", "--from=bar"};
    IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () -> importCommand.execute( arguments ) );
    assertThat( incorrectUsage.getMessage(), containsString( "database" ) );
  }
}
origin: neo4j/neo4j

throw new IncorrectUsage( e.getMessage() );
throw new IncorrectUsage( e.getMessage() );
origin: neo4j/neo4j

@Test
void failIfInvalidModeSpecified()
{
  try ( NullOutsideWorld outsideWorld = new NullOutsideWorld() )
  {
    ImportCommand importCommand =
        new ImportCommand( testDir.directory( "home" ).toPath(), testDir.directory( "conf" ).toPath(),
            outsideWorld );
    String[] arguments = {"--mode=foo", "--database=bar", "--from=baz"};
    IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () -> importCommand.execute( arguments ) );
    assertThat( incorrectUsage.getMessage(), containsString( "foo" ) );
  }
}
origin: neo4j/neo4j

CsvImporter( Args args, Config databaseConfig, OutsideWorld outsideWorld ) throws IncorrectUsage
{
  this.args = args;
  this.outsideWorld = outsideWorld;
  nodesFiles = extractInputFiles( args, "nodes", outsideWorld.errorStream() );
  relationshipsFiles = extractInputFiles( args, "relationships", outsideWorld.errorStream() );
  reportFileName =
      args.interpretOption( "report-file", withDefault( ImportCommand.DEFAULT_REPORT_FILE_NAME ), s -> s );
  ignoreExtraColumns = args.getBoolean( "ignore-extra-columns", false );
  ignoreDuplicateNodes = args.getBoolean( "ignore-duplicate-nodes", false );
  ignoreBadRelationships = args.getBoolean( "ignore-missing-nodes", false );
  try
  {
    validateInputFiles( nodesFiles, relationshipsFiles );
  }
  catch ( IllegalArgumentException e )
  {
    throw new IncorrectUsage( e.getMessage() );
  }
  idType = args.interpretOption( "id-type", withDefault( IdType.STRING ),
      from -> IdType.valueOf( from.toUpperCase() ) );
  inputEncoding = Charset.forName( args.get( "input-encoding", defaultCharset().name() ) );
  highIO = args.getBoolean( "high-io", null, true ); // intentionally left as null if not specified
  this.databaseConfig = databaseConfig;
}
origin: neo4j/neo4j

if ( e.getMessage().equals( "Unknown classifier: threads" ) )
origin: neo4j/neo4j

@Test
void shouldProvideFeedbackIfTheCommandReportsAUsageProblem()
{
  OutsideWorld outsideWorld = mock( OutsideWorld.class );
  AdminCommand command = args ->
  {
    throw new IncorrectUsage( "the-usage-message" );
  };
  new AdminTool( cannedCommand( "exception", command ), new NullBlockerLocator(), outsideWorld, false )
      .execute( null, null, "exception" );
  InOrder inOrder = inOrder( outsideWorld );
  inOrder.verify( outsideWorld ).stdErrLine( "the-usage-message" );
  verify( outsideWorld ).exit( STATUS_ERROR );
}
origin: neo4j/neo4j

@Test
void throwsOnUnexpectedShortArgument()
{
  IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () -> builder.withDatabase().parse( new String[]{ "-f" } ) );
  assertEquals( "unrecognized option: 'f'", incorrectUsage.getMessage() );
}
origin: neo4j/neo4j

throw new IncorrectUsage( e.getMessage() );
  throw new IncorrectUsage( "Only one of '--" + ARG_DATABASE + "' and '--backup' can be specified." );
throw new IncorrectUsage( e.getMessage() );
origin: neo4j/neo4j

@Test
void throwsOnUnexpectedLongArgumentWithValue()
{
  IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () -> builder.withDatabase().parse( new String[]{ "--stacktrace=true" } ) );
  assertEquals( "unrecognized option: 'stacktrace'", incorrectUsage.getMessage() );
}
origin: org.neo4j/neo4j-dbms

private void validateClassifiers( Set<String> availableClassifiers, Set<String> orphans ) throws IncorrectUsage
{
  for ( String classifier : orphans )
  {
    if ( !availableClassifiers.contains( classifier ) )
    {
      throw new IncorrectUsage( "Unknown classifier: " + classifier );
    }
  }
}
origin: neo4j/neo4j

@Test
void throwsOnUnexpectedLongArgument()
{
  IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () -> builder.withDatabase().parse( new String[]{"--stacktrace"} ) );
  assertEquals( "unrecognized option: 'stacktrace'", incorrectUsage.getMessage() );
}
org.neo4j.commandline.adminIncorrectUsage

Most used methods

  • <init>
  • getMessage

Popular in Java

  • Reactive rest calls using spring rest template
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getApplicationContext (Context)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • JLabel (javax.swing)
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now