Search in sources :

Example 1 with PrettyPrinter

use of org.neo4j.shell.prettyprint.PrettyPrinter in project neo4j by neo4j.

the class InteractiveShellRunnerTest method setupInteractiveTestShellRunner.

private TestInteractiveShellRunner setupInteractiveTestShellRunner(String input) throws Exception {
    // NOTE: Tests using this will test a bit more of the stack using OfflineTestShell
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    ByteArrayOutputStream error = new ByteArrayOutputStream();
    BoltStateHandler mockedBoltStateHandler = mock(BoltStateHandler.class);
    when(mockedBoltStateHandler.getProtocolVersion()).thenReturn("");
    final PrettyPrinter mockedPrettyPrinter = mock(PrettyPrinter.class);
    Logger logger = new AnsiLogger(false, Format.VERBOSE, new PrintStream(output), new PrintStream(error));
    OfflineTestShell offlineTestShell = new OfflineTestShell(logger, mockedBoltStateHandler, mockedPrettyPrinter);
    CommandHelper commandHelper = new CommandHelper(logger, Historian.empty, offlineTestShell);
    offlineTestShell.setCommandHelper(commandHelper);
    InputStream inputStream = new ByteArrayInputStream(input.getBytes());
    InteractiveShellRunner runner = new InteractiveShellRunner(offlineTestShell, offlineTestShell, offlineTestShell, logger, new ShellStatementParser(), inputStream, historyFile, userMessagesHandler, connectionConfig);
    return new TestInteractiveShellRunner(runner, output, error, mockedBoltStateHandler);
}
Also used : PrintStream(java.io.PrintStream) ShellStatementParser(org.neo4j.shell.parser.ShellStatementParser) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) OfflineTestShell(org.neo4j.shell.OfflineTestShell) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Logger(org.neo4j.shell.log.Logger) AnsiLogger(org.neo4j.shell.log.AnsiLogger) AnsiLogger(org.neo4j.shell.log.AnsiLogger) CommandHelper(org.neo4j.shell.commands.CommandHelper) PrettyPrinter(org.neo4j.shell.prettyprint.PrettyPrinter) ByteArrayInputStream(java.io.ByteArrayInputStream) BoltStateHandler(org.neo4j.shell.state.BoltStateHandler)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 PrintStream (java.io.PrintStream)1 OfflineTestShell (org.neo4j.shell.OfflineTestShell)1 CommandHelper (org.neo4j.shell.commands.CommandHelper)1 AnsiLogger (org.neo4j.shell.log.AnsiLogger)1 Logger (org.neo4j.shell.log.Logger)1 ShellStatementParser (org.neo4j.shell.parser.ShellStatementParser)1 PrettyPrinter (org.neo4j.shell.prettyprint.PrettyPrinter)1 BoltStateHandler (org.neo4j.shell.state.BoltStateHandler)1