@Test void shouldNotBlockIfNoneOfTheBlockersBlock() throws CommandFailed, IncorrectUsage { AdminCommand command = mock( AdminCommand.class ); AdminCommand.Blocker falseBlocker = mock( AdminCommand.Blocker.class ); when( falseBlocker.doesBlock( any(), any() ) ).thenReturn( false ); when( falseBlocker.explanation() ).thenReturn( "falseBlocker explanation" ); BlockerLocator blockerLocator = mock( BlockerLocator.class ); when( blockerLocator.findBlockers( "command" ) ) .thenReturn( Arrays.asList( falseBlocker, falseBlocker, falseBlocker ) ); new AdminTool( cannedCommand( "command", command ), blockerLocator, new NullOutsideWorld(), false ) .execute( null, null, "command", "the", "other", "args" ); verify( command ).execute( new String[]{"the", "other", "args"} ); }
@Test void shouldExecuteTheCommand() throws CommandFailed, IncorrectUsage { AdminCommand command = mock( AdminCommand.class ); new AdminTool( cannedCommand( "command", command ), new NullBlockerLocator(), new NullOutsideWorld(), false ) .execute( null, null, "command", "the", "other", "args" ); verify( command ).execute( new String[]{"the", "other", "args"} ); }
try command.execute( commandArgs ); success();
public boolean backup( File neo4jHome, String backupName ) throws CommandFailed, IncorrectUsage { File targetLocation = new File( neo4jHome, backupName ); String[] args; if ( rawArgs.isPresent() ) { args = rawArgs.get(); } else { try { args = resolveArgs( targetLocation ); } catch ( IOException e ) { throw new CommandFailed( "Failed to resolve arguments", e ); } } new OnlineBackupCommandProvider() .create( neo4jHome.toPath(), configDirFromTarget( neo4jHome.toPath() ), resolveOutsideWorld() ) .execute( args ); return true; }