@Test public void runCommand() throws CommandException { cmd.execute( fileFromResource( "test.cypher" ) ); verify(shell).execute( "RETURN 42;" ); verifyNoMoreInteractions( shell ); }
@Override public void execute(@Nonnull final String argString) throws ExitException, CommandException { String filename = simpleArgParse(argString, 1, 1, COMMAND_NAME, getUsage())[0]; try ( BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream( new File(filename) )))) { bufferedReader.lines() .forEach(line -> statementParser.parseMoreText(line + "\n")); List<String> statements = statementParser.consumeStatements(); for ( String statement : statements ) { cypherShell.execute( statement ); } } catch ( IOException e ) { throw new CommandException( format("Cannot find file: '%s'", filename), e); } }
Source implements Command { @Override public void execute(@Nonnull final String argString) throws ExitException, CommandException { String filename = simpleArgParse(argString, 1, 1, COMMAND_NAME, getUsage())[0]; try ( BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream( new File(filename) )))) { bufferedReader.lines() .forEach(line -> statementParser.parseMoreText(line + "\n")); List<String> statements = statementParser.consumeStatements(); for ( String statement : statements ) { cypherShell.execute( statement ); } } catch ( IOException e ) { throw new CommandException( format("Cannot find file: '%s'", filename), e); } } }
Source implements Command { @Override public void execute(@Nonnull final String argString) throws ExitException, CommandException { String filename = simpleArgParse(argString, 1, 1, COMMAND_NAME, getUsage())[0]; try ( BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream( new File(filename) )))) { bufferedReader.lines() .forEach(line -> statementParser.parseMoreText(line + "\n")); List<String> statements = statementParser.consumeStatements(); for ( String statement : statements ) { cypherShell.execute( statement ); } } catch ( IOException e ) { throw new CommandException( format("Cannot find file: '%s'", filename), e); } } Source( CypherShell cypherShell, StatementParser statementParser ); }
Source implements Command { @Override public void execute(@Nonnull final String argString) throws ExitException, CommandException { String filename = simpleArgParse(argString, 1, 1, COMMAND_NAME, getUsage())[0]; try ( BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream( new File(filename) )))) { bufferedReader.lines() .forEach(line -> statementParser.parseMoreText(line + "\n")); List<String> statements = statementParser.consumeStatements(); for ( String statement : statements ) { cypherShell.execute( statement ); } } catch ( IOException e ) { throw new CommandException( format("Cannot find file: '%s'", filename), e); } } Source( CypherShell cypherShell, StatementParser statementParser ); @Nonnull @Override String getName(); @Nonnull @Override String getDescription(); @Nonnull @Override String getUsage(); @Nonnull @Override String getHelp(); @Nonnull @Override List<String> getAliases(); @Override void execute(@Nonnull final String argString); }
Source implements Command { @Override public void execute(@Nonnull final String argString) throws ExitException, CommandException { String filename = simpleArgParse(argString, 1, 1, COMMAND_NAME, getUsage())[0]; try ( BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream( new File(filename) )))) { bufferedReader.lines() .forEach(line -> statementParser.parseMoreText(line + "\n")); List<String> statements = statementParser.consumeStatements(); for ( String statement : statements ) { cypherShell.execute( statement ); } } catch ( IOException e ) { throw new CommandException( format("Cannot find file: '%s'", filename), e); } } Source( CypherShell cypherShell, StatementParser statementParser ); @Nonnull @Override String getName(); @Nonnull @Override String getDescription(); @Nonnull @Override String getUsage(); @Nonnull @Override String getHelp(); @Nonnull @Override List<String> getAliases(); @Override void execute(@Nonnull final String argString);  }