congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
IncorrectUsage.getMessage
Code IndexAdd Tabnine to your IDE (free)

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

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

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

@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

@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

@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

@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

@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

if ( e.getMessage().equals( "Unknown classifier: threads" ) )
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

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

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

@Test
void throwsOnUnexpectedShortArgumentWithValue()
{
  IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () -> builder.withDatabase().parse( new String[]{ "-f=bob" } ) );
  assertEquals( "unrecognized option: 'f'", incorrectUsage.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: neo4j/neo4j

@Test
public void failIfSourceIsNotAStore()
{
  File from = testDir.directory( "empty" );
  String[] arguments = {"--mode=database", "--database=bar", "--from=" + from.getAbsolutePath()};
  try
  {
    new DatabaseImporter( Args.parse( arguments ), Config.defaults(), new NullOutsideWorld() );
    fail( "Should have thrown an exception." );
  }
  catch ( IncorrectUsage e )
  {
    assertThat( e.getMessage(), containsString( "does not contain a database" ) );
  }
}
origin: neo4j/neo4j

@Test
void printUnrecognizedClassifiers() throws Exception
{
  String[] args = {"logs", "tx", "invalid"};
  try ( RealOutsideWorld outsideWorld = new RealOutsideWorld() )
  {
    DiagnosticsReportCommand
        diagnosticsReportCommand = new DiagnosticsReportCommand( homeDir, configDir, outsideWorld );
    IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () -> diagnosticsReportCommand.execute( args ) );
    assertEquals( "Unknown classifier: invalid", incorrectUsage.getMessage() );
  }
}
origin: neo4j/neo4j

@Test
void allHasToBeOnlyClassifier() throws Exception
{
  String[] args = {"all", "logs", "tx"};
  try ( RealOutsideWorld outsideWorld = new RealOutsideWorld() )
  {
    DiagnosticsReportCommand diagnosticsReportCommand = new DiagnosticsReportCommand( homeDir, configDir, outsideWorld );
    IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () -> diagnosticsReportCommand.execute( args ) );
    assertEquals( "If you specify 'all' this has to be the only classifier. Found ['logs','tx'] as well.", incorrectUsage.getMessage() );
  }
}
origin: neo4j/neo4j

@Test
void throwsOnUnexpectedPositionalArgumentWhenExpectingSome()
{
  IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () ->
      builder.withMandatoryPositionalArgument( 0, "first" )
       .withOptionalPositionalArgument( 1, "second" )
       .parse( new String[]{ "one", "two", "three", "four" } ) );
  assertEquals( "unrecognized arguments: 'three four'", incorrectUsage.getMessage() );
}
origin: neo4j/neo4j

@Test
void throwsOnTooFewPositionalArguments()
{
  IncorrectUsage incorrectUsage = assertThrows( IncorrectUsage.class, () ->
    builder.withMandatoryPositionalArgument( 0, "first" )
      .withOptionalPositionalArgument( 1, "second" )
      .parse( new String[]{} ) );
  assertEquals( "not enough arguments", incorrectUsage.getMessage() );
}
origin: neo4j/neo4j

@Test
public void requiresFromArgument()
{
  String[] arguments = {"--mode=database", "--database=bar"};
  try
  {
    new DatabaseImporter( Args.parse( arguments ), Config.defaults(), new NullOutsideWorld() );
    fail( "Should have thrown an exception." );
  }
  catch ( IncorrectUsage e )
  {
    assertThat( e.getMessage(), containsString( "from" ) );
  }
}
org.neo4j.commandline.adminIncorrectUsagegetMessage

Popular methods of IncorrectUsage

  • <init>

Popular in Java

  • Reading from database using SQL prepared statement
  • scheduleAtFixedRate (Timer)
  • putExtra (Intent)
  • getSystemService (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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