### Question:
UnbindFromClusterCommand implements AdminCommand { @Override public void execute( String[] args ) throws IncorrectUsage, CommandFailed { try { Config config = loadNeo4jConfig( homeDir, configDir, arguments.parse( args ).get( ARG_DATABASE ) ); File dataDirectory = config.get( GraphDatabaseSettings.data_directory ); Path pathToSpecificDatabase = config.get( GraphDatabaseSettings.database_path ).toPath(); boolean hasDatabase = true; try { Validators.CONTAINS_EXISTING_DATABASE.validate( pathToSpecificDatabase.toFile() ); } catch ( IllegalArgumentException ignored ) { hasDatabase = false; } if ( hasDatabase ) { confirmTargetDirectoryIsWritable( DatabaseLayout.of( pathToSpecificDatabase.toFile() ).getStoreLayout() ); } ClusterStateDirectory clusterStateDirectory = ClusterStateDirectory.withoutInitializing( dataDirectory ); if ( outsideWorld.fileSystem().fileExists( clusterStateDirectory.get() ) ) { deleteClusterStateIn( clusterStateDirectory.get() ); } else { outsideWorld.stdErrLine( "This instance was not bound. No work performed." ); } } catch ( StoreLockException e ) { throw new CommandFailed( "Database is currently locked. Please shutdown Neo4j.", e ); } catch ( IllegalArgumentException e ) { throw new IncorrectUsage( e.getMessage() ); } catch ( UnbindFailureException | CannotWriteException | IOException e ) { throw new CommandFailed( e.getMessage(), e ); } } UnbindFromClusterCommand( Path homeDir, Path configDir, OutsideWorld outsideWorld ); @Override void execute( String[] args );  }### Answer:
@Test public void shouldIgnoreIfSpecifiedDatabaseDoesNotExist() throws Exception { File clusterStateDir = createClusterStateDir( fs ); UnbindFromClusterCommand command = new UnbindFromClusterCommand( homeDir, confDir, outsideWorld ); command.execute( databaseNameParameter( "doesnotexist.db" ) ); assertFalse( fs.fileExists( clusterStateDir ) ); }
@Test public void shouldFailToUnbindLiveDatabase() throws Exception { createClusterStateDir( fs ); UnbindFromClusterCommand command = new UnbindFromClusterCommand( homeDir, confDir, outsideWorld ); FileLock fileLock = createLockedFakeDbDir( homeDir ); try { command.execute( databaseNameParameter( GraphDatabaseSettings.DEFAULT_DATABASE_NAME ) ); fail(); } catch ( CommandFailed e ) { assertThat( e.getMessage(), containsString( "Database is currently locked. Please shutdown Neo4j." ) ); } finally { fileLock.release(); } }
@Test public void shouldRemoveClusterStateDirectoryForGivenDatabase() throws Exception { File clusterStateDir = createClusterStateDir( fs ); createUnlockedFakeDbDir( homeDir ); UnbindFromClusterCommand command = new UnbindFromClusterCommand( homeDir, confDir, outsideWorld ); command.execute( databaseNameParameter( "graph.db" ) ); assertFalse( fs.fileExists( clusterStateDir ) ); }
@Test public void shouldReportWhenClusterStateDirectoryIsNotPresent() throws Exception { createUnlockedFakeDbDir( homeDir ); UnbindFromClusterCommand command = new UnbindFromClusterCommand( homeDir, confDir, outsideWorld ); command.execute( databaseNameParameter( GraphDatabaseSettings.DEFAULT_DATABASE_NAME ) ); verify( outsideWorld ).stdErrLine( "This instance was not bound. No work performed." ); }